|
5 | 5 | permissions: |
6 | 6 | contents: write |
7 | 7 | pull-requests: write |
| 8 | + id-token: write # Required for npm provenance |
8 | 9 |
|
9 | 10 | name: Release Please |
10 | 11 |
|
11 | 12 | jobs: |
12 | 13 | release-please: |
13 | 14 | runs-on: ubuntu-latest |
| 15 | + outputs: |
| 16 | + # Capture the PR object and release status |
| 17 | + release_created: ${{ steps.release.outputs.release_created }} |
| 18 | + pr: ${{ steps.release.outputs.pr }} |
14 | 19 | steps: |
15 | | - - id: release |
16 | | - name: Release Please |
| 20 | + - name: Release Please |
| 21 | + id: release |
17 | 22 | uses: googleapis/release-please-action@v4 |
18 | 23 |
|
19 | 24 | with: |
20 | 25 | release-type: node |
21 | | - package-name: '@vis.gl/react-google-maps' |
22 | | - bump-minor-pre-major: true |
23 | 26 |
|
24 | | - # Below are the actions for actual npm publishing when a release-branch was merged. |
25 | | - |
26 | | - - if: ${{ steps.release.outputs.release_created }} |
27 | | - name: Checkout |
28 | | - uses: actions/checkout@v4 |
| 27 | + publish-release: |
| 28 | + needs: release-please |
| 29 | + if: ${{ needs.release-please.outputs.release_created == 'true' }} |
| 30 | + runs-on: ubuntu-latest |
| 31 | + steps: |
| 32 | + - name: Checkout |
| 33 | + uses: actions/checkout@v5 |
29 | 34 |
|
30 | | - - if: ${{ steps.release.outputs.release_created }} |
31 | | - name: Setup Node |
32 | | - uses: actions/setup-node@v4 |
| 35 | + - name: Setup Node |
| 36 | + uses: actions/setup-node@v6 |
33 | 37 | with: |
34 | | - node-version: 20 |
| 38 | + node-version: 24 |
35 | 39 | cache: npm |
36 | 40 | registry-url: 'https://registry.npmjs.org' |
37 | 41 |
|
38 | | - - if: ${{ steps.release.outputs.release_created }} |
39 | | - name: Install Dependencies |
| 42 | + - name: Install Dependencies |
40 | 43 | run: npm ci |
41 | 44 |
|
42 | | - - if: ${{ steps.release.outputs.release_created }} |
43 | | - name: Publish |
44 | | - # npm publish will trigger the build via the prepack hook |
| 45 | + - name: Build and Publish |
45 | 46 | run: npm publish |
46 | 47 | env: |
47 | 48 | NODE_AUTH_TOKEN: ${{secrets.NODE_AUTH_TOKEN}} |
| 49 | + |
| 50 | + publish-prerelease: |
| 51 | + needs: release-please |
| 52 | + if: ${{ needs.release-please.outputs.pr != '' && needs.release-please.outputs.release_created != 'true' }} |
| 53 | + runs-on: ubuntu-latest |
| 54 | + steps: |
| 55 | + - name: Checkout |
| 56 | + uses: actions/checkout@v5 |
| 57 | + |
| 58 | + - name: Setup Node |
| 59 | + uses: actions/setup-node@v6 |
| 60 | + with: |
| 61 | + node-version: 24 |
| 62 | + cache: npm |
| 63 | + registry-url: 'https://registry.npmjs.org' |
| 64 | + |
| 65 | + - name: Install Dependencies |
| 66 | + run: npm ci |
| 67 | + |
| 68 | + - name: Calculate RC Version |
| 69 | + id: semver |
| 70 | + run: | |
| 71 | + # The version release-please wants to release (e.g., 1.2.0) |
| 72 | + TARGET_VERSION=$(echo '${{ needs.release-please.outputs.pr }}' | jq -r '.version') |
| 73 | +
|
| 74 | + # Get the current @next version from npm. |
| 75 | + # The `|| echo """` prevents an error if the tag doesn't exist. |
| 76 | + CURRENT_NEXT=$(npm view @vis.gl/react-google-maps dist-tags.next 2>/dev/null || echo "") |
| 77 | +
|
| 78 | + # If we are already on this version's RC cycle, increment it; otherwise, start fresh at rc.1 |
| 79 | + if [[ "$CURRENT_NEXT" == "$TARGET_VERSION-rc."* ]]; then |
| 80 | + NEXT_VERSION=$(npx -y semver $CURRENT_NEXT -i prerelease --preid rc) |
| 81 | + else |
| 82 | + NEXT_VERSION="${TARGET_VERSION}-rc.1" |
| 83 | + fi |
| 84 | +
|
| 85 | + echo "version=$NEXT_VERSION" >> $GITHUB_OUTPUT |
| 86 | +
|
| 87 | + - name: Build and Publish to @next |
| 88 | + run: | |
| 89 | + # Overwrite package.json version locally for publish |
| 90 | + npm version ${{ steps.semver.outputs.version }} --no-git-tag-version |
| 91 | + npm publish --tag next --access public |
| 92 | + env: |
| 93 | + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |
| 94 | + |
| 95 | + - name: Comment on PR |
| 96 | + uses: actions/github-script@v7 |
| 97 | + with: |
| 98 | + script: | |
| 99 | + const prNumber = JSON.parse('${{ needs.release-please.outputs.pr }}').number; |
| 100 | + const version = '${{ steps.semver.outputs.version }}'; |
| 101 | + github.rest.issues.createComment({ |
| 102 | + owner: context.repo.owner, |
| 103 | + repo: context.repo.repo, |
| 104 | + issue_number: prNumber, |
| 105 | + body: `🚀 **Pre-release published!**\n\nInstall this version for testing:\n\`\`\`bash\nnpm install @vis.gl/react-google-maps@${version}\n\`\`\`\nOr use the tag:\n\`\`\`bash\nnpm install @vis.gl/react-google-maps@next\n\`\`\`` |
| 106 | + }) |
0 commit comments