chore(sdk/js): bump to 0.5.8-beta.0 for release workflow testing #2
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
| # SPDX-FileCopyrightText: © 2025 Phala Network <dstack@phala.network> | |
| # | |
| # SPDX-License-Identifier: Apache-2.0 | |
| name: Publish JS SDK to npm | |
| on: | |
| push: | |
| tags: ['js-sdk-v*'] | |
| workflow_dispatch: | |
| inputs: | |
| npm_tag: | |
| description: 'npm dist-tag (latest, beta, canary)' | |
| required: true | |
| default: 'latest' | |
| type: choice | |
| options: | |
| - latest | |
| - beta | |
| - canary | |
| permissions: | |
| id-token: write | |
| contents: read | |
| jobs: | |
| publish: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' | |
| registry-url: 'https://registry.npmjs.org' | |
| - name: Upgrade npm for OIDC support | |
| run: | | |
| npm install -g npm@latest | |
| echo "npm version: $(npm --version)" | |
| - name: Verify OIDC token availability | |
| run: | | |
| if [ -n "${ACTIONS_ID_TOKEN_REQUEST_URL}" ] && [ -n "${ACTIONS_ID_TOKEN_REQUEST_TOKEN}" ]; then | |
| echo "OIDC token available" | |
| else | |
| echo "OIDC token NOT available" | |
| echo "Check workflow permissions include 'id-token: write'" | |
| exit 1 | |
| fi | |
| - name: Verify repository configuration | |
| working-directory: sdk/js | |
| run: | | |
| echo "Checking repository consistency..." | |
| GIT_REPO=$(git remote get-url origin | sed 's/.*github.com[/:]//; s/.git$//') | |
| PKG_REPO=$(node -e "console.log(require('./package.json').repository?.url || '')" | sed 's|https://github.com/||; s|git+||; s|.git$||') | |
| echo "Git remote: $GIT_REPO" | |
| echo "package.json: $PKG_REPO" | |
| if [ "$GIT_REPO" != "$PKG_REPO" ]; then | |
| echo "Repository mismatch!" | |
| echo "This will cause 422 error during publish" | |
| exit 1 | |
| fi | |
| echo "Repositories match" | |
| - name: Install dependencies | |
| working-directory: sdk/js | |
| run: npm install | |
| - name: Build | |
| working-directory: sdk/js | |
| run: npm run build | |
| - name: Determine npm dist-tag | |
| id: tag | |
| run: | | |
| if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then | |
| echo "tag=${{ github.event.inputs.npm_tag }}" >> "$GITHUB_OUTPUT" | |
| else | |
| # auto-detect from git tag: js-sdk-v0.5.8-beta.1 -> beta | |
| RAW_TAG="${GITHUB_REF_NAME}" | |
| if echo "$RAW_TAG" | grep -qiE '(beta|alpha|rc|preview)'; then | |
| echo "tag=beta" >> "$GITHUB_OUTPUT" | |
| else | |
| echo "tag=latest" >> "$GITHUB_OUTPUT" | |
| fi | |
| fi | |
| - name: Publish to npm | |
| working-directory: sdk/js | |
| run: | | |
| NPM_TAG="${{ steps.tag.outputs.tag }}" | |
| echo "Publishing with dist-tag: $NPM_TAG" | |
| npm publish --access public --provenance --tag "$NPM_TAG" |