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 Release Test Lint Quality Gate Status GitHub Last Commit Codeberg Last Commit GitHub Top Language GitHub Org Stars Discord

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.

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

Note

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

For more details see action.yml and src/index.js.

Inputs

Input Required Default Description
prefix - v Tag Prefix for Semantic Versions
major - true Update Major Tag *
minor - true Update Minor Tag *
tags - - Additional Tags to Update *
tag - github.ref_name Manually Set Target Tag **
summary - true Add Summary to Job *
dry_run - false Do not create tags, outout only
token - github.token For use with a PAT to rollback *

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.

tags - The prefix is not applied to specified tags. These can be a string list "v1,v1.0" or newline delimited |. If you only want to update the specified tags make sure to set both major and minor to false.

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. Rolling back requires a PAT. See Rolling Back for more details and a manual workflow example.

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

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@v1

Permissions

This action requires the following permissions:

permissions:
  contents: write

Permissions documentation for Workflows and Actions.

Outputs

Output Description
tags Comma Seperated String of Parsed Tags

Example output:

v1,v1.0

Using the outputs:

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

- name: 'Echo Tags'
  run: echo ${{ steps.tags.outputs.tags }}

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@v1

Specifying the tags to update or create:

- name: 'Update Tags'
  uses: cssnr/update-version-tags-action@v1
  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@v1
  with:
    tag: v1.0.1

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@v1
        with:
          tag: ${{ inputs.tag }}
          token: ${{ secrets.GH_PAT }}

Tags

The following rolling tags are maintained.

Tag Example Target Bugs Feat. Description
GitHub Tag Major vN vN.x.x βœ… βœ… Includes new features but is always backwards compatible.
GitHub Tag Minor vN.N vN.N.x βœ… ❌ Only receives bug fixes. This is the most stable tag.
GitHub Release vN.N.N vN.N.N ❌ ❌ Not a rolling tag. Not recommended.

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

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 Example Example Example
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

Currently, the best way to contribute to this project is to star this project on GitHub.

For more information, see the CSSNR CONTRIBUTING.md.

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

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