Skip to content

github action that generates versioning string basing on the npm version value, branch name and commit number

Notifications You must be signed in to change notification settings

pengyanb/npm-versioning-action

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

36 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

npm versioning action

Github action package that generates versioning string base on the npm version value, branch name and commit number.

WARNING: when use with actions/checkout@v2, remember to fetch all history by passing the fetch-depth option

- uses: actions/checkout@v2
  with:
    fetch-depth: 0

Inputs:

  • release-branch : string, default value master.

  • package-json-path : string, path to package.json file, default value ./package.json

  • update-version : boolean, flag to indicate wheather to update package.json file, default value true

outputs:

  • version, the version string generated

  • tag: latest for release branch, beta for other branches

For release branch (default master), version string is generated based on the semantic version specified in package.json file.

For other branches, version string is generated using ${package.json semantic version}-${branchName}.${commitCount} format.

Basic usage:

- name: npm versioning
  id: npmVersioning
  uses: pengyanb/npm-versioning-action@v1

- name: dummy versioning usage
  run: echo "Generated version is \${{ steps.npmVersioning.outputs.version}}"

Specify a different release branch:

- name: npm versioning
  id: npmVersioning
  uses: pengyanb/npm-versioning-action@v1
  with:
    release-branch: "develop"

- name: dummy versioning usage
  run: echo "Generated version is \${{ steps.npmVersioning.outputs.version}}"

Set multiple release branches:

- name: npm versioning
  id: npmVersioning
  uses: pengyanb/npm-versioning-action@v1
  with:
    release-branch: "develop,master"

- name: dummy versioning usage
  run: echo "Generated version is \${{ steps.npmVersioning.outputs.version}}"

use with npm publish:

- name: npm versioning
  id: npmVersioning
  uses: pengyanb/npm-versioning-action@v1
  with:
    release-branch: "master" 
    package-json-path: "./dist/package.json"
    update-version: true

- name: npm publish
  run: run: npm publish ./dist --tag ${{ steps.npmVersioning.outputs.tag }} --dry-run true
  env:
    NPM_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}

About

github action that generates versioning string basing on the npm version value, branch name and commit number

Resources

Stars

Watchers

Forks

Packages

No packages published