Skip to content

cssnr/update-version-tags-action

Use this GitHub action with your project
Add this Action to an existing workflow or create a new one
View on Marketplace

Repository files navigation

GitHub Tag Major GitHub Tag Minor GitHub Release Version GitHub Dist Size Action Run Using Workflow Release Workflow Test Workflow Lint Quality Gate Status GitHub Last Commit Codeberg Last Commit GitHub Contributors GitHub Repo Size GitHub Top Language GitHub Discussions GitHub Forks GitHub Repo Stars GitHub Org Stars Discord Ko-fi

Update Version Tags Action

Update Version Tags on Push or Release for Semantic Versions or Custom Tags.

Zero configuration to maintain both major vN -> vN.x.x and minor vN.N -> vN.N.x tags.

This is useful if you want to automatically update additional tags, to point to your pushed/released tag. For example, many GitHub Actions maintain a vN and vN.N tag that points to the latest release of the vN.x.x branch.

- name: 'Update Tags'
  uses: cssnr/update-version-tags-action@v2

GitHub Actions can copy and paste this workflow: release.yaml

Make sure to review the Inputs and checkout more Examples.

Note

Please submit a Feature Request for new features or Open an Issue if you find any bugs.

Inputs

Input Default Value Description of Input Value
prefix v Tag Prefix for Semantic Versions
major true Update Major Tag vN
minor true Update Minor Tag vN.N
release false Update Release Tag vN.N.N
tags - Additional Tags to Update
tag github.ref_name Manually Set Target Tag
create false Create Target tag
summary true Add Summary to Job
dry_run false Will not Create/Update Tags, Output Only
token github.token For use with a PAT to Rollback

prefix

The prefix is applied to the generated version tags. If you release 1.0.0 or v1.0.0, the parsed major/minor is 1 and 1.0 and then with the prefix added becomes v1 and v1.0.

To disable the prefix, set it to an empty string prefix: ''

The prefix is not applied to the specified input tags.

Default: v

major/minor

Both major and minor versions are parsed from the release tag using semver. If you release version 1.0.0 this will update or create a reference for v1 and v1.0. If you are not using semantic versions, set both to false and provide your own tags.

Default: true

release

If true and you provide a non-release tag 1.2.3-release.1 this would create the release tag 1.2.3.

Default: false

tags

These are extra tags to set. For example, you could maintain a latest tag that always points to the latest release.

These can be a string list "v1,v1.0" or newline delimited.

👀 View Example tags

Extra Tag.

with:
  tags: latest

CSV with major/minor disabled.

with:
  tags: v1,v1.0,latest
  major: false
  minor: false

Newline with major/minor disabled.

with:
  tags: |
    v1
    v1.0
    latest
  major: false
  minor: false

To only set these tags set both major and minor to false.

Note the prefix is not applied to these tags...

tag

This is the target tag to parse the sha from. Defaults to the sha that triggered the workflow. To override this behavior you can specify a target tag here from which the target sha will be parsed. This is the sha that all parsed or provided tags are updated too. To create this tag at the current sha set create to true.

Rolling back requires a PAT. See Rolling Back for more details and a manual workflow example.

Default: ${{ github.ref_name }}

create

If true this will create the tag at the current sha of the workflow run.

Default: false

summary

Write a Summary for the job. To disable this set to false.

👀 View Example Job Summary
Tagv1.0.1
Sha9b5d1797561610366c63dcd48b0764f4cdd91761
Tagsv1,v1.0
Tags
v1
v1.0
Results
TagResult
v1Updated
v1.0Updated
SemVer
{
  "options": {},
  "loose": false,
  "includePrerelease": false,
  "raw": "v1.0.1",
  "major": 1,
  "minor": 0,
  "patch": 1,
  "prerelease": [],
  "build": [],
  "version": "1.0.1"
}
Inputs
prefix: v
major: true
minor: true
tags: ""
tag: ""
summary: true
dry_run: false

Default: true

dry_run

If this is true no tags will be created/updated and will only output the results.

Default: false

token

GitHub workflow tokens do not allow for rolling back or deleting tags. To do this you must create a PAT with the repo and workflow permissions, add it to secrets, and use it. See Rolling Back for more information and an example.

For semantic versions, simply add this step to your release workflow:

- name: 'Update Tags'
  uses: cssnr/update-version-tags-action@v2

Default: ${{ github.token }}

Permissions

This action requires the following permissions:

permissions:
  contents: write

Permissions documentation for Workflows and Actions.

Outputs

Output Output Description
tags Comma Seperated String of Parsed Tags
semver Parsed Semantic Version JSON

Example output.

v1,v1.0

Using the outputs.

- name: 'Update Tags'
  uses: cssnr/update-version-tags-action@v2
  id: tags

- name: 'Echo Tags'
  run: echo ${{ steps.tags.outputs.tags }}
👀 View Example semver
{
  "options": {},
  "loose": false,
  "includePrerelease": false,
  "raw": "v1.0.1",
  "major": 1,
  "minor": 0,
  "patch": 1,
  "prerelease": [],
  "build": [],
  "version": "1.0.1"
}

Let us know if you need more output formats...

Examples

This is the workflow used by this Action to update tags on release: release.yaml

name: 'Release'

on:
  release:
    types: [published]

jobs:
  release:
    name: 'Release'
    runs-on: ubuntu-latest
    timeout-minutes: 5
    permissions:
      contents: write

    steps:
      - name: 'Update Tags'
        uses: cssnr/update-version-tags-action@v2

Specifying the tags to update or create:

- name: 'Update Tags'
  uses: cssnr/update-version-tags-action@v2
  with:
    major: false
    minor: false
    tags: |
      v1
      v1.0

Specifying the target tag to update too:

- name: 'Update Tags'
  uses: cssnr/update-version-tags-action@v2
  with:
    tag: v1.0.1

For more examples, you can check out other projects using this action:
https://github.com/cssnr/update-version-tags-action/network/dependents

Rolling Back

To roll back or manually update tags, copy this workflow: tags.yaml

To rollback tags you must use a PAT with the repo and workflow permissions. The target sha will be parsed from the target tag provided in the UI.

For example, if you releases v1.0.1 but wanted to roll back to v1.0.0. You would run the workflow with tag v1.0.0 it would update the v1 and v1.0 tags (or what ever tags you manually specify) to point back to the sha of tag v1.0.0.

This same workflow could be used to manually roll forward without a PAT.

name: 'Tags'

on:
  workflow_dispatch:
    inputs:
      tag:
        description: 'Target Tag'
        required: true

jobs:
  tags:
    name: 'Tags'
    runs-on: ubuntu-latest
    timeout-minutes: 5
    permissions:
      contents: write

    steps:
      - name: 'Update Tags'
        uses: cssnr/update-version-tags-action@v2
        with:
          tag: ${{ inputs.tag }}
          token: ${{ secrets.GH_PAT }}

Tags

The following rolling tags are maintained.

Version Tag Rolling Bugs Feat. Name Target Example
GitHub Tag Major Major vN.x.x vN
GitHub Tag Minor Minor vN.N.x vN.N
GitHub Release Micro vN.N.N vN.N.N
latest Latest vX.X.X latest

You can view the release notes for each version on the releases page.

The Major tag is recommended. It is the most up-to-date and always backwards compatible. Breaking changes would result in a Major version bump. At a minimum you should use a Minor tag.

The latest tag always points to the latest release regardless of the version number.

Badges

You can use shields.io to generate dynamic badges that always point to the latest tags for semantic versions.

Tag badges can be created here: https://shields.io/badges/git-hub-tag

Set sort to semver and filter to one of the following.

Version Filter Example Labels Icons Only For The Badge Social Icons
Major !v*.* GitHub Tag Major GitHub Tag Major GitHub Tag Major GitHub Tag Major
Minor !v*.*.* GitHub Tag Minor GitHub Tag Minor GitHub Tag Minor GitHub Tag Minor
Micro GitHub Tag Micro GitHub Tag Micro GitHub Tag Micro GitHub Tag Micro

You may need to adjust the filter to match your tagging scheme.

To create a 2 color badge with icon and no text; set a labelColor with an empty label.

GitHub's media proxy caches images for 1 hour. You can purge the cache by sending a PURGE request.

curl -X PURGE 'https://camo.githubusercontent.com/xxx'

Support

For general help or to request a feature, see:

If you are experiencing an issue/bug or getting unexpected results, you can:

For more information, see the CSSNR SUPPORT.md.

Contributing

If you would like to submit a PR, please review the CONTRIBUTING.md.

Please consider making a donation to support the development of this project and additional open source projects.

Ko-fi

Additionally, you can support other GitHub Actions I have published:

❔ Unpublished Actions

These actions are not published on the Marketplace, but may be useful.


📝 Template Actions

These are basic action templates that I use for creating new actions.

Note: The docker-test-action builds, runs and pushes images to GitHub Container Registry.


For a full list of current projects visit: https://cssnr.github.io/

About

Update Version Tags Automatically

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Sponsor this project