Skip to content

playtini/github-tag-action

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

187 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

github-tag-action

A Github Action to automatically bump and tag master, on merge, with the latest SemVer formatted version.

Build Status Stable Version Latest Release

Medium Post: Creating A Github Action to Tag Commits

Usage

name: Bump version
on:
  push:
    branches:
      - master
jobs:
  build:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v2
      with:
        fetch-depth: '0'
    - name: Bump version and push tag
      uses: anothrNick/github-tag-action@1.26.0
      env:
        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        WITH_V: true

NOTE: set the fetch-depth for actions/checkout@v2 to be sure you retrieve all commits to look for the semver commit message.

Options

Environment Variables

  • GITHUB_TOKEN (required) - Required for permission to tag the repo.
  • DEFAULT_BUMP (optional) - Which type of bump to use when none explicitly provided (default: minor).
  • WITH_V (optional) - Tag version with v character.
  • RELEASE_BRANCHES (optional) - Comma separated list of branches (bash reg exp accepted) that will generate the release tags. Other branches and pull-requests generate versions postfixed with the commit hash and do not generate any tag. Examples: master or .* or release.*,hotfix.*,master ...
  • CUSTOM_TAG (optional) - Set a custom tag, useful when generating tag based on f.ex FROM image in a docker image. Setting this tag will invalidate any other settings set!
  • SOURCE (optional) - Operate on a relative path under $GITHUB_WORKSPACE.
  • DRY_RUN (optional) - Determine the next version without tagging the branch. The workflow can use the outputs new_tag and tag in subsequent steps. Possible values are true and false (default).
  • INITIAL_VERSION (optional) - Set initial version before bump. Default 0.0.0.
  • TAG_CONTEXT (optional) - Set the context of the previous tag. Possible values are repo (default) or branch.
  • SUFFIX (optional) - Suffix appended to every generated tag (this fork always appends it), master by default. E.g. 1.2.3-master.
  • VERBOSE (optional) - Print git logs. For some projects these logs may be very large. Possible values are true (default) and false.
  • GIT_API_TAGGING (optional) - How to push the tag. true (default) posts the tag via the GitHub refs API; false uses git push. Possible values are true and false.
  • TAG_MESSAGE (optional) - When set, creates an annotated tag (git tag -a -m) instead of a lightweight one. Note: the annotation is only preserved when GIT_API_TAGGING is false; the refs API path pushes a lightweight tag.
  • MAJOR_STRING_TOKEN (optional) - Commit-message token that triggers a major bump. Default #major.
  • MINOR_STRING_TOKEN (optional) - Commit-message token that triggers a minor bump. Default #minor.
  • PATCH_STRING_TOKEN (optional) - Commit-message token that triggers a patch bump. Default #patch.
  • NONE_STRING_TOKEN (optional) - Commit-message token that skips bumping. Default #none.
  • BRANCH_HISTORY (optional) - Which commit messages are scanned for bump tokens: compare (default, all commits since the last tag), last (only the latest commit), or full (all commits since DEFAULT_BRANCH).
  • DEFAULT_BRANCH (optional) - Branch to diff against when BRANCH_HISTORY=full. Falls back to $GITHUB_BASE_REF, then autodetection of master/main.

Outputs

  • new_tag - The value of the newly created tag.
  • tag - The value of the latest tag after running this action.
  • part - The part of version which was bumped.
  • old_tag - The previous tag before the bump.

Note: This action creates a lightweight tag.

Bumping

Manual Bumping: Any commit message that includes #major, #minor, #patch, or #none will trigger the respective version bump. If two or more are present, the highest-ranking one will take precedence. If #none is contained in the commit message, it will skip bumping regardless DEFAULT_BUMP.

Automatic Bumping: If no #major, #minor or #patch tag is contained in the commit messages, it will bump whichever DEFAULT_BUMP is set to (which is minor by default). Disable this by setting DEFAULT_BUMP to none.

Note: This action will not bump the tag if the HEAD commit has already been tagged.

Workflow

  • Add this action to your repo
  • Commit some changes
  • Either push to master or open a PR
  • On push (or merge), the action will:
    • Get latest tag
    • Bump tag with minor version unless any commit message contains #major or #patch
    • Pushes tag to github
    • If triggered on your repo's default branch (master or main if unchanged), the bump version will be a release tag.
    • If triggered on any other branch, a prerelease will be generated, depending on the bump, starting with *-<PRERELEASE_SUFFIX>.1, *-<PRERELEASE_SUFFIX>.2, ...

Credits

fsaintjacques/semver-tool

Projects using github-tag-action

A list of projects using github-tag-action for reference.

  • another/github-tag-action (uses itself to create tags)

  • anothrNick/json-tree-service

    Access JSON structure with HTTP path parameters as keys/indices to the JSON.

About

A Github Action to tag a repo on merge.

Resources

License

Stars

0 stars

Watchers

0 watching

Forks

Packages

 
 
 

Contributors

Languages

  • Shell 96.3%
  • Dockerfile 3.7%