Skip to content

Publish npm package #74

Publish npm package

Publish npm package #74

Workflow file for this run

name: Publish npm package
on:
workflow_dispatch:
inputs:
dry-run:
description: 'Dry run'
required: true
type: boolean
default: 'true'
schedule:
- cron: '48 3 * * 1' # 3:48 AM UTC every Monday
jobs:
preflight:
name: Preflight
runs-on: ubuntu-20.04
outputs:
dry-run: ${{ steps.get-dry-run.outputs.dry-run }}
steps:
- name: Get dry run
id: get-dry-run
shell: pwsh
run: |
$IsDryRun = '${{ github.event.inputs.dry-run }}' -Eq 'true' -Or '${{ github.event_name }}' -Eq 'schedule'
if ($IsDryRun) {
echo "dry-run=true" >> $Env:GITHUB_OUTPUT
} else {
echo "dry-run=false" >> $Env:GITHUB_OUTPUT
}
tests:
name: Tests
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: 16
- name: Setup wasm-pack
shell: bash
run: |
curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
- name: Tests
shell: pwsh
run: |
Set-Location ./ffi/wasm
./run_tests.ps1
publish:
name: Publish package
runs-on: ubuntu-20.04
environment: npm-publish
needs:
- preflight
- tests
if: needs.preflight.outputs.dry-run == 'false'
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup wasm-pack
shell: bash
run: |
curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
- name: Build & Publish
shell: pwsh
run: |
Set-Location ./ffi/wasm
npm config set "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}"
./publish.ps1