| 1 | name: Publish package |
| 2 | |
| 3 | on: |
| 4 | release: |
| 5 | types: [created] |
| 6 | |
| 7 | jobs: |
| 8 | build: |
| 9 | runs-on: ubuntu-latest |
| 10 | |
| 11 | steps: |
| 12 | - name: Checkout |
| 13 | uses: actions/checkout@v4 |
| 14 | |
| 15 | - name: Setup pnpm |
| 16 | uses: pnpm/action-setup@v3 |
| 17 | with: |
| 18 | version: 8 |
| 19 | |
| 20 | - name: Setup Node.js |
| 21 | uses: actions/setup-node@v4 |
| 22 | with: |
| 23 | node-version: '20.x' |
| 24 | cache: 'pnpm' |
| 25 | |
| 26 | - name: Install Dependencies |
| 27 | run: pnpm install --ignore-scripts --frozen-lockfile |
| 28 | |
| 29 | - name: Tests & Coverage |
| 30 | run: | |
| 31 | pnpm test |
| 32 | pnpm coverage |
| 33 | |
| 34 | - name: Lint |
| 35 | run: pnpm lint |
| 36 | |
| 37 | - name: Production Build |
| 38 | run: pnpm build:prod |
| 39 | |
| 40 | publish-jsr: |
| 41 | needs: build |
| 42 | runs-on: ubuntu-latest |
| 43 | |
| 44 | permissions: |
| 45 | contents: read |
| 46 | id-token: write |
| 47 | |
| 48 | steps: |
| 49 | - name: Checkout |
| 50 | uses: actions/checkout@v4 |
| 51 | |
| 52 | - name: Setup Node.js |
| 53 | uses: actions/setup-node@v4 |
| 54 | with: |
| 55 | node-version: '20.x' |
| 56 | |
| 57 | - name: Read package.json version |
| 58 | id: package-version |
| 59 | uses: jaywcjlove/github-action-package@main |
| 60 | |
| 61 | - name: Publish Release |
| 62 | if: ${{ contains(steps.package-version.outputs.version, '-') == false }} |
| 63 | run: npx jsr publish --allow-dirty |
| 64 | |
| 65 | publish-npm: |
| 66 | needs: build |
| 67 | runs-on: ubuntu-latest |
| 68 | |
| 69 | steps: |
| 70 | - name: Checkout |
| 71 | uses: actions/checkout@v4 |
| 72 | |
| 73 | - name: Setup pnpm |
| 74 | uses: pnpm/action-setup@v3 |
| 75 | with: |
| 76 | version: 8 |
| 77 | |
| 78 | - name: Setup Node.js |
| 79 | uses: actions/setup-node@v4 |
| 80 | with: |
| 81 | node-version: '20.x' |
| 82 | registry-url: https://registry.npmjs.org/ |
| 83 | cache: 'pnpm' |
| 84 | |
| 85 | - name: Install Dependencies |
| 86 | run: pnpm install --ignore-scripts --frozen-lockfile |
| 87 | |
| 88 | - name: Read package.json version |
| 89 | id: package-version |
| 90 | uses: jaywcjlove/github-action-package@main |
| 91 | |
| 92 | - name: Publish Release |
| 93 | if: ${{ contains(steps.package-version.outputs.version, '-') == false }} |
| 94 | run: pnpm publish --no-git-checks |
| 95 | env: |
| 96 | NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |
| 97 | |
| 98 | - name: Publish Pre-Release |
| 99 | if: ${{ contains(steps.package-version.outputs.version, '-') == true && contains(steps.package-version.outputs.version, '-beta') == false }} |
| 100 | run: pnpm publish --no-git-checks --tag next |
| 101 | env: |
| 102 | NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |
| 103 | |
| 104 | - name: Publish Beta Release |
| 105 | if: ${{ contains(steps.package-version.outputs.version, '-beta') == true }} |
| 106 | run: pnpm publish --no-git-checks --tag beta |
| 107 | env: |
| 108 | NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |