Merge branch 'task/2668-terraphim-lsp-foundation' into main #82
Workflow file for this run
This file contains hidden or 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: Publish WASM Package | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| version: | |
| description: 'Version to publish (semantic version)' | |
| required: true | |
| type: string | |
| dry_run: | |
| description: 'Run in dry-run mode only' | |
| required: false | |
| type: boolean | |
| default: true | |
| tag: | |
| description: 'npm tag (latest, beta, next)' | |
| required: false | |
| type: string | |
| default: latest | |
| push: | |
| tags: | |
| - 'v*' | |
| - 'wasm-v*' | |
| permissions: | |
| contents: read | |
| packages: write | |
| jobs: | |
| publish-wasm: | |
| name: Build and publish wasm package | |
| runs-on: ubuntu-latest | |
| defaults: | |
| run: | |
| working-directory: crates/terraphim_automata/wasm | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v6 | |
| - name: Install Rust toolchain | |
| uses: dtolnay/rust-toolchain@stable | |
| with: | |
| targets: wasm32-unknown-unknown | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v5 | |
| with: | |
| node-version: '20' | |
| registry-url: https://npm.pkg.github.com | |
| scope: '@terraphim' | |
| - name: Install wasm-pack | |
| run: | | |
| if ! command -v wasm-pack >/dev/null 2>&1; then | |
| cargo install wasm-pack --locked | |
| fi | |
| - name: Determine publish version | |
| id: version | |
| run: | | |
| VERSION="${{ inputs.version }}" | |
| if [[ -z "$VERSION" ]]; then | |
| if [[ "${{ github.ref }}" == refs/tags/wasm-v* ]]; then | |
| VERSION=${GITHUB_REF#refs/tags/wasm-v} | |
| elif [[ "${{ github.ref }}" == refs/tags/v* ]]; then | |
| VERSION=${GITHUB_REF#refs/tags/v} | |
| fi | |
| fi | |
| if [[ ! "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then | |
| echo "Invalid version format: $VERSION" | |
| exit 1 | |
| fi | |
| echo "version=$VERSION" >> "$GITHUB_OUTPUT" | |
| - name: Build wasm package | |
| run: wasm-pack build --release --target web | |
| - name: Set npm package metadata | |
| working-directory: crates/terraphim_automata/wasm/pkg | |
| run: | | |
| npm pkg set name='@terraphim/automata-wasm' | |
| npm pkg set publishConfig.registry='https://npm.pkg.github.com' | |
| npm version "${{ steps.version.outputs.version }}" --no-git-tag-version | |
| - name: Prepare package token | |
| env: | |
| OP_SERVICE_ACCOUNT_TOKEN: ${{ secrets.OP_SERVICE_ACCOUNT_TOKEN }} | |
| run: | | |
| TOKEN="" | |
| if command -v op >/dev/null 2>&1; then | |
| TOKEN=$(op read "op://TerraphimPlatform/npm.token/password" 2>/dev/null || true) | |
| fi | |
| if [[ -z "$TOKEN" ]]; then | |
| TOKEN="${{ secrets.GITHUB_TOKEN }}" | |
| fi | |
| echo "NPM_TOKEN=$TOKEN" >> "$GITHUB_ENV" | |
| - name: Publish wasm package | |
| working-directory: crates/terraphim_automata/wasm/pkg | |
| env: | |
| NODE_AUTH_TOKEN: ${{ env.NPM_TOKEN }} | |
| run: | | |
| NPM_TAG="${{ inputs.tag }}" | |
| if [[ -z "$NPM_TAG" ]]; then | |
| NPM_TAG=latest | |
| fi | |
| if [[ "${{ inputs.dry_run }}" == "true" ]]; then | |
| npm publish --dry-run --tag "$NPM_TAG" | |
| else | |
| npm publish --tag "$NPM_TAG" | |
| fi |