Skip to content

Action that increments a project to the next version at pull request time.

License

Notifications You must be signed in to change notification settings

Piszmog/next-version

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

Repository files navigation

Next Version

CI

Increment the semantic version of the project to the next version. Used to increment the version at Pull Request time.

Supported Files

Currently, supports the following files,

  • package.json
  • pom.xml
  • build.gradle

How does it work?

The Action is driven based on the labels on the Pull Request. The following labels are supported:

Type Label
Major Increment version:major
Minor Increment version:minor
Patch Increment version:patch or No label

Example

Label Current Version New Version
version:major 1.2.3 2.0.0
version:minor 1.2.3 1.3.0
version:patch 1.2.3 1.2.4
No Label 1.2.3 1.2.4

Inputs

Name Required Description
token True GitHub Token used to query files in the repository and commit changes to the branch
files True Comma separated list of files containing the version to increment

Example Usage

It is recommended to have the action in its own workflow file in order to trigger correctly.

name: Versioning
on:
  pull_request:
    types:
      - opened
      - labeled
      - synchronize
    branches:
      - main
jobs:
  version:
    name: Version
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - name: Next Version
        uses: Piszmog/next-version@v1
        with:
          token: ${{ secrets.PAT }}
          files: package.json

Limitations

New Workflow Runs are not triggered

Incrementing the version does not trigger a new workflow run. This is due to limitations set by GitHub .

When you use the repository's GITHUB_TOKEN to perform tasks on behalf of the GitHub Actions app, events triggered by the GITHUB_TOKEN will not create a new workflow run. This prevents you from accidentally creating recursive workflow runs.

You can change this by creating a new Personal Access Token (PAT), with the scope public_repo, storing the token as a secret in your repository and then passing the new token to the action.

- uses: Piszmog/next-version@v1
  with:
    token: ${{ secrets.YOUR_PAT }}

If you work in an organization and don't want to create a PAT from your personal account, we recommend using a robot account for the token.