Fixed the release/publishing CI #383
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: CI | |
| on: | |
| push: | |
| branches: [master] | |
| pull_request: | |
| branches: [master] | |
| release: | |
| types: [published] | |
| jobs: | |
| build: | |
| name: Build | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v6 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v6 | |
| with: | |
| node-version: 22 | |
| registry-url: https://registry.npmjs.org/ | |
| cache: npm | |
| - name: Install latest NPM | |
| run: npm i -g npm@latest | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Build | |
| run: npm run build | |
| - name: Pack | |
| run: npm pack | |
| - name: Upload package artifact | |
| uses: actions/upload-artifact@v7 | |
| with: | |
| name: package | |
| path: cldn-ip-0.0.0-dev.tgz | |
| test: | |
| name: Test on Node.js ${{ matrix.node }} | |
| runs-on: ubuntu-latest | |
| needs: build | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| node: [20, 22, 24] | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v6 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v6 | |
| with: | |
| node-version: ${{ matrix.node }} | |
| registry-url: https://registry.npmjs.org/ | |
| cache: npm | |
| - name: Install latest NPM | |
| run: npm i -g npm@latest | |
| - name: Install test dependencies | |
| run: npm ci | |
| - name: Download build artifact | |
| uses: actions/download-artifact@v8 | |
| with: | |
| name: package | |
| path: . | |
| - name: Extract build package | |
| run: tar -xzf cldn-ip-0.0.0-dev.tgz --strip-components=1 -C . --overwrite | |
| - name: Test | |
| run: npm run test | |
| test-deno: | |
| name: Test on Deno | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v6 | |
| - name: Install Deno | |
| uses: denoland/setup-deno@v2 | |
| - name: Install test dependencies | |
| run: deno install | |
| - name: Check types | |
| run: deno check src tests --sloppy-imports | |
| - name: Check formatting | |
| run: deno fmt --check | |
| - name: Test | |
| run: deno task test | |
| publish: | |
| name: Publish | |
| needs: | |
| - build | |
| - test | |
| - test-deno | |
| if: github.event_name == 'release' | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| id-token: write | |
| pages: write | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v6 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v6 | |
| with: | |
| node-version: 22 | |
| registry-url: https://registry.npmjs.org/ | |
| cache: npm | |
| - name: Install latest NPM | |
| run: npm i -g npm@latest | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Set version from release tag | |
| run: npm version ${{ github.event.release.tag_name }} --git-tag-version=false | |
| - name: Generate jsr.json from package.json | |
| run: | | |
| jq '{ | |
| name: .name, | |
| version: .version, | |
| license: .license, | |
| exports: "./src/index.ts" | |
| }' package.json > jsr.json | |
| - name: Publish to JSR | |
| run: npx jsr publish | |
| - name: Download build artifact | |
| uses: actions/download-artifact@v8 | |
| with: | |
| name: package | |
| path: ./package | |
| - name: Extract build package | |
| working-directory: ./package | |
| run: tar -xzf cldn-ip-0.0.0-dev.tgz | |
| - name: Copy package.json to build package | |
| run: cp package.json package/package | |
| - name: Publish release to NPM | |
| if: "!github.event.release.prerelease" | |
| working-directory: ./package/package | |
| run: npm publish --provenance --access public | |
| - name: Publish release candidate to NPM | |
| if: github.event.release.prerelease | |
| working-directory: ./package/package | |
| run: npm publish --provenance --access public --tag rc | |
| - name: Generate docs | |
| if: "!github.event.release.prerelease" | |
| run: npm run docs:build | |
| - name: Set up GitHub pages | |
| if: "!github.event.release.prerelease" | |
| uses: actions/configure-pages@v6 | |
| - name: Upload docs artifact to pages | |
| if: "!github.event.release.prerelease" | |
| uses: actions/upload-pages-artifact@v3 | |
| with: | |
| path: docs/.vitepress/dist | |
| - name: Deploy to GitHub Pages | |
| if: "!github.event.release.prerelease" | |
| id: deployment | |
| uses: actions/deploy-pages@v5 |