Skip to content
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

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

⬆️ package.json Version Bump ⬆️

Bumps version in package.json based on labels added to the PR


Usage 💻

Hey! This action requires actions/checkout@v2

- uses: actions/checkout@v2
- uses: copapow/version-bump-package@v1
    id: bump
    with:
        major_label: version-major # optional - default = major
        minor_label: version-minor # optional - default = minor
        patch_label: version-patch # optional - default = patch
        default_branch: main       # optional = default = master
        github_token: ${{ secrets.GITHUB_TOKEN }} # required
- run: |
    echo "Previous version: ${{ steps.bump.outputs.previous_version }}"
    echo "New Version: ${{ steps.bump.outputs.new_version }}"

Inputs 📥

Key Required Description Default
major_label No Custom label to trigger major version bump major
minor_label No Custom label to trigger minor version bump minor
patch_label No Custom label to trigger patch version bump patch
default_branch No Default branch of your project master
github_token Yes Github token - can be ${{secrets.GITHUB_TOKEN}}

Outputs 📤

Key Description
previous_version version in package.json before bump
new_version version in package.json after bump

But Why?

There are many actions like this one, but this one is mine. Similar actions utilize specific terms in commit messages and while that may work for some, I prefer to use labels.

Here's how I use this action in conjunction with EndBug/add-and-commit@v7 to auto commit the new version to package.json. A caveat with using EndBug/add-and-commit is it can't be used if you use GitHub's protected branch features.

name: Bump Package Version On Merge

on:
  pull_request:
    types: [closed]
    branches:
      - main

jobs:
  bump-package-version:
    # Only run if the PR closed by merging
    if: github.event.pull_request.merged == true
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - uses: copapow/version-bump-package@v1
        with:
          github_token: ${{ secrets.GITHUB_TOKEN }}
      - uses: EndBug/add-and-commit@v7
        with:
          branch: main
          message: 'Bump package version'

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

Packages

Used by

Contributors

Languages