Build and Publish JS Packages #1
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: Build and Publish JS Packages | |
| on: | |
| release: | |
| types: [created] | |
| workflow_dispatch: | |
| jobs: | |
| test: | |
| runs-on: ubuntu-latest | |
| if: | | |
| github.event_name == 'workflow_dispatch' || | |
| (github.event_name == 'release' && | |
| startsWith(github.ref, 'refs/tags/') && | |
| contains(github.ref, 'js_v')) | |
| strategy: | |
| matrix: | |
| node-version: ["22", "24"] | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Setup pnpm | |
| uses: pnpm/action-setup@v4 | |
| with: | |
| version: latest | |
| - name: Set up Node ${{ matrix.node-version }} | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: ${{ matrix.node-version }} | |
| cache: pnpm | |
| cache-dependency-path: src/js/pnpm-lock.yaml | |
| - name: Install dependencies | |
| working-directory: src/js | |
| run: pnpm install --frozen-lockfile | |
| - name: Build | |
| working-directory: src/js | |
| run: pnpm build | |
| - name: Run tests | |
| working-directory: src/js | |
| run: pnpm test | |
| publish: | |
| runs-on: ubuntu-latest | |
| needs: [test] | |
| environment: npm | |
| permissions: | |
| id-token: write | |
| if: | | |
| github.event_name == 'workflow_dispatch' || | |
| (github.event_name == 'release' && | |
| startsWith(github.ref, 'refs/tags/') && | |
| contains(github.ref, 'js_v')) | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Setup pnpm | |
| uses: pnpm/action-setup@v4 | |
| with: | |
| version: latest | |
| - name: Set up Node | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: "24" | |
| registry-url: https://registry.npmjs.org | |
| - name: Install dependencies | |
| working-directory: src/js | |
| run: pnpm install --frozen-lockfile | |
| - name: Build | |
| working-directory: src/js | |
| run: pnpm build | |
| - name: Publish | |
| working-directory: src/js | |
| run: pnpm -r publish --access public --no-git-checks | |
| env: | |
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |