Skip to content

Commit

Permalink
test local
Browse files Browse the repository at this point in the history
  • Loading branch information
galal-hussein committed Jun 7, 2024
1 parent e824ada commit f72114a
Show file tree
Hide file tree
Showing 14 changed files with 106 additions and 113 deletions.
160 changes: 77 additions & 83 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ on:
- "v*"

env:
GITHUB_TAG: ${{ github.ref_name }}
GITHUB_ACTION_TAG: ${{ github.ref_name }}

name: Release
permissions:
contents: write
id-token: write
jobs:
release-amd64:
runs-on: runs-on,runner=8cpu-linux-x64,run-id=${{ github.run_id }},image=ubuntu22-full-x64,hdd=64
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
Expand All @@ -35,118 +35,112 @@ jobs:
run: |
dapper -f Dockerfile --target dapper make dapper-ci
- name: "Read secrets"
uses: rancher-eio/read-vault-secrets@main
with:
secrets: |
secret/data/github/repo/${{ github.repository }}/dockerhub/${{ github.repository_owner }}/credentials username | DOCKER_USERNAME ;
secret/data/github/repo/${{ github.repository }}/dockerhub/${{ github.repository_owner }}/credentials password | DOCKER_PASSWORD ;
# - name: "Read secrets"
# uses: rancher-eio/read-vault-secrets@main
# with:
# secrets: |
# secret/data/github/repo/${{ github.repository }}/dockerhub/${{ github.repository_owner }}/credentials username | DOCKER_USERNAME ;
# secret/data/github/repo/${{ github.repository }}/dockerhub/${{ github.repository_owner }}/credentials password | DOCKER_PASSWORD ;

- name: Package Images
run: |
dapper -f Dockerfile --target dapper make package-images
- name: Scan Images
continue-on-error: true
run: |
dapper -f Dockerfile --target dapper make scan-images
- name: Test
run: |
dapper -f Dockerfile --target dapper make test
- name: Login to Container Registry
uses: docker/login-action@v3
with:
username: ${{ env.DOCKER_USERNAME }}
password: ${{ env.DOCKER_PASSWORD }}
- name: Publish Image Runtime
run: |
GITHUB_TAG=${{ github.ref_name }} make publish-image-runtime
GITHUB_ACTION_TAG=${{ github.ref_name }} dapper -f Dockerfile --target dapper make publish-image-runtime
env:
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}

- name: Checksum Artifacts
run: |
dapper -f Dockerfile --target dapper make checksum
- name: Publish Artifacts
uses: softprops/action-gh-release@v2
with:
files: |
dist/artifacts/*
release-arm64:
runs-on: runs-on,runner=8cpu-linux-arm64,run-id=${{ github.run_id }},image=ubuntu22-full-arm64,hdd=64
steps:
- name: Checkout code
uses: actions/checkout@v4
# release-arm64:
# runs-on: runs-on,runner=8cpu-linux-arm64,run-id=${{ github.run_id }},image=ubuntu22-full-arm64,hdd=64
# steps:
# - name: Checkout code
# uses: actions/checkout@v4

- name: Install Dapper
run: |
curl -sL https://releases.rancher.com/dapper/latest/dapper-$(uname -s)-$(uname -m) > /usr/local/bin/dapper
chmod +x /usr/local/bin/dapper
# - name: Install Dapper
# run: |
# curl -sL https://releases.rancher.com/dapper/latest/dapper-$(uname -s)-$(uname -m) > /usr/local/bin/dapper
# chmod +x /usr/local/bin/dapper

- name: Validate Release
run: |
dapper -f Dockerfile --target dapper make validate-release
# - name: Validate Release
# run: |
# dapper -f Dockerfile --target dapper make validate-release

- name: Build
run: |
dapper -f Dockerfile --target dapper make dapper-ci
# - name: Build
# run: |
# dapper -f Dockerfile --target dapper make dapper-ci

- name: "Read secrets"
uses: rancher-eio/read-vault-secrets@main
with:
secrets: |
secret/data/github/repo/${{ github.repository }}/dockerhub/${{ github.repository_owner }}/credentials username | DOCKER_USERNAME ;
secret/data/github/repo/${{ github.repository }}/dockerhub/${{ github.repository_owner }}/credentials password | DOCKER_PASSWORD ;
# - name: "Read secrets"
# uses: rancher-eio/read-vault-secrets@main
# with:
# secrets: |
# secret/data/github/repo/${{ github.repository }}/dockerhub/${{ github.repository_owner }}/credentials username | DOCKER_USERNAME ;
# secret/data/github/repo/${{ github.repository }}/dockerhub/${{ github.repository_owner }}/credentials password | DOCKER_PASSWORD ;

- name: Package Images
run: |
dapper -f Dockerfile --target dapper make package-images
# - name: Package Images
# run: |
# dapper -f Dockerfile --target dapper make package-images

- name: Scan Images
run: |
dapper -f Dockerfile --target dapper make scan-images
# - name: Scan Images
# run: |
# dapper -f Dockerfile --target dapper make scan-images

- name: Login to Container Registry
uses: docker/login-action@v3
with:
username: ${{ env.DOCKER_USERNAME }}
password: ${{ env.DOCKER_PASSWORD }}
# - name: Login to Container Registry
# uses: docker/login-action@v3
# with:
# username: ${{ env.DOCKER_USERNAME }}
# password: ${{ env.DOCKER_PASSWORD }}

- name: Publish Image Runtime
run: |
GITHUB_TAG=${{ github.ref_name }} make publish-image-runtime
# - name: Publish Image Runtime
# run: |
# GITHUB_TAG=${{ github.ref_name }} make publish-image-runtime

- name: Checksum Artifacts
run: |
dapper -f Dockerfile --target dapper make checksum
# - name: Checksum Artifacts
# run: |
# dapper -f Dockerfile --target dapper make checksum

- name: Publish Artifacts
uses: softprops/action-gh-release@v2
with:
files: |
dist/artifacts/*
dispatch:
needs: [release-amd64, release-arm64]
runs-on: runs-on,runner=8cpu-linux-x64,run-id=${{ github.run_id }},image=ubuntu22-full-x64,hdd=64
steps:
- name: Checkout code
uses: actions/checkout@v4
# - name: Publish Artifacts
# uses: softprops/action-gh-release@v2
# with:
# files: |
# dist/artifacts/*
# dispatch:
# needs: [release-amd64, release-arm64]
# runs-on: runs-on,runner=8cpu-linux-x64,run-id=${{ github.run_id }},image=ubuntu22-full-x64,hdd=64
# steps:
# - name: Checkout code
# uses: actions/checkout@v4

- name: Install Dapper
run: |
curl -sL https://releases.rancher.com/dapper/latest/dapper-$(uname -s)-$(uname -m) > /usr/local/bin/dapper
chmod +x /usr/local/bin/dapper
# - name: Install Dapper
# run: |
# curl -sL https://releases.rancher.com/dapper/latest/dapper-$(uname -s)-$(uname -m) > /usr/local/bin/dapper
# chmod +x /usr/local/bin/dapper

- name: "Read secrets"
uses: rancher-eio/read-vault-secrets@main
with:
secrets: |
secret/data/github/repo/${{ github.repository }}/pat_username/credentials token | PAT_USERNAME ;
# - name: "Read secrets"
# uses: rancher-eio/read-vault-secrets@main
# with:
# secrets: |
# secret/data/github/repo/${{ github.repository }}/pat_username/credentials token | PAT_USERNAME ;

- name: Dispatch
run: |
dapper -f Dockerfile --target dapper make dispatch
env:
PAT_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PATH_USERNAME: ${{ env.PAT_USERNAME }}
# - name: Dispatch
# run: |
# dapper -f Dockerfile --target dapper make dispatch
# env:
# PAT_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# PATH_USERNAME: ${{ env.PAT_USERNAME }}
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ RUN zypper install -y systemd-rpm-macros

# Dapper/Drone/CI environment
FROM build AS dapper
ENV DAPPER_ENV GODEBUG GOCOVER REPO TAG GITHUB_TAG PAT_USERNAME PAT_TOKEN KUBERNETES_VERSION DOCKER_BUILDKIT DRONE_BUILD_EVENT IMAGE_NAME AWS_SECRET_ACCESS_KEY AWS_ACCESS_KEY_ID ENABLE_REGISTRY
ENV DAPPER_ENV GODEBUG GOCOVER REPO TAG GITHUB_ACTION_TAG PAT_USERNAME PAT_TOKEN KUBERNETES_VERSION DOCKER_BUILDKIT DRONE_BUILD_EVENT IMAGE_NAME AWS_SECRET_ACCESS_KEY AWS_ACCESS_KEY_ID ENABLE_REGISTRY DOCKER_USERNAME DOCKER_PASSWORD
ARG DAPPER_HOST_ARCH
ENV ARCH $DAPPER_HOST_ARCH
ENV DAPPER_OUTPUT ./dist ./bin ./build
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile.windows
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ RUN apk --no-cache add \

# Dapper/Drone/CI environment
FROM rancher/hardened-build-base:v1.21.5b2 AS dapper
ENV DAPPER_ENV GODEBUG REPO TAG GITHUB_TAG PAT_USERNAME PAT_TOKEN KUBERNETES_VERSION DOCKER_BUILDKIT DRONE_BUILD_EVENT IMAGE_NAME AWS_SECRET_ACCESS_KEY AWS_ACCESS_KEY_ID ENABLE_REGISTRY
ENV DAPPER_ENV GODEBUG REPO TAG GITHUB_ACTION_TAG PAT_USERNAME PAT_TOKEN KUBERNETES_VERSION DOCKER_BUILDKIT DRONE_BUILD_EVENT IMAGE_NAME AWS_SECRET_ACCESS_KEY AWS_ACCESS_KEY_ID ENABLE_REGISTRY
ARG DAPPER_HOST_ARCH
ENV ARCH $DAPPER_HOST_ARCH
ENV DAPPER_OUTPUT ./dist ./bin ./build
Expand Down
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ build-image-runtime: ## Build the runtime image

.PHONY: publish-image-runtime
publish-image-runtime: build-image-runtime
./scripts/checksum
./scripts/publish-image-runtime

.PHONY: validate
Expand Down
8 changes: 4 additions & 4 deletions scripts/build-image-runtime
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ DOCKER_BUILDKIT=${DOCKER_BUILDKIT:-1} docker image build \
--build-arg MINOR=${VERSION_MINOR} \
--build-arg DAPPER_HOST_ARCH=${GOARCH} \
--build-arg CACHEBUST="$(date +%s%N)" \
--tag ${REPO}/${PROG}-runtime:${DOCKERIZED_VERSION} \
--tag ${REPO}/${PROG}-runtime:${DOCKERIZED_VERSION}-${GOOS}-${GOARCH} \
--tag husseingalal/${PROG}-runtime:${DOCKERIZED_VERSION} \
--tag husseingalal/${PROG}-runtime:${DOCKERIZED_VERSION}-${GOOS}-${GOARCH} \
--target runtime \
--file Dockerfile \
.
Expand All @@ -25,12 +25,12 @@ if [ "${GOARCH}" != "s390x" ] && [ "${GOARCH}" != "arm64" ]; then
--build-arg MAJOR=${VERSION_MAJOR} \
--build-arg MINOR=${VERSION_MINOR} \
--build-arg CACHEBUST="$(date +%s%N)" \
--tag ${REPO}/${PROG}-runtime:${DOCKERIZED_VERSION}-windows-amd64 \
--tag husseingalal/${PROG}-runtime:${DOCKERIZED_VERSION}-windows-amd64 \
--target windows-runtime \
--file Dockerfile.windows \
.
fi
mkdir -p build/images
docker image save \
--output build/images/${PROG}-runtime.tar \
${REPO}/${PROG}-runtime:${DOCKERIZED_VERSION}-${GOOS}-${GOARCH}
husseingalal/${PROG}-runtime:${DOCKERIZED_VERSION}-${GOOS}-${GOARCH}
4 changes: 2 additions & 2 deletions scripts/build-image-test
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ DOCKER_BUILDKIT=${DOCKER_BUILDKIT:-1} docker image build \
--build-arg TAG=${VERSION} \
--build-arg KUBERNETES_VERSION=${KUBERNETES_VERSION} \
--build-arg CACHEBUST="$(date +%s%N)" \
--tag ${REPO}/${PROG}-test:${DOCKERIZED_VERSION} \
--tag ${REPO}/${PROG}-test:${DOCKERIZED_VERSION}-${GOARCH} \
--tag husseingalal/${PROG}-test:${DOCKERIZED_VERSION} \
--tag husseingalal/${PROG}-test:${DOCKERIZED_VERSION}-${GOARCH} \
--target test \
.
2 changes: 1 addition & 1 deletion scripts/build-images
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ source ./scripts/version.sh
./scripts/build-image-runtime

awk '{print $1}' << EOF > build/images-core.txt
${REGISTRY}/${REPO}/${PROG}-runtime:${DOCKERIZED_VERSION}
${REGISTRY}/husseingalal/${PROG}-runtime:${DOCKERIZED_VERSION}
EOF

xargs -n1 -t docker image pull --quiet << EOF >> build/images-core.txt
Expand Down
20 changes: 7 additions & 13 deletions scripts/checksum
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,12 @@ source ./scripts/version.sh

CHECKSUM_DIR=${CHECKSUM_DIR:-./dist/artifacts}

function checksum(){
sumfile="${CHECKSUM_DIR}/sha256sum-${ARCH}.txt"
echo -n "" > "${sumfile}"

sumfile="${CHECKSUM_DIR}/sha256sum-${ARCH}.txt"
echo -n "" > "${sumfile}"
files=$(ls ${CHECKSUM_DIR} | grep "${ARCH}" | grep -v "sha256sum-${ARCH}.txt")
for file in ${files}; do
sha256sum "${CHECKSUM_DIR}/${file}" | sed "s;$(dirname ${CHECKSUM_DIR}/${file})/;;g" >> "${sumfile}"
done

files=$(ls ${CHECKSUM_DIR})
for file in ${files}; do
sha256sum "${file}" | sed "s;$(dirname ${file})/;;g" >> "${sumfile}"
done

cat "${sumfile}"
}


checksum
cat "${sumfile}"
2 changes: 1 addition & 1 deletion scripts/package
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ mkdir -p dist/{artifacts,bundle}
./scripts/package-binary
./scripts/package-windows-binary
./scripts/package-bundle
./scripts/package-windows-bundle
./scripts/package-windows-bundle
2 changes: 1 addition & 1 deletion scripts/package-binary
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ source ./scripts/version.sh

mkdir -p dist/artifacts

install -s bin/${PROG} dist/artifacts/${RELEASE}
install -s bin/${PROG} dist/artifacts/${RELEASE}
2 changes: 1 addition & 1 deletion scripts/package-dev-rpm
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ while IFS= read -r script; do
"${script}"

# Build rpm
bash "${script}"
TAG=${RPM_VERSION} bash "${script}"
done <"${SCRIPT_LIST}"

if [ "${DAPPER_UID:--1}" -ne "-1" ]; then
Expand Down
4 changes: 2 additions & 2 deletions scripts/package-windows-images
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ mkdir -p dist/artifacts
# 1809/LTSC
crane --platform windows/amd64 pull \
${REGISTRY}/${REPO}/${PROG}-runtime:${DOCKERIZED_VERSION}-windows-amd64 \
rancher/pause:${PAUSE_VERSION}-windows-1809-amd64 \
husseingalal/pause:${PAUSE_VERSION}-windows-1809-amd64 \
rke2-windows-1809-amd64-images.tar

# 2022/LTSC
crane --platform windows/amd64 pull \
${REGISTRY}/${REPO}/${PROG}-runtime:${DOCKERIZED_VERSION}-windows-amd64 \
rancher/pause:${PAUSE_VERSION}-windows-ltsc2022-amd64 \
husseingalal/pause:${PAUSE_VERSION}-windows-ltsc2022-amd64 \
rke2-windows-ltsc2022-amd64-images.tar

WINDOWS_TARFILES=(rke2-windows-1809-amd64-images.tar rke2-windows-ltsc2022-amd64-images.tar)
Expand Down
8 changes: 6 additions & 2 deletions scripts/publish-image-runtime
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@ cd $(dirname $0)/..

source ./scripts/version.sh

docker image push ${REPO}/${PROG}-runtime:${DOCKERIZED_VERSION}-${GOOS}-${GOARCH}
set +x
docker login -u $DOCKER_USERNAME -p $DOCKER_PASSWORD
set -x

docker image push husseingalal/${PROG}-runtime:${DOCKERIZED_VERSION}-${GOOS}-${GOARCH}
if [ "${GOARCH}" != "s390x" ] && [ "${GOARCH}" != "arm64" ]; then
docker image push ${REPO}/${PROG}-runtime:${DOCKERIZED_VERSION}-windows-amd64
docker image push husseingalal/${PROG}-runtime:${DOCKERIZED_VERSION}-windows-amd64
fi
2 changes: 1 addition & 1 deletion scripts/validate-release
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,6 @@ function check_kubernetes_version() {
. ./scripts/version.sh

git fetch origin -f --tags
parse_tag $GITHUB_TAG
parse_tag $GITHUB_ACTION_TAG
check_release_branch
check_kubernetes_version

0 comments on commit f72114a

Please sign in to comment.