Skip to content

A GitHub action to auto tag merged PRs following SemVer

License

Notifications You must be signed in to change notification settings

RueLaLa/auto-tagger

Use this GitHub action with your project
Add this Action to an existing workflow or create a new one
View on Marketplace

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

67 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

auto-tagger

Introduction

This is a simple github action that is triggered on github PR merging that will increment the git tag on the merge commit following semver and add a comment to the merged commit with the new tag.

Installation

To use this, simply define an action configuration yaml in the .github/workflows directory of your repository with the following contents:

name: auto_tagger
on:
  pull_request:
   types: [closed]
jobs:
  build:
    if: github.event_name == 'pull_request' && github.event.action == 'closed' && github.event.pull_request.merged == true
    runs-on: ubuntu-20.04
    steps:
    - uses: actions/checkout@master
      with:
        fetch-depth: 0
    - name: Bump version and push tag
      uses: RueLaLa/auto-tagger@master
      env:
        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        GITHUB_PR_NUMBER: ${{ github.event.number }}

The default Github token created for the action to use has enough permissions to checkout, tag, and push the new tag on the repo that this action is defined in.

Local Testing

To test the semver component locally, install the python dependencies by running pip install -r requirements.txt where auto-tagger is checked out.

Then, cd to the directory you want to test in and run the below command:

DRYRUN=True GITHUB_SHA=$(git rev-parse HEAD) /path/to/auto-tagger/entrypoint.py

Usage

Once installed, when merging a pull request, simply include either #major, #minor, or #patch to the commit message. Alternatively, if you don't include of these, a patch level bump will be assumed. Below is an example from the pull request page: merge commit message example