From 9c7046864fc05a0d249d4a3dd928775cb5b55307 Mon Sep 17 00:00:00 2001 From: Marco Ferrari Date: Wed, 20 Dec 2023 15:55:53 +0100 Subject: [PATCH] ci: fix release workflow (#5030) - Don't run the Release job with a matrix because we don't want to run release-please and the git tag steps more than once. - Don't get release metadata if release-please didn't create the release yet. - Populate the container image build cache. - Set the starting version and commit for release-please. --- .../.release-please-manifest.json | 4 ++- .../release-please/release-please-config.json | 3 +- .github/workflows/cd.yml | 35 +++++++++++-------- .github/workflows/ci.yml | 2 +- 4 files changed, 26 insertions(+), 18 deletions(-) diff --git a/.github/release-please/.release-please-manifest.json b/.github/release-please/.release-please-manifest.json index 0967ef42..a3a12f49 100644 --- a/.github/release-please/.release-please-manifest.json +++ b/.github/release-please/.release-please-manifest.json @@ -1 +1,3 @@ -{} +{ + ".": "6.0.0" +} diff --git a/.github/release-please/release-please-config.json b/.github/release-please/release-please-config.json index 5ab4ba41..6b355c9a 100644 --- a/.github/release-please/release-please-config.json +++ b/.github/release-please/release-please-config.json @@ -1,5 +1,6 @@ { "$schema": "https://raw.githubusercontent.com/googleapis/release-please/main/schemas/config.json", + "bootstrap-sha": "9db632f0e18a73a9845c11d0f35431e714a66772", "packages": { ".": { "changelog-path": "CHANGELOG.md", @@ -7,7 +8,7 @@ "extra-files": [ "action.yml", "README.md", - "slim/action.yaml" + "slim/action.yml" ] } } diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index 01623b19..ad2ff795 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -118,6 +118,7 @@ jobs: BUILD_REVISION=${{ env.BUILD_REVISION }} BUILD_VERSION=${{ env.BUILD_VERSION }} cache-from: type=registry,ref=${{ env.CONTAINER_IMAGE_ID }} + cache-to: type=registry,ref=${{ env.CONTAINER_IMAGE_ID }}-buildcache,mode=max load: false push: true secrets: | @@ -163,7 +164,7 @@ jobs: - test runs-on: ubuntu-latest concurrency: - group: ${{ github.workflow }}-main-${{ matrix.images.environment }} + group: ${{ github.workflow }}-main-release cancel-in-progress: true permissions: contents: write @@ -171,14 +172,8 @@ jobs: issues: write packages: write pull-requests: write - strategy: - fail-fast: false - matrix: - images: - - environment: Release-SLIM - prefix: slim- - - environment: Release - prefix: "" + env: + RELEASE_ENVIRONMENT: "Release" timeout-minutes: 60 steps: - uses: google-github-actions/release-please-action@v4 @@ -188,16 +183,17 @@ jobs: manifest-file: .github/release-please/.release-please-manifest.json token: ${{ secrets.GITHUB_TOKEN }} - - name: Start ${{ matrix.images.environment }} Deployment + - name: Start deployment if: steps.release.outputs.release_created uses: bobheadxi/deployments@v1.4.0 id: deployment with: step: start token: ${{ secrets.GITHUB_TOKEN }} - env: ${{ matrix.images.environment }} + env: ${{ env.RELEASE_ENVIRONMENT }} - name: Configure release metedata + if: steps.release.outputs.release_created # shellcheck disable=SC2062 run: | RELEASE_VERSION="${{ steps.release.outputs.tag_name }}" @@ -233,10 +229,19 @@ jobs: if: steps.release.outputs.release_created uses: akhilerm/tag-push-action@v2.1.0 with: - src: ghcr.io/super-linter/super-linter:${{ matrix.images.prefix }}latest + src: ghcr.io/super-linter/super-linter:latest dst: | - ghcr.io/super-linter/super-linter:${{ matrix.images.prefix }}${{ env.SEMVER_MAJOR_VERSION }} - ghcr.io/super-linter/super-linter:${{ matrix.images.prefix }}${{ env.RELEASE_VERSION }} + ghcr.io/super-linter/super-linter:${{ env.SEMVER_MAJOR_VERSION }} + ghcr.io/super-linter/super-linter:${{ env.RELEASE_VERSION }} + + - name: Retag and Push Images slim + if: steps.release.outputs.release_created + uses: akhilerm/tag-push-action@v2.1.0 + with: + src: ghcr.io/super-linter/super-linter:slim-latest + dst: | + ghcr.io/super-linter/super-linter:slim-${{ env.SEMVER_MAJOR_VERSION }} + ghcr.io/super-linter/super-linter:slim-${{ env.RELEASE_VERSION }} # No need to tag major.minor.patch because that tag is automatically created when creating the release - name: Tag major, minor, and latest versions @@ -248,7 +253,7 @@ jobs: git push --force origin ${{ env.SEMVER_MAJOR_VERSION }} git push --force origin latest - - name: Update ${{ matrix.images.environment }} Deployment + - name: Update deployment uses: bobheadxi/deployments@v1.4.0 # We depend on the 'deployment' step outputs, so we can't run this step # if the 'deployment' step didn't run. This can happen if any step diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8b634e20..7967c82a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -86,7 +86,7 @@ jobs: BUILD_DATE=${{ env.BUILD_DATE }} BUILD_REVISION=${{ env.BUILD_REVISION }} BUILD_VERSION=${{ env.BUILD_VERSION }} - cache-from: type=registry,ref=${{ env.CONTAINER_IMAGE_ID }} + cache-from: type=registry,ref=${{ env.CONTAINER_IMAGE_ID }}-buildcache load: true push: false secrets: |