v0.3.1 #14
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 JS Package | |
| on: | |
| release: | |
| types: [published] | |
| workflow_dispatch: | |
| inputs: | |
| version: | |
| description: 'Version to publish' | |
| required: true | |
| type: string | |
| permissions: | |
| id-token: write # Required for OIDC | |
| contents: read | |
| jobs: | |
| publish: | |
| name: Publish to npm | |
| if: github.event_name == 'workflow_dispatch' || startsWith(github.event.release.tag_name, 'v') | |
| runs-on: ubuntu-latest | |
| environment: npm | |
| defaults: | |
| run: | |
| working-directory: packages/js | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Node | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '24' | |
| registry-url: 'https://registry.npmjs.org' | |
| cache: npm | |
| cache-dependency-path: packages/js/package-lock.json | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Set version from release tag | |
| if: github.event_name == 'release' || github.event_name == 'workflow_dispatch' | |
| env: | |
| RELEASE_TAG: ${{ github.event.release.tag_name }} | |
| INPUT_VERSION: ${{ github.event.inputs.version }} | |
| run: | | |
| if [ "${GITHUB_EVENT_NAME}" = "release" ]; then | |
| echo "Release tag: ${RELEASE_TAG}" | |
| case "${RELEASE_TAG}" in | |
| v*) VERSION="${RELEASE_TAG#v}" ;; | |
| *) echo "Expected a v-prefixed tag (e.g. v0.0.9), got: ${RELEASE_TAG}" && exit 1 ;; | |
| esac | |
| else | |
| VERSION="${INPUT_VERSION}" | |
| echo "Manual dispatch version: ${VERSION}" | |
| fi | |
| if ! echo "${VERSION}" | grep -Eq '^[0-9]+\.[0-9]+\.[0-9]+([-.][0-9A-Za-z.-]+)?$'; then | |
| echo "Invalid semver version: ${VERSION}" | |
| exit 1 | |
| fi | |
| # --allow-same-version: package.json may already be at the release | |
| # version (it is committed in-repo), and `npm version` otherwise | |
| # errors with "Version not changed" and aborts the publish. | |
| npm version "$VERSION" --no-git-tag-version --allow-same-version | |
| - name: Show publish metadata | |
| run: | | |
| echo "Tag: ${GITHUB_REF_NAME:-manual}" | |
| npm pkg get name version | |
| - name: Build | |
| run: npm run build --if-present | |
| - name: Publish | |
| run: npm publish --provenance --access public |