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.
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 , prerelease , premajor ). |
N | prerelease |
prerelease_suffix |
The suffix added to a prerelease tag, if none already exists. | N | beta |
next_tag
The computed next tag.previous_tag
The tag used to computenext_tag
.
steps:
- id: compute_tag
uses: craig-day/compute-tag@v10
with:
github_token: ${{ github.token }}
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@v10
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@v10
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@v10
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@v10
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
name: Release
on:
push:
branches:
- master
jobs:
release:
runs-on: ubuntu-latest
steps:
- id: compute_tag
uses: craig-day/compute-tag@v10
with:
github_token: ${{ github.token }}
version_scheme: semantic
- name: create release
uses: actions/create-release@v1
with:
tag_name: ${{ steps.compute_tag.outputs.next_tag }}
release_name: ${{ steps.compute_tag.outputs.next_tag }}
body: >
Automatic release of ${{ steps.compute_tag.outputs.next_tag }}
env:
GITHUB_TOKEN: ${{ github.token }}