|
| 1 | +name: Beta Release |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_run: |
| 5 | + workflows: ["CI"] |
| 6 | + branches: [beta] |
| 7 | + types: [completed] |
| 8 | + |
| 9 | +permissions: |
| 10 | + contents: write |
| 11 | + pull-requests: write |
| 12 | + issues: write |
| 13 | + actions: write |
| 14 | + statuses: write |
| 15 | + id-token: write |
| 16 | + |
| 17 | +concurrency: |
| 18 | + group: release-please-beta |
| 19 | + cancel-in-progress: false |
| 20 | + |
| 21 | +env: |
| 22 | + FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true |
| 23 | + |
| 24 | +jobs: |
| 25 | + release-please: |
| 26 | + name: Release Please (Beta) |
| 27 | + if: >- |
| 28 | + github.event.workflow_run.conclusion == 'success' && |
| 29 | + github.event.workflow_run.event == 'push' |
| 30 | + runs-on: ubuntu-latest |
| 31 | + outputs: |
| 32 | + release_created: ${{ steps.release.outputs.release_created }} |
| 33 | + tag_name: ${{ steps.release.outputs.tag_name }} |
| 34 | + pr_head_sha: ${{ steps.pr-sha.outputs.sha }} |
| 35 | + steps: |
| 36 | + - name: Release Please |
| 37 | + id: release |
| 38 | + uses: googleapis/release-please-action@v4 |
| 39 | + with: |
| 40 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 41 | + target-branch: beta |
| 42 | + config-file: release-please-config-beta.json |
| 43 | + manifest-file: .release-please-manifest-beta.json |
| 44 | + |
| 45 | + - name: Update release title with date |
| 46 | + if: ${{ steps.release.outputs.release_created }} |
| 47 | + env: |
| 48 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 49 | + TAG: ${{ steps.release.outputs.tag_name }} |
| 50 | + REPO: ${{ github.repository }} |
| 51 | + run: | |
| 52 | + DATE=$(date -u +"%Y/%m/%d") |
| 53 | + gh release edit "$TAG" --repo "$REPO" --title "$TAG ($DATE)" |
| 54 | +
|
| 55 | + - name: Get PR head SHA |
| 56 | + id: pr-sha |
| 57 | + if: ${{ !steps.release.outputs.release_created }} |
| 58 | + env: |
| 59 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 60 | + REPO: ${{ github.repository }} |
| 61 | + run: | |
| 62 | + SHA=$(gh pr list --repo "$REPO" --head release-please--branches--beta --state open --json headRefOid --jq '.[0].headRefOid // empty') |
| 63 | + echo "sha=${SHA:-}" >> "$GITHUB_OUTPUT" |
| 64 | +
|
| 65 | + test-release-pr: |
| 66 | + name: Test (Beta Release PR) |
| 67 | + needs: release-please |
| 68 | + if: ${{ !needs.release-please.outputs.release_created && needs.release-please.outputs.pr_head_sha != '' }} |
| 69 | + runs-on: ubuntu-latest |
| 70 | + steps: |
| 71 | + - name: Set pending status |
| 72 | + env: |
| 73 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 74 | + SHA: ${{ needs.release-please.outputs.pr_head_sha }} |
| 75 | + REPO: ${{ github.repository }} |
| 76 | + run: | |
| 77 | + gh api "repos/$REPO/statuses/$SHA" \ |
| 78 | + -f state=pending -f context="Test (Beta)" -f description="Running tests..." \ |
| 79 | + || echo "::warning::Failed to set pending status on $SHA" |
| 80 | +
|
| 81 | + - name: Checkout |
| 82 | + uses: actions/checkout@v6 |
| 83 | + with: |
| 84 | + ref: ${{ needs.release-please.outputs.pr_head_sha }} |
| 85 | + |
| 86 | + - name: Setup pnpm |
| 87 | + uses: pnpm/action-setup@v5 |
| 88 | + |
| 89 | + - name: Setup Node.js |
| 90 | + uses: actions/setup-node@v6 |
| 91 | + with: |
| 92 | + node-version: 18 |
| 93 | + cache: pnpm |
| 94 | + cache-dependency-path: pnpm-lock.yaml |
| 95 | + |
| 96 | + - name: Install dependencies |
| 97 | + run: pnpm install --frozen-lockfile |
| 98 | + |
| 99 | + - name: Test (unit only) |
| 100 | + run: pnpm test:ci |
| 101 | + |
| 102 | + - name: Build |
| 103 | + run: pnpm tsup |
| 104 | + |
| 105 | + - name: Report success |
| 106 | + if: success() |
| 107 | + continue-on-error: true |
| 108 | + env: |
| 109 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 110 | + SHA: ${{ needs.release-please.outputs.pr_head_sha }} |
| 111 | + REPO: ${{ github.repository }} |
| 112 | + run: | |
| 113 | + gh api "repos/$REPO/statuses/$SHA" \ |
| 114 | + -f state=success -f context="Test (Beta)" -f description="Tests passed" \ |
| 115 | + || echo "::warning::Failed to report success status on $SHA" |
| 116 | +
|
| 117 | + - name: Report failure |
| 118 | + if: failure() |
| 119 | + continue-on-error: true |
| 120 | + env: |
| 121 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 122 | + SHA: ${{ needs.release-please.outputs.pr_head_sha }} |
| 123 | + REPO: ${{ github.repository }} |
| 124 | + run: | |
| 125 | + gh api "repos/$REPO/statuses/$SHA" \ |
| 126 | + -f state=failure -f context="Test (Beta)" -f description="Tests failed" \ |
| 127 | + || echo "::warning::Failed to report failure status on $SHA" |
| 128 | +
|
| 129 | + lint-release-pr: |
| 130 | + name: Lint (Beta Release PR) |
| 131 | + needs: release-please |
| 132 | + if: ${{ !needs.release-please.outputs.release_created && needs.release-please.outputs.pr_head_sha != '' }} |
| 133 | + runs-on: ubuntu-latest |
| 134 | + steps: |
| 135 | + - name: Set pending status |
| 136 | + env: |
| 137 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 138 | + SHA: ${{ needs.release-please.outputs.pr_head_sha }} |
| 139 | + REPO: ${{ github.repository }} |
| 140 | + run: | |
| 141 | + gh api "repos/$REPO/statuses/$SHA" \ |
| 142 | + -f state=pending -f context="Lint (Beta)" -f description="Running lint..." \ |
| 143 | + || echo "::warning::Failed to set pending status on $SHA" |
| 144 | +
|
| 145 | + - name: Checkout |
| 146 | + uses: actions/checkout@v6 |
| 147 | + with: |
| 148 | + ref: ${{ needs.release-please.outputs.pr_head_sha }} |
| 149 | + |
| 150 | + - name: Setup pnpm |
| 151 | + uses: pnpm/action-setup@v5 |
| 152 | + |
| 153 | + - name: Setup Node.js |
| 154 | + uses: actions/setup-node@v6 |
| 155 | + with: |
| 156 | + node-version: 18 |
| 157 | + cache: pnpm |
| 158 | + cache-dependency-path: pnpm-lock.yaml |
| 159 | + |
| 160 | + - name: Install dependencies |
| 161 | + run: pnpm install --frozen-lockfile |
| 162 | + |
| 163 | + - name: Lint |
| 164 | + run: pnpm lint:ci |
| 165 | + |
| 166 | + - name: Report success |
| 167 | + if: success() |
| 168 | + continue-on-error: true |
| 169 | + env: |
| 170 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 171 | + SHA: ${{ needs.release-please.outputs.pr_head_sha }} |
| 172 | + REPO: ${{ github.repository }} |
| 173 | + run: | |
| 174 | + gh api "repos/$REPO/statuses/$SHA" \ |
| 175 | + -f state=success -f context="Lint (Beta)" -f description="Lint passed" \ |
| 176 | + || echo "::warning::Failed to report success status on $SHA" |
| 177 | +
|
| 178 | + - name: Report failure |
| 179 | + if: failure() |
| 180 | + continue-on-error: true |
| 181 | + env: |
| 182 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 183 | + SHA: ${{ needs.release-please.outputs.pr_head_sha }} |
| 184 | + REPO: ${{ github.repository }} |
| 185 | + run: | |
| 186 | + gh api "repos/$REPO/statuses/$SHA" \ |
| 187 | + -f state=failure -f context="Lint (Beta)" -f description="Lint failed" \ |
| 188 | + || echo "::warning::Failed to report failure status on $SHA" |
| 189 | +
|
| 190 | + publish: |
| 191 | + name: Publish to npm (Beta) |
| 192 | + needs: release-please |
| 193 | + if: ${{ needs.release-please.outputs.release_created == 'true' }} |
| 194 | + runs-on: ubuntu-latest |
| 195 | + steps: |
| 196 | + - name: Checkout |
| 197 | + uses: actions/checkout@v6 |
| 198 | + with: |
| 199 | + ref: ${{ needs.release-please.outputs.tag_name }} |
| 200 | + |
| 201 | + - name: Setup pnpm |
| 202 | + uses: pnpm/action-setup@v5 |
| 203 | + |
| 204 | + - name: Setup Node.js |
| 205 | + uses: actions/setup-node@v6 |
| 206 | + with: |
| 207 | + node-version: 18 |
| 208 | + cache: pnpm |
| 209 | + cache-dependency-path: pnpm-lock.yaml |
| 210 | + registry-url: https://registry.npmjs.org |
| 211 | + |
| 212 | + - name: Install dependencies |
| 213 | + run: pnpm install --frozen-lockfile |
| 214 | + |
| 215 | + - name: Build |
| 216 | + run: pnpm tsup |
| 217 | + |
| 218 | + - name: Publish with provenance (beta) |
| 219 | + run: npm publish --provenance --access public --tag beta |
| 220 | + env: |
| 221 | + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |
| 222 | + |
| 223 | + - name: Report publish failure |
| 224 | + if: failure() |
| 225 | + env: |
| 226 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 227 | + TAG: ${{ needs.release-please.outputs.tag_name }} |
| 228 | + REPO: ${{ github.repository }} |
| 229 | + run: | |
| 230 | + echo "::error::npm publish failed for $TAG" |
| 231 | + gh release edit "$TAG" --repo "$REPO" \ |
| 232 | + --notes "$(gh release view "$TAG" --repo "$REPO" --json body --jq .body) |
| 233 | +
|
| 234 | + --- |
| 235 | + > **WARNING**: npm publish failed. Package was NOT published to npm." || true |
0 commit comments