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.
This commit is contained in:
Marco Ferrari 2023-12-20 15:55:53 +01:00 committed by GitHub
parent 93b5ede1e8
commit 9c7046864f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 26 additions and 18 deletions

View file

@ -1 +1,3 @@
{} {
".": "6.0.0"
}

View file

@ -1,5 +1,6 @@
{ {
"$schema": "https://raw.githubusercontent.com/googleapis/release-please/main/schemas/config.json", "$schema": "https://raw.githubusercontent.com/googleapis/release-please/main/schemas/config.json",
"bootstrap-sha": "9db632f0e18a73a9845c11d0f35431e714a66772",
"packages": { "packages": {
".": { ".": {
"changelog-path": "CHANGELOG.md", "changelog-path": "CHANGELOG.md",
@ -7,7 +8,7 @@
"extra-files": [ "extra-files": [
"action.yml", "action.yml",
"README.md", "README.md",
"slim/action.yaml" "slim/action.yml"
] ]
} }
} }

View file

@ -118,6 +118,7 @@ jobs:
BUILD_REVISION=${{ env.BUILD_REVISION }} BUILD_REVISION=${{ env.BUILD_REVISION }}
BUILD_VERSION=${{ env.BUILD_VERSION }} BUILD_VERSION=${{ env.BUILD_VERSION }}
cache-from: type=registry,ref=${{ env.CONTAINER_IMAGE_ID }} cache-from: type=registry,ref=${{ env.CONTAINER_IMAGE_ID }}
cache-to: type=registry,ref=${{ env.CONTAINER_IMAGE_ID }}-buildcache,mode=max
load: false load: false
push: true push: true
secrets: | secrets: |
@ -163,7 +164,7 @@ jobs:
- test - test
runs-on: ubuntu-latest runs-on: ubuntu-latest
concurrency: concurrency:
group: ${{ github.workflow }}-main-${{ matrix.images.environment }} group: ${{ github.workflow }}-main-release
cancel-in-progress: true cancel-in-progress: true
permissions: permissions:
contents: write contents: write
@ -171,14 +172,8 @@ jobs:
issues: write issues: write
packages: write packages: write
pull-requests: write pull-requests: write
strategy: env:
fail-fast: false RELEASE_ENVIRONMENT: "Release"
matrix:
images:
- environment: Release-SLIM
prefix: slim-
- environment: Release
prefix: ""
timeout-minutes: 60 timeout-minutes: 60
steps: steps:
- uses: google-github-actions/release-please-action@v4 - uses: google-github-actions/release-please-action@v4
@ -188,16 +183,17 @@ jobs:
manifest-file: .github/release-please/.release-please-manifest.json manifest-file: .github/release-please/.release-please-manifest.json
token: ${{ secrets.GITHUB_TOKEN }} token: ${{ secrets.GITHUB_TOKEN }}
- name: Start ${{ matrix.images.environment }} Deployment - name: Start deployment
if: steps.release.outputs.release_created if: steps.release.outputs.release_created
uses: bobheadxi/deployments@v1.4.0 uses: bobheadxi/deployments@v1.4.0
id: deployment id: deployment
with: with:
step: start step: start
token: ${{ secrets.GITHUB_TOKEN }} token: ${{ secrets.GITHUB_TOKEN }}
env: ${{ matrix.images.environment }} env: ${{ env.RELEASE_ENVIRONMENT }}
- name: Configure release metedata - name: Configure release metedata
if: steps.release.outputs.release_created
# shellcheck disable=SC2062 # shellcheck disable=SC2062
run: | run: |
RELEASE_VERSION="${{ steps.release.outputs.tag_name }}" RELEASE_VERSION="${{ steps.release.outputs.tag_name }}"
@ -233,10 +229,19 @@ jobs:
if: steps.release.outputs.release_created if: steps.release.outputs.release_created
uses: akhilerm/tag-push-action@v2.1.0 uses: akhilerm/tag-push-action@v2.1.0
with: with:
src: ghcr.io/super-linter/super-linter:${{ matrix.images.prefix }}latest src: ghcr.io/super-linter/super-linter:latest
dst: | dst: |
ghcr.io/super-linter/super-linter:${{ matrix.images.prefix }}${{ env.SEMVER_MAJOR_VERSION }} ghcr.io/super-linter/super-linter:${{ env.SEMVER_MAJOR_VERSION }}
ghcr.io/super-linter/super-linter:${{ matrix.images.prefix }}${{ env.RELEASE_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 # No need to tag major.minor.patch because that tag is automatically created when creating the release
- name: Tag major, minor, and latest versions - name: Tag major, minor, and latest versions
@ -248,7 +253,7 @@ jobs:
git push --force origin ${{ env.SEMVER_MAJOR_VERSION }} git push --force origin ${{ env.SEMVER_MAJOR_VERSION }}
git push --force origin latest git push --force origin latest
- name: Update ${{ matrix.images.environment }} Deployment - name: Update deployment
uses: bobheadxi/deployments@v1.4.0 uses: bobheadxi/deployments@v1.4.0
# We depend on the 'deployment' step outputs, so we can't run this step # 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 # if the 'deployment' step didn't run. This can happen if any step

View file

@ -86,7 +86,7 @@ jobs:
BUILD_DATE=${{ env.BUILD_DATE }} BUILD_DATE=${{ env.BUILD_DATE }}
BUILD_REVISION=${{ env.BUILD_REVISION }} BUILD_REVISION=${{ env.BUILD_REVISION }}
BUILD_VERSION=${{ env.BUILD_VERSION }} 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 load: true
push: false push: false
secrets: | secrets: |