Giter VIP home page Giter VIP logo

keyword-version-bump's Introduction

Keyword Version Bump

This action bumps and commits a node project's version using the Semantic Versioning system. The type of bump is determined by searching a target string with a list of keywords. The npm package semver is used for incrementing and validating the version.

Usage

- uses: 'dtgreene/keyword-version-bump@main'
  with:
    # The target word used for searching for keywords.
    search-target: ''
    # Case-sensitive, comma-separated list of words that trigger a major version bump.
    # Default: ''
    keywords-major: ''
    # Case-sensitive, comma-separated list of words that trigger a minor version bump.
    # Default: ''
    keywords-minor: ''
    # Case-sensitive, comma-separated list of words that trigger a patch version bump.
    # Default: ''
    keywords-patch: ''
    # The default bump type used when no bump type can be determined by searching.
    # If left blank, and no bump type can be determined, the action will exit without bumping.
    # Default: ''
    default-bump-type: ''
    # The commit message to use when bumping the version. {version} will be replaced with the new version.
    # https://github.blog/changelog/2021-02-08-github-actions-skip-pull-request-and-push-workflows-with-skip-ci/
    # Default: '[skip ci]: Automated version bump {version}'
    commit-message: ''
    # Path to an external json configuration file
    # Default: ''
    configuration: ''

The keywords for major, minor, and patch bump types can be configured via the workflow. Additional bump types can be configured when using an external configuration file.

The available bump types are:

  • major
  • premajor
  • minor
  • preminor
  • patch
  • prepatch
  • prerelease

Output

# The package version after being bumped
- bumped_version: ''

Workflow example

This action relies on actions/checkout for checking out the repo and setting up the environment.

The following is an example of a workflow that bumps a project's version after a pull request is merged into main. It searches for keywords in the pull request's title to determine the bump type.

In this example, changes will be made directly to the main branch. In most repos that would fail due to branch protection rules. If no branch protection rules are in place, the default secrets.GITHUB_TOKEN should have enough permissions.

Otherwise, a PAT (personal access token) that belongs to a user with the right permissions should be provided in the @actions/checkout step.

See actions/checkout for more info about the permission options.

example-bump-workflow.yml

name: Bump Version

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

jobs:
  bump:
    name: Bump
    runs-on: ubuntu-latest
    if: ${{ github.event.pull_request.merged }}
    env: 
      GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
    steps:
      - name: Checkout Repo
        uses: 'actions/checkout@v3'
        with:
          persist-credentials: true
          ref: ${{ github.ref }}
          token: ${{ secrets.BUMP_TOKEN }}
  
      - name: Set Author
        run: |
          git config --local user.name 'Bump and Tag'
          git config --local user.email '[email protected]'  
        
      - name: Bump Version
        id: bump_version
        uses: 'dtgreene/keyword-version-bump@main'
        with:
          search-target: ${{ github.event.pull_request.title }}
          configuration: '.github/workflows/bump-version.config.json'

External configuration file

All configuration options aside from the search-target can be configured through an external json file. Configuration options in the external file override any options provided through the workflow.

example-bump-workflow.yml

- name: Bump Version
  uses: 'dtgreene/keyword-version-bump@main'
  with:
    search-target: ${{ github.event.pull_request.title }}
    configuration: '.github/workflows/version-bump.config.json'

version-bump.config.json

{
  "bump_types": [
    {
      "type": "major",
      "keywords": [],
    },
    {
      "type": "minor",
      "keywords": ["feat"],
    },
    {
      "type": "patch",
      "keywords": ["patch", "fix", "bug"],
    }
  ],
  "default_bump_type": "patch",
  "commit_message": "[skip ci]: Automated version bump {version}"
}

keyword-version-bump's People

Contributors

dtgreene avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.