Skip to content

An action to compute the next tag for git

License

Notifications You must be signed in to change notification settings

alexpls/compute-tag

This branch is 10 commits behind zendesk/compute-tag:master.

Folders and files

NameName
Last commit message
Last commit date
Jan 17, 2023
Dec 20, 2022
Mar 27, 2020
Mar 27, 2020
Jan 17, 2023
Jan 23, 2023
Dec 20, 2022
Dec 20, 2022
Dec 20, 2022

Repository files navigation

compute-tag

Latest Release Example Runs

A Github action to compute the next version tag.

This can be helpful to automatically compute tags and pipe them to the create-release action.

Inputs

Parameter Description Required Default
github_token A Github token, usually ${{ github.token }}. Y N/A
tag The tag to compute the next version of. If not specified, the most recent tag in the repo. N Latest
branch The branch to find compute the tag for. This requires iteration of all tags for the repo and the commits for the branch to find a tag for a commit on the branch. For large repositories this can be very slow. It is highly recommended that github_token be supplied to prevent rate limit errors when searching. N N/A
version_scheme One of (continuous, semantic). N semantic
version_type One of (major, minor, patch, premajor, preminor, prepatch, prerelease). N prerelease
prerelease_suffix The suffix added to a prerelease tag, if none already exists. N beta

Output

  • next_tag The computed next tag.
  • previous_tag The tag used to compute next_tag.

Usage

steps:
  - id: compute_tag
    uses: craig-day/compute-tag@v15
    with:
      github_token: ${{ github.token }}

Examples

For an exhuastive list of every version_scheme+version_type combination, see the results from the Example Runs workflow

Tag each push to master as a semantic prerelease

name: Release

on:
  push:
    branches:
      - master

jobs:
  release:
    runs-on: ubuntu-latest
    steps:
      - id: compute_tag
        uses: craig-day/compute-tag@v15
        with:
          github_token: ${{ github.token }}

Sample Logs:

Computing the next tag based on: v5.0.0-pre.4
Computed the next tag as: v5.0.0-pre.5

Tag each push to master as a semantic patch

name: Release

on:
  push:
    branches:
      - master

jobs:
  release:
    runs-on: ubuntu-latest
    steps:
      - id: compute_tag
        uses: craig-day/compute-tag@v15
        with:
          github_token: ${{ github.token }}
          version_type: patch

Sample Logs:

Computing the next tag based on: v5.0.3
Computed the next tag as: v5.0.4

Tag each push to master as a continuous prerelease

name: Release

on:
  push:
    branches:
      - master

jobs:
  release:
    runs-on: ubuntu-latest
    steps:
      - id: compute_tag
        uses: craig-day/compute-tag@v15
        with:
          github_token: ${{ github.token }}
          version_scheme: continuous
          version_type: prerelease

Sample Logs:

Computing the next tag based on: v5-pre.4
Computed the next tag as: v5-pre.5

Switching from continuous to semantic

name: Release

on:
  push:
    branches:
      - master

jobs:
  release:
    runs-on: ubuntu-latest
    steps:
      - id: compute_tag
        uses: craig-day/compute-tag@v15
        with:
          github_token: ${{ github.token }}
          version_scheme: semantic

Sample Logs:

Computing the next tag based on: v5-pre.4
Computed the next tag as: v5.0.0-pre.5

Create a GitHub Release for each push to master

NOTE: Since actions/create-release is deprecated, this example uses softprops/action-gh-release which maintains a similar API and feature set.

name: Release

on:
  push:
    branches:
      - master

jobs:
  release:
    runs-on: ubuntu-latest
    steps:
      - id: compute_tag
        uses: craig-day/compute-tag@v15
        with:
          github_token: ${{ github.token }}
          version_scheme: semantic

      - name: create release
        uses: softprops/action-gh-release@v1
        with:
          name: ${{ steps.compute_tag.outputs.next_tag }}
          tag_name: ${{ steps.compute_tag.outputs.next_tag }}
          generate_release_notes: true
          prerelease: true
        env:
          GITHUB_TOKEN: ${{ github.token }}

About

An action to compute the next tag for git

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%