From ccf58d2678ff5ab5e17f9c85746084fef8b1fc47 Mon Sep 17 00:00:00 2001 From: Marco Ferrari Date: Fri, 30 Sep 2022 19:55:04 +0200 Subject: [PATCH] Use Git to update major version and latest tags (#3376) --- .github/workflows/deploy-release.yml | 15 +++++++++ .github/workflows/versioning.yml | 50 ---------------------------- docs/release-process.md | 2 +- 3 files changed, 16 insertions(+), 51 deletions(-) delete mode 100644 .github/workflows/versioning.yml diff --git a/.github/workflows/deploy-release.yml b/.github/workflows/deploy-release.yml index 323f5b84..3d8d121d 100644 --- a/.github/workflows/deploy-release.yml +++ b/.github/workflows/deploy-release.yml @@ -53,6 +53,11 @@ jobs: echo "RELEASE_VERSION=${{ github.event.inputs.release_version }}" \ >> "${GITHUB_ENV}" fi + { + echo "SEMVER_VERSION=${RELEASE_VERSION#v}" + echo "SEMVER_MAJOR_VERSION=${SEMVER_VERSION%%.*}" + echo "SEMVER_MAJOR_VERSION_WITH_PREFIX=v${SEMVER_MAJOR_VERSION}" + } >> "${GITHUB_ENV}" - name: Start deployment for the ${{ matrix.images.deployment-environment-identifier }} environment uses: bobheadxi/deployments@v1.3.0 @@ -74,6 +79,16 @@ jobs: ghcr.io/github/super-linter:${{ matrix.images.container-image-id-prefix }}v4 ghcr.io/github/super-linter:${{ matrix.images.container-image-id-prefix }}${{ env.RELEASE_VERSION }} + # We use ^{} to recursively deference the tag to get the commit the tag is pointing at. + # Then, we use that reference to create new tags, so that the new tags point to the commit + # the original tag was pointing to, and not to the original tag. + # This notation is documented at https://git-scm.com/docs/gitrevisions#Documentation/gitrevisions.txt-emltrevgtemegemv0998em + - name: Update the major version and latest tags + run: | + git tag --force "${SEMVER_MAJOR_VERSION_WITH_PREFIX}" "${RELEASE_VERSION}^{}" + git tag --force latest "${RELEASE_VERSION}^{}" + git push --force origin "refs/tags/${SEMVER_MAJOR_VERSION_WITH_PREFIX}" "refs/tags/latest" + - name: Update the deployment status for the ${{ matrix.images.deployment-environment-identifier }} environment uses: bobheadxi/deployments@v1.3.0 if: always() diff --git a/.github/workflows/versioning.yml b/.github/workflows/versioning.yml deleted file mode 100644 index fcb87519..00000000 --- a/.github/workflows/versioning.yml +++ /dev/null @@ -1,50 +0,0 @@ ---- -######################### -######################### -## Version GitHub Tags ## -######################### -######################### - -# -# Documentation: -# https://help.github.com/en/articles/workflow-syntax-for-github-actions -# - -########################## -# Name of the action job # -########################## -name: GitHub Tag Update - -##################################################### -# Run the job when a release is published or edited # -##################################################### -on: - release: - types: [published, edited] - -################# -# Start the job # -################# -permissions: - contents: read - -jobs: - actions-tagger: - permissions: - contents: write # for Actions-R-Us/actions-tagger to create a release and add latest tag - runs-on: windows-latest - timeout-minutes: 60 - steps: - ############################# - # Check out the latest code # - ############################# - - uses: actions/checkout@v3 - - ###################### - # Run the tag action # - ###################### - - uses: Actions-R-Us/actions-tagger@v2.0.2 - with: - publish_latest_tag: true - env: - GITHUB_TOKEN: "${{secrets.GITHUB_TOKEN}}" diff --git a/docs/release-process.md b/docs/release-process.md index 2d9242ab..f7ee87a3 100644 --- a/docs/release-process.md +++ b/docs/release-process.md @@ -23,7 +23,7 @@ When an *Admin* wants to create a Release, the process is as follows: - `github/super-linter:slim-latest` - `github/super-linter:slim-v4` - `github/super-linter:slim-v4.6.3` -- The `versioning.yml` workflow is also triggered to update the `latest` and `vMAJOR` Git tags to point to the same commit that the release Git tag is pointing at. +- This also updates the `latest` and `vMAJOR` Git tags to point to the same commit that the release Git tag is pointing at. - At this point, the Release is complete and images are available for general consumption ## Pitfalls and Issues