Skip to content

A Github Action to tag a repo on merge with specified message

License

Notifications You must be signed in to change notification settings

PrateekKhatri/github-tag-action-1

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Git Tag Generator

A GitHub Action to automatically push new tag to master, on push or merge with the latest SemVer formatted version if the commit message contains specified keywords.

Note: This action creates a lightweight tag.

Build Status Stable Version Latest Release GitHub Marketplace

Usage

name: Generate tag

on:
  push:
    branches:
      - master

jobs:
  build:
    name: Generate tag
    runs-on: ubuntu-latest
    steps:
      - name: Check out code
        uses: actions/checkout@master
        with:
          fetch-depth: '0'

      - name: Bump version and push tag
        uses: ChloePlanet/github-tag-action@master
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          WITH_V: true

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

Use GitHub Personal Access Token ${{ secrets.REPO_ACCESS_TOKEN }} in GITHUB_TOKEN if you want to trigger another workflow by this workflow.

name: Another workflow on tag generated

on:
  push:
    tags:
      - 'v*.*.*'

jobs:
  myJob:
    name: On tag generated
    runs-on: ubuntu-latest
    steps:
      # Whatever you want to do on tag generated

An action in a workflow run can't trigger a new workflow run. When you use GITHUB_TOKEN in your actions, all of the interactions with the repository are on behalf of the Github-actions bot. The operations act by Github-actions bot cannot trigger a new workflow run. More details: https://help.github.com/en/actions/reference/events-that-trigger-workflows#about-workflow-events

Workflow

  • Add this action to your repo
  • Commit some changes with message contains #major or #patch or #patch
  • Either push to master or open a PR
  • On push (or merge) to master, the action will:
    • Get latest tag
    • Generate tag if commit message contains #major or #patch or #patch

      Note: This action will not push the tag if the HEAD commit has already been tagged. If two or more keywords are present, the highest-ranking one will take precedence.

    • Pushes tag to GitHub

Environment Variables

  • GITHUB_TOKEN (required) - Required for permission to tag the repo.
  • 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.

Outputs

  • last_tag - The value of the latest tag before running this action.
  • new_tag - The value of the newly created tag.
  • tag_generated - 1 if new tag is generated successfully. 0 if no tag is generated
  • last_major - The major part of last tag
  • last_minor - The minor part of last tag
  • last_patch - The patch part of last tag
  • major - The major part of new tag
  • minor - The minor part of new tag
  • patch - The patch part of new tag
  • bump_ver - The bump version string e.g. major, minor or patch

Credits

anothrNick/github-tag-action fsaintjacques/semver-tool

Projects using Git Tag Generator

A list of projects using Git Tag Generator for reference.

License

MIT License

About

A Github Action to tag a repo on merge with specified message

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Languages

  • Shell 95.8%
  • Dockerfile 4.2%