Use Git to update major version and latest tags (#3376)

This commit is contained in:
Marco Ferrari 2022-09-30 19:55:04 +02:00 committed by GitHub
parent 590315aa7f
commit ccf58d2678
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 16 additions and 51 deletions

View file

@ -53,6 +53,11 @@ jobs:
echo "RELEASE_VERSION=${{ github.event.inputs.release_version }}" \ echo "RELEASE_VERSION=${{ github.event.inputs.release_version }}" \
>> "${GITHUB_ENV}" >> "${GITHUB_ENV}"
fi 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 - name: Start deployment for the ${{ matrix.images.deployment-environment-identifier }} environment
uses: bobheadxi/deployments@v1.3.0 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 }}v4
ghcr.io/github/super-linter:${{ matrix.images.container-image-id-prefix }}${{ env.RELEASE_VERSION }} 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 - name: Update the deployment status for the ${{ matrix.images.deployment-environment-identifier }} environment
uses: bobheadxi/deployments@v1.3.0 uses: bobheadxi/deployments@v1.3.0
if: always() if: always()

View file

@ -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}}"

View file

@ -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-latest`
- `github/super-linter:slim-v4` - `github/super-linter:slim-v4`
- `github/super-linter:slim-v4.6.3` - `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 - At this point, the Release is complete and images are available for general consumption
## Pitfalls and Issues ## Pitfalls and Issues