Release #4
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Release | |
on: | |
release: | |
types: | |
- published | |
push: | |
branches: | |
- test-release | |
jobs: | |
release: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Setup node | |
uses: actions/setup-node@v4 | |
with: | |
node-version: ${{ vars.NODE_VERSION }} | |
registry-url: https://registry.npmjs.org/ | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Start terminal session (pre build) | |
if: vars.TERMINAL_PRE_BUILD == 'true' | |
uses: mxschmitt/action-tmate@v3 | |
- name: Build | |
shell: bash | |
run: | | |
npm install | |
# Project must have build-dist script. | |
npm run build-dist | |
- name: Start terminal session (post build) | |
if: vars.TERMINAL_POST_BUILD == 'true' | |
uses: mxschmitt/action-tmate@v3 | |
- name: Test | |
shell: bash | |
run: | | |
# Run test script if present. | |
npm run test --if-present | |
- name: Publish | |
shell: bash | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NODE_AUTH_TOKEN }} | |
run: | | |
# Get the tag on the version property if any. | |
tag=`grep "^ \"version\": " package.json | cut -d "\"" -f4 -s | cut -d "-" -f2 -s` | |
# If release is not official, tag it with the release phase. | |
if [ "$tag" != "" ] | |
then | |
tag_args="--tag $tag" | |
fi | |
if [ "${{ github.event_name }}" != "release" ] | |
then | |
dry_run_arg="--dry-run" | |
fi | |
# Create .npmignore to exclude hidden directories. | |
echo /.\*/ > .npmignore | |
npm publish --access public $tag_args $dry_run_arg |