Manual NPM Package Publish #2
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: Manual NPM Package Publish | |
on: | |
workflow_dispatch: | |
inputs: | |
working_directory: | |
description: 'Working directory (e.g., libs/client-api-wasm)' | |
required: true | |
default: 'libs/client-api-wasm' | |
package_name: | |
description: 'Which package to publish' | |
required: true | |
default: '@appflowyinc/client-api-wasm' | |
type: choice | |
options: | |
- '@appflowyinc/client-api-wasm' | |
package_version: | |
description: 'Package version' | |
required: true | |
prerelease_preid: | |
description: 'Preid for prerelease version (e.g., alpha, beta, rc)' | |
required: false | |
type: choice | |
default: '' | |
options: | |
- '' | |
- 'alpha' | |
- 'beta' | |
- 'rc' | |
env: | |
NODE_VERSION: '20.12.0' | |
RUST_TOOLCHAIN: "1.75" | |
jobs: | |
publish: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions-rs/toolchain@v1 | |
with: | |
toolchain: ${{ env.RUST_TOOLCHAIN }} | |
- name: Setup Node.js | |
uses: actions/setup-node@v1 | |
with: | |
node-version: ${{ env.NODE_VERSION }} | |
- uses: Swatinem/rust-cache@v2 | |
with: | |
workspaces: | | |
AppFlowy-Cloud | |
- name: Install wasm-pack | |
run: npm install -g wasm-pack | |
- name: Build with wasm-pack | |
run: wasm-pack build | |
working-directory: ${{ github.event.inputs.working_directory }} | |
- name: Update name | |
working-directory: ${{ github.event.inputs.working_directory }}/pkg | |
run: | | |
jq '.name = "${{ github.event.inputs.package_name }}"' package.json > package.json.tmp | |
mv package.json.tmp package.json | |
- name: Update version | |
working-directory: ${{ github.event.inputs.working_directory }}/pkg | |
run: | | |
npm version ${{ github.event.inputs.package_version }} | |
if [ "${{ github.event.inputs.prerelease_preid }}" != "" ]; then | |
npm version prerelease --preid ${{ github.event.inputs.prerelease_preid }} | |
fi | |
- name: Configure npm for wasm-pack | |
run: echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > ${{ github.event.inputs.working_directory }}/pkg/.npmrc | |
- name: Publish package | |
run: | | |
npm config set access public | |
wasm-pack publish | |
working-directory: ${{ github.event.inputs.working_directory }}/pkg | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |