Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Workflow to automate maintaining major release tag for GitHub Actions (e.g., from v3.1.2 to v3)

Automated Update of Major Release Tag


GitHub's documentation for developers of GitHub Actions recommend that in addition to specific tagged releases with SemVer release numbers that a major release tag is maintained and moved to point to the most recent specific version. For example, let's say that you just release v3.1.2 (with corresponding tag). The recommendation is to then move a v3 tag to point to that new version. This gives users of the action the option to use specific release version, such as v3.1.2, or to just use the major release number, v3, which enables them to automatically gain the benefit of any bug fixes without updating their workflows.

What This Workflow Does

When you create a release, this workflow runs. It assumes that the release tag is of the form, vX.Y.Z (where X, Y, and Z are the major, minor, and patch numbers of a SemVer version). From this, it extracts the major version forming a string of the form vX. It then adds (if it doesn't exist) or moves (if it does exist) the tag with major version only to the new released version. For example, if the new release has a tag of v3.1.2, it will move the v3 tag to also point to the v3.1.2 release. Or for example, let's say you just released a new major version, with tag v4.0.0, this workflow will add a new tag v4 that also points to v4.0.0.


To use this workflow, drop the workflow file into the .github/workflows directory. And then edit your name and username where indicated.

# Copyright (c) 2021 Vincent A. Cicirello
# MIT License
name: Update Major Release Tag
types: [created]
runs-on: ubuntu-latest
- uses: actions/checkout@v2
- name: Get major version num and update tag
run: |
git config --global 'YOUR NAME HERE'
git config --global ''
git tag -fa ${MAJOR} -m "Update major version tag"
git push origin ${MAJOR} --force
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment