Extract package version from package.json and export it
Create a .github/workflows/export-version.yml
file in the repository you want to install this action, then add the following to it:
name: Export Version
on:
push:
branches:
- master
jobs:
run:
runs-on: ubuntu-latest
steps:
- uses: wow-actions/export-version@v1
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
The default config will generate a file "src/version.ts"
with the following content:
/* eslint-disable */
/**
* Auto generated version file, do not modify it!
*/
const version = 'xxx'
export { version }
Various inputs are defined to let you configure the action:
Note: Workflow command and parameter names are not case-sensitive.
Name | Description | Default |
---|---|---|
GITHUB_TOKEN |
The GitHub token for authentication | N/A |
source |
The package.json path or the directory path contains a package.json file |
'package.json' |
target |
The auto generated target file path | 'src/version.ts' |
template |
Template to render the target file content Placeholder {{version}} is supportted |
... |
commitMessage |
Commit message to create/update the target file | 'chore: update version file [skip ci]' |
The scripts and documentation in this project are released under the MIT License