| 1 | name: Release Please |
| 2 | |
| 3 | on: |
| 4 | push: |
| 5 | branches: |
| 6 | - master |
| 7 | |
| 8 | permissions: |
| 9 | contents: read |
| 10 | |
| 11 | jobs: |
| 12 | release-please: |
| 13 | runs-on: ubuntu-latest |
| 14 | if: github.repository == 'poolifier/poolifier' |
| 15 | |
| 16 | permissions: |
| 17 | contents: write |
| 18 | pull-requests: write |
| 19 | |
| 20 | outputs: |
| 21 | release_created: ${{ steps.release.outputs.release_created }} |
| 22 | |
| 23 | steps: |
| 24 | - uses: googleapis/release-please-action@v4 |
| 25 | id: release |
| 26 | with: |
| 27 | token: ${{ secrets.WORKFLOW_TOKEN }} |
| 28 | config-file: .github/release-please/config.json |
| 29 | manifest-file: .github/release-please/manifest.json |
| 30 | |
| 31 | build-release: |
| 32 | needs: release-please |
| 33 | runs-on: ubuntu-latest |
| 34 | if: needs.release-please.outputs.release_created |
| 35 | |
| 36 | steps: |
| 37 | - name: Checkout |
| 38 | uses: actions/checkout@v4 |
| 39 | |
| 40 | - name: Setup pnpm |
| 41 | uses: pnpm/action-setup@v4 |
| 42 | |
| 43 | - name: Setup Node.js |
| 44 | uses: actions/setup-node@v4 |
| 45 | with: |
| 46 | node-version: 20.x |
| 47 | cache: 'pnpm' |
| 48 | |
| 49 | - name: Install Dependencies |
| 50 | run: pnpm install --ignore-scripts --frozen-lockfile |
| 51 | |
| 52 | - name: Tests & Coverage |
| 53 | run: | |
| 54 | pnpm test |
| 55 | pnpm coverage |
| 56 | |
| 57 | - name: Lint |
| 58 | run: pnpm lint |
| 59 | |
| 60 | - name: Production Build |
| 61 | run: pnpm build:prod |
| 62 | |
| 63 | publish-jsr: |
| 64 | needs: build-release |
| 65 | runs-on: ubuntu-latest |
| 66 | |
| 67 | permissions: |
| 68 | contents: read |
| 69 | id-token: write |
| 70 | |
| 71 | steps: |
| 72 | - name: Checkout |
| 73 | uses: actions/checkout@v4 |
| 74 | |
| 75 | - name: Setup Node.js |
| 76 | uses: actions/setup-node@v4 |
| 77 | with: |
| 78 | node-version: 20.x |
| 79 | |
| 80 | - name: Read package.json version |
| 81 | id: package-version |
| 82 | uses: jaywcjlove/github-action-package@main |
| 83 | |
| 84 | - name: Publish Release |
| 85 | if: ${{ contains(steps.package-version.outputs.version, '-') == false }} |
| 86 | run: npx jsr publish --allow-dirty |
| 87 | |
| 88 | publish-npm: |
| 89 | needs: build-release |
| 90 | runs-on: ubuntu-latest |
| 91 | |
| 92 | steps: |
| 93 | - name: Checkout |
| 94 | uses: actions/checkout@v4 |
| 95 | |
| 96 | - name: Setup pnpm |
| 97 | uses: pnpm/action-setup@v4 |
| 98 | |
| 99 | - name: Setup Node.js |
| 100 | uses: actions/setup-node@v4 |
| 101 | with: |
| 102 | node-version: 20.x |
| 103 | registry-url: https://registry.npmjs.org/ |
| 104 | cache: 'pnpm' |
| 105 | |
| 106 | - name: Install Dependencies |
| 107 | run: pnpm install --ignore-scripts --frozen-lockfile |
| 108 | |
| 109 | - name: Read package.json version |
| 110 | id: package-version |
| 111 | uses: jaywcjlove/github-action-package@main |
| 112 | |
| 113 | - name: Publish Release |
| 114 | if: ${{ contains(steps.package-version.outputs.version, '-') == false }} |
| 115 | run: pnpm publish --no-git-checks |
| 116 | env: |
| 117 | NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |
| 118 | |
| 119 | - name: Publish Pre-Release |
| 120 | if: ${{ contains(steps.package-version.outputs.version, '-') == true && contains(steps.package-version.outputs.version, '-beta') == false }} |
| 121 | run: pnpm publish --no-git-checks --tag next |
| 122 | env: |
| 123 | NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |
| 124 | |
| 125 | - name: Publish Beta Release |
| 126 | if: ${{ contains(steps.package-version.outputs.version, '-beta') == true }} |
| 127 | run: pnpm publish --no-git-checks --tag beta |
| 128 | env: |
| 129 | NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |
| 130 | |
| 131 | publish-documentation: |
| 132 | needs: [publish-npm, publish-jsr] |
| 133 | runs-on: ubuntu-latest |
| 134 | |
| 135 | steps: |
| 136 | - name: Checkout |
| 137 | uses: actions/checkout@v4 |
| 138 | |
| 139 | - name: Setup pnpm |
| 140 | uses: pnpm/action-setup@v4 |
| 141 | |
| 142 | - name: Setup Node.js |
| 143 | uses: actions/setup-node@v4 |
| 144 | with: |
| 145 | node-version: 20.x |
| 146 | cache: 'pnpm' |
| 147 | |
| 148 | - name: Generate documentation |
| 149 | run: | |
| 150 | pnpm install --ignore-scripts --frozen-lockfile |
| 151 | pnpm typedoc |
| 152 | |
| 153 | - name: Commit files |
| 154 | if: github.ref == 'refs/heads/${{ github.event.repository.default_branch }}' |
| 155 | env: |
| 156 | COMMIT_MESSAGE: 'docs: publish documentation' |
| 157 | COMMIT_AUTHOR: Documentation Bot |
| 158 | COMMIT_EMAIL: documentation-bot@users.noreply.github.com |
| 159 | run: | |
| 160 | git config --local user.name "${{ env.COMMIT_AUTHOR }}" |
| 161 | git config --local user.email "${{ env.COMMIT_EMAIL }}" |
| 162 | git pull |
| 163 | git add ./docs |
| 164 | git commit -a -m "${{ env.COMMIT_MESSAGE }}" |
| 165 | |
| 166 | - name: Push changes |
| 167 | if: github.ref == 'refs/heads/${{ github.event.repository.default_branch }}' |
| 168 | uses: CasperWA/push-protected@v2 |
| 169 | with: |
| 170 | token: ${{ secrets.GH_TOKEN_PROTECTED }} |
| 171 | branch: ${{ github.event.repository.default_branch }} |