From 61e5042bf71c1c071cf17c3ad81dc7f49e582886 Mon Sep 17 00:00:00 2001 From: yy <56745951+lingdie@users.noreply.github.com> Date: Mon, 6 Nov 2023 16:48:16 +0800 Subject: [PATCH 1/5] Release ci (#29) * add cloud release ci. Signed-off-by: yy * fix Signed-off-by: yy * add workflow_call. Signed-off-by: yy * fix secret. Signed-off-by: yy --------- Signed-off-by: yy --- .github/workflows/cloud-release.yml | 51 +++++++++++++++++++++++++++++ .github/workflows/cloud.yml | 19 +++++++++-- .github/workflows/controllers.yml | 12 +++++++ .github/workflows/frontend.yml | 12 +++++++ .github/workflows/services.yml | 12 +++++++ 5 files changed, 104 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/cloud-release.yml diff --git a/.github/workflows/cloud-release.yml b/.github/workflows/cloud-release.yml new file mode 100644 index 00000000000..f9d6eb55567 --- /dev/null +++ b/.github/workflows/cloud-release.yml @@ -0,0 +1,51 @@ +name: Release Cloud + +on: + release: + types: [ published ] + +env: + # Common versions + GO_VERSION: "1.20" + DEFAULT_OWNER: "labring" + TAG: ${{ github.event.release.tag_name }} + +jobs: + save-sealos: + uses: ./.github/workflows/import-save-sealos.yml + + release-controllers: + uses: ./.github/workflows/controllers.yml + with: + push_image: true + push_image_tag: ${{ env.TAG }} + secrets: inherit + + release-frontends: + uses: ./.github/workflows/frontend.yml + with: + push_image: true + push_image_tag: ${{ env.TAG }} + secrets: inherit + + release-service: + needs: + - save-sealos + uses: ./.github/workflows/services.yml + with: + push_image: true + push_image_tag: ${{ env.TAG }} + secrets: inherit + + release-cloud: + needs: + - save-sealos + - release-controllers + - release-frontends + - release-service + uses: ./.github/workflows/cloud.yml + with: + push_image: true + push_image_tag: ${{ env.TAG }} + build_from: ${{ env.TAG }} + secrets: inherit \ No newline at end of file diff --git a/.github/workflows/cloud.yml b/.github/workflows/cloud.yml index abef9bb5ebf..44828b485d0 100644 --- a/.github/workflows/cloud.yml +++ b/.github/workflows/cloud.yml @@ -1,12 +1,27 @@ name: Build Cloud Cluster image on: - release: - types: [ published ] workflow_run: workflows: [ "Build Controllers image", "Build Frontend Image" ] types: - completed + workflow_call: + inputs: + push_image: + description: 'Push image' + required: false + type: boolean + default: false + push_image_tag: + description: 'Push all-in-one image tag, default is latest' + default: 'latest' + required: false + type: string + build_from: + description: 'Build all-in-one image from components image tag, default is latest' + default: 'latest' + required: false + type: string workflow_dispatch: inputs: push_image: diff --git a/.github/workflows/controllers.yml b/.github/workflows/controllers.yml index 3e28c33fcff..4153d9db358 100644 --- a/.github/workflows/controllers.yml +++ b/.github/workflows/controllers.yml @@ -3,6 +3,18 @@ name: Build Controllers image on: create: tags: + workflow_call: + inputs: + push_image: + description: "Push image" + required: false + type: boolean + default: false + push_image_tag: + description: "Push image tag" + default: "latest" + required: false + type: string workflow_dispatch: inputs: push_image: diff --git a/.github/workflows/frontend.yml b/.github/workflows/frontend.yml index 627744ae9e5..87cc9dce5bf 100644 --- a/.github/workflows/frontend.yml +++ b/.github/workflows/frontend.yml @@ -3,6 +3,18 @@ name: Build Frontend Image on: create: tags: + workflow_call: + inputs: + push_image: + description: "Push image" + required: false + type: boolean + default: false + push_image_tag: + description: "Push image tag" + default: "latest" + required: false + type: string workflow_dispatch: inputs: push_image: diff --git a/.github/workflows/services.yml b/.github/workflows/services.yml index fa2400655ac..5aa262b4255 100644 --- a/.github/workflows/services.yml +++ b/.github/workflows/services.yml @@ -4,6 +4,18 @@ name: Build Services image on: create: tags: + workflow_call: + inputs: + push_image: + description: 'Push image' + required: false + type: boolean + default: false + push_image_tag: + description: 'Push image tag' + default: 'latest' + required: false + type: string workflow_dispatch: inputs: push_image: From dfbcf1395cacc7a0feb95dc50e26e8d473f0dca3 Mon Sep 17 00:00:00 2001 From: yy <56745951+lingdie@users.noreply.github.com> Date: Mon, 6 Nov 2023 16:53:48 +0800 Subject: [PATCH 2/5] Update cloud-release.yml --- .github/workflows/cloud-release.yml | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/.github/workflows/cloud-release.yml b/.github/workflows/cloud-release.yml index f9d6eb55567..9d6c55bba8f 100644 --- a/.github/workflows/cloud-release.yml +++ b/.github/workflows/cloud-release.yml @@ -8,7 +8,6 @@ env: # Common versions GO_VERSION: "1.20" DEFAULT_OWNER: "labring" - TAG: ${{ github.event.release.tag_name }} jobs: save-sealos: @@ -18,14 +17,14 @@ jobs: uses: ./.github/workflows/controllers.yml with: push_image: true - push_image_tag: ${{ env.TAG }} + push_image_tag: ${{ github.event.release.tag_name }} secrets: inherit release-frontends: uses: ./.github/workflows/frontend.yml with: push_image: true - push_image_tag: ${{ env.TAG }} + push_image_tag: ${{ github.event.release.tag_name }} secrets: inherit release-service: @@ -34,7 +33,7 @@ jobs: uses: ./.github/workflows/services.yml with: push_image: true - push_image_tag: ${{ env.TAG }} + push_image_tag: ${{ github.event.release.tag_name }} secrets: inherit release-cloud: @@ -46,6 +45,6 @@ jobs: uses: ./.github/workflows/cloud.yml with: push_image: true - push_image_tag: ${{ env.TAG }} - build_from: ${{ env.TAG }} - secrets: inherit \ No newline at end of file + push_image_tag: ${{ github.event.release.tag_name }} + build_from: ${{ github.event.release.tag_name }} + secrets: inherit From e91b4d78fa907d7a9d77198a485ed9a9ba81617b Mon Sep 17 00:00:00 2001 From: yy <56745951+lingdie@users.noreply.github.com> Date: Fri, 3 Nov 2023 15:09:51 +0800 Subject: [PATCH 3/5] Release ci (#26) * add cloud release ci. Signed-off-by: yy * fix Signed-off-by: yy --------- Signed-off-by: yy --- .github/workflows/cloud-release.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/cloud-release.yml b/.github/workflows/cloud-release.yml index 9d6c55bba8f..e1309c71e08 100644 --- a/.github/workflows/cloud-release.yml +++ b/.github/workflows/cloud-release.yml @@ -45,6 +45,11 @@ jobs: uses: ./.github/workflows/cloud.yml with: push_image: true +<<<<<<< HEAD push_image_tag: ${{ github.event.release.tag_name }} build_from: ${{ github.event.release.tag_name }} secrets: inherit +======= + push_image_tag: ${{ env.TAG }} + build_from: ${{ env.TAG }} +>>>>>>> 73be102a (Release ci (#26)) From 4dd41d8ad2460d9dc7ef9e3868e71ddd4a1b2740 Mon Sep 17 00:00:00 2001 From: yy Date: Tue, 7 Nov 2023 10:42:47 +0800 Subject: [PATCH 4/5] add cloud release ci. Signed-off-by: yy --- .github/workflows/cloud-release.yml | 27 +++++++++--- .github/workflows/cloud.yml | 4 -- scripts/cloud/build-offline-tar.sh | 66 +++++++++++++++++++++++++++++ 3 files changed, 88 insertions(+), 9 deletions(-) create mode 100644 scripts/cloud/build-offline-tar.sh diff --git a/.github/workflows/cloud-release.yml b/.github/workflows/cloud-release.yml index e1309c71e08..03d9feaf915 100644 --- a/.github/workflows/cloud-release.yml +++ b/.github/workflows/cloud-release.yml @@ -45,11 +45,28 @@ jobs: uses: ./.github/workflows/cloud.yml with: push_image: true -<<<<<<< HEAD push_image_tag: ${{ github.event.release.tag_name }} build_from: ${{ github.event.release.tag_name }} secrets: inherit -======= - push_image_tag: ${{ env.TAG }} - build_from: ${{ env.TAG }} ->>>>>>> 73be102a (Release ci (#26)) + + release-offline-tar: + needs: + - release-cloud + runs-on: ubuntu:latest + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Build + run: export CLOUD_VERSION=${{ github.event.release.tag_name }} && bash ./scripts/cloud/build-offline-tar.sh + - name: Setup ossutil + uses: manyuanrong/setup-ossutil@v2.0 + with: + endpoint: ${{ secrets.OSS_ENDPOINT }} + access-key-id: ${{ secrets.OSS_ACCESS_KEY_ID }} + access-key-secret: ${{ secrets.OSS_ACCESS_KEY_SECRET }} + - name: Cat md5sum + run: cat ./sealos-cloud.tar.gz.md5 + - name: Upload + run: | + ossutil cp ./sealos-cloud.tar.gz oss://${{ secrets.OSS_BUCKET }}/cloud/sealos-cloud-${{ github.event.release.tag_name }}.tar.gz + ossutil cp ./sealos-cloud.tar.gz.md5 oss://${{ secrets.OSS_BUCKET }}/cloud/sealos-cloud-${{ github.event.release.tag_name }}.tar.gz.md5 \ No newline at end of file diff --git a/.github/workflows/cloud.yml b/.github/workflows/cloud.yml index 44828b485d0..c6e2cd4f11c 100644 --- a/.github/workflows/cloud.yml +++ b/.github/workflows/cloud.yml @@ -1,10 +1,6 @@ name: Build Cloud Cluster image on: - workflow_run: - workflows: [ "Build Controllers image", "Build Frontend Image" ] - types: - - completed workflow_call: inputs: push_image: diff --git a/scripts/cloud/build-offline-tar.sh b/scripts/cloud/build-offline-tar.sh new file mode 100644 index 00000000000..d368a53c75a --- /dev/null +++ b/scripts/cloud/build-offline-tar.sh @@ -0,0 +1,66 @@ +#!/bin/bash +set -x + +CLOUD_VERSION="latest" + +# pull and save images +mkdir -p output/tars + +images=( + docker.io/labring/sealos-cloud:$CLOUD_VERSION + docker.io/labring/kubernetes:v1.25.6 + docker.io/labring/helm:v3.12.0 + docker.io/labring/cilium:v1.12.14 + docker.io/labring/cert-manager:v1.8.0 + docker.io/labring/openebs:v3.4.0 + docker.io/labring/kubernetes-reflector:v7.0.151 + docker.io/labring/ingress-nginx:v1.5.1 + docker.io/labring/kubeblocks:v0.6.4 + docker.io/labring/metrics-server:v0.6.4 +) + +for image in "${images[@]}"; do + sealos pull "$image" + filename=$(echo "$image" | cut -d':' -f1 | tr / -) + if [[ ! -f "output/tars/${filename}.tar" ]]; then + sealos save -o "output/tars/${filename}.tar" "$image" + fi +done + + +# get and save cli +mkdir -p output/cli + +VERSION="v4.3.5" + +wget https://github.com/labring/sealos/releases/download/${VERSION}/sealos_${VERSION#v}_linux_amd64.tar.gz \ + && tar zxvf sealos_${VERSION#v}_linux_amd64.tar.gz sealos && chmod +x sealos && mv sealos output/cli + +# get and save install scripts +echo " +#!/bin/bash +bash scripts/load-images.sh +bash scripts/install.sh --cloud-version=$CLOUD_VERSION + +" > output/install.sh + +mkdir -p output/scripts + +echo ' +#!/bin/bash + +for file in tars/*.tar; do + sealos load -i $file +done + +cp cli/sealos /usr/local/bin +' > output/scripts/load-images.sh + +curl -sfL https://raw.githubusercontent.com/labring/sealos/${CLOUD_VERSION}/scripts/cloud/install.sh -o output/scripts/install.sh + +# tar output to a tar.gz +mv output sealos-cloud +tar czfv sealos-cloud.tar.gz sealos-cloud + +# md5sum output tar.gz +md5sum sealos-cloud.tar.gz | cut -d " " -f1 > sealos-cloud.tar.gz.md5 \ No newline at end of file From b55708629fad8d9b707aa633d7af6c85d1635fa0 Mon Sep 17 00:00:00 2001 From: yy Date: Tue, 7 Nov 2023 13:20:42 +0800 Subject: [PATCH 5/5] add cloud release ci. Signed-off-by: yy --- .github/workflows/cloud-release.yml | 2 +- .github/workflows/controllers.yml | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/cloud-release.yml b/.github/workflows/cloud-release.yml index 03d9feaf915..13f6b707cae 100644 --- a/.github/workflows/cloud-release.yml +++ b/.github/workflows/cloud-release.yml @@ -52,7 +52,7 @@ jobs: release-offline-tar: needs: - release-cloud - runs-on: ubuntu:latest + runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v3 diff --git a/.github/workflows/controllers.yml b/.github/workflows/controllers.yml index 4153d9db358..5d0c5eea7c8 100644 --- a/.github/workflows/controllers.yml +++ b/.github/workflows/controllers.yml @@ -62,6 +62,7 @@ jobs: run: bash ./scripts/resolve-modules.sh ./controllers golangci-lint: + if: ${{ github.event_name }} == 'push' || ${{ github.event_name }} == 'pull_request' needs: [ resolve-modules ] runs-on: ubuntu-20.04 strategy: