Skip to content

Latest commit

 

History

History
71 lines (46 loc) · 2.41 KB

README.md

File metadata and controls

71 lines (46 loc) · 2.41 KB

NPM Package Version Bump Action

main test

This is a GitHub Action that bumps version of a NPM Package.

The version is formatted according to the pattern described in the RFC-18:

<base-version>-<environment>.<build-number>+<branch>.<commit>

Inputs

The action supports following input parameters:

  • work-dir (optional, default: .) - location of package.json file,

  • is-prerelease (optional, default: true) - defines if the version is a prerelease, currently only true is supported,

  • environment (optional, default: pre) - prerelease id.

  • branch (optional) - branch reference at which version is built

  • commit (optional) - commit hash at which version is built

Branch conversion

It's expected that branch parameter will be populated with GitHub context ref property:

The branch or tag ref that triggered the workflow run. For branches this in the format refs/heads/<branch_name>, and for tags it is refs/tags/<tag_name>.

To handle this value correctly in the resulting version format the provided value is converted in the following way:

  • refs/heads/ and refs/tag/ prefixes are stripped out,

  • any / occurrence is replaced by -,

  • any . occurrence is replaced with -.

Usage

- uses: keep-network/npm-version-bump@v2
  with:
    work-dir: ./contracts       # optional, default: .
    environment: "ropsten"      # optional, default: pre
    branch: ${{ github.ref }}   # optional
    commit: ${{ github.sha }}   # optional

Outputs

The action outputs version property with a value of the resolved package version.

Example usage:

- uses: keep-network/npm-version-bump@v2
  id: bump-version
- name: Print resolved version
  run: echo "Resolved new version ${{ steps.bump-version.outputs.version }}"