Skip to content

Release

Release #1

Workflow file for this run

name: Release
on:
release:
types:
- published
push:
branches:
- test-release
jobs:
build:
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
publish:
needs: build
# Publish is valid only for release publication.
if: github.event_name == 'release'
runs-on: ubuntu-latest
steps:
- 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
# Create .npmignore to exclude hidden directories.
echo /.\*/ > .npmignore
npm publish --access public $tag_args