3

This question is very close to this 3 year old question from 2019.

I'm seeking advise/reference to a bot/github action that semver bumps up the package.json version (as a commit) on merge/rebase pending on the labels major, minor or patch that the PR has.

Norfeldt
  • 8,272
  • 23
  • 96
  • 152

1 Answers1

2

You can test out Konsentus/action.bump-version-and-tag:

This action will find the last version tag made on the current branch, bump it and tag the current commit with the new version.

If a package.json file is present, the version contained will also be bumped to the same version as the tag.

As tags are commit specific and not branch specific, these version tags are prefixed with the current branch name, e.g. master/v1.0.0.

Example

name: Bump Version and Tag
on:
  push:
    branches:
      - 'master'
      - 'sit'
      - 'alpha'
      - 'sandbox'
jobs:
  bump-and-tag:
    env:
      GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
    name: Bump and Tag
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v2
        with:
          fetch-depth: 0

      - name: Get Tags
        run: git fetch origin +refs/tags/*:refs/tags/*

      - name: Bump Version
        id: bump_and_tag
        uses: konsentus/action.bump-version-and-tag@v2
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250