AppFlowy-Cloud/.github/workflows/wasm_publish.yml

62 lines
1.8 KiB
YAML

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: 'Package name'
required: true
default: '@appflowyinc/client-api-wasm'
package_version:
description: 'Package version'
required: true
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 package.json
run: |
cd ${{ github.event.inputs.working_directory }}/pkg
jq '.name = "${{ github.event.inputs.package_name }}" | .version = "${{ github.event.inputs.package_version }}"' package.json > package.json.tmp
mv package.json.tmp package.json
- 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 }}