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
-
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
-
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.
- name: npm versioning
id: npmVersioning
uses: pengyanb/npm-versioning-action@v1
- name: dummy versioning usage
run: echo "Generated version is \${{ steps.npmVersioning.outputs.version}}"
- 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}}"
- 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}}"
- 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 }}