Skip to content

Github action to upgrade the package.json version and create a changelog based on PR description that can be triggered in your workflows

License

Notifications You must be signed in to change notification settings

Drassil/action-package-version-bump

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

action-package-version-bump

Github action to upgrade the package.json version and create a changelog based on PR description that can be triggered in your workflows

How to use

This action is intended to work only when executed within a PR. Hence you need to use the following workflow trigger:

on:
  pull_request:

The full specification of what you can do with this event is available here: https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#pull_request

Once you have defined what kind of event should trigger it, just add this action to your workflow, it will update your package.json based on your strategy but always based on your reference branch (main by default), it also updates the CHANGELOG.md by concatenating the description of the PR with the existing content of the CHANGELOG.md.

There are several required options for this action that are listed here:

repository:
description: 'The repository where to pull the changes'
required: true
user_name:
description: 'Name of the git user to push the changes'
required: true
user_email:
description: 'Email of the git user to push the changes'
required: true
ref_branch:
description: 'Branch to use as a base reference for the version bump'
required: false
default: 'master'
use_rebase:
description: 'Use rebase strategy for pull'
required: false
default: false
version_args:
description: 'npm version command arguments. '
required: false
default: 'patch'
node_version:
description: 'node version used for the npm commands'
required: false
default: '16'

An example of how to use it is available here:

name: Version bump (test)
on:
pull_request:
types:
- labeled
env:
NODE_VERSION: 16
RC_VERSION: 1
jobs:
version-bump:
if: github.event.label.name == 'pr-version-bump'
runs-on: [ubuntu-latest]
steps:
- uses: actions/checkout@v2
with:
ref: ${{ github.event.pull_request.head.ref }}
- name: Test bump action
with:
repository: https://github.com/Drassil/action-package-version-bump
user_name: 'drassil-git-bot'
user_email: '[email protected]'
ref_branch: 'main'
use_rebase: true
version_args: 'prerelease --preid=rc${{ env.RC_VERSION }}'
node_version: ${{ env.NODE_VERSION }}
uses: ./

Demo

This is a video of how this action works:

2022-02-21.12-55-52.mp4

About

Github action to upgrade the package.json version and create a changelog based on PR description that can be triggered in your workflows

Resources

License

Stars

Watchers

Forks

Packages

No packages published