/nbgv.sh-action

GitHub action using nbgv.sh to generate a version number for your project.

Primary LanguageDockerfile

GitHub action for nbgv.sh

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.

Example

# .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:

  1. The contents: write permission is required to push tags to a GitHub repository and might not be necessary for your usage.

  2. By default, the checkout@v3 action will check out a single commit, which is not sufficient for nbgv.sh to work correctly. Setting fetch-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.