Nbgv.sh is a tool that provides semver-compatible versioning for any project in a git repository. This GitHub action provides simplified access to nbgv.sh.
# .github/workflows/tag.yml
name: tag
on:
push:
branches: [main]
jobs:
tag:
permissions:
contents: write # Note 1
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: '0' # Note 2
- run: |
git config user.name "GitHub Actions"
git config user.email "actions@github.com"
- uses: Stefansm/nbgv.sh-action@main
id: version
- run: |
git tag v${{ steps.version.outputs.version }}
- run: |
git push --tags
There are a few things to note here:
-
The
contents: write
permission is required to push tags to a GitHub repository and might not be necessary for your usage. -
By default, the
checkout@v3
action will check out a single commit, which is not sufficient fornbgv.sh
to work correctly. Settingfetch-depth: '0'
means the action will download the full history.
The action provides a single output: version
, which contains the version
generated by nbgv.sh
.