Skip to content

Commit 57b62bc

Browse files
authored
chore: add automated prerelease and update github actions (#894)
1 parent 033b518 commit 57b62bc

4 files changed

Lines changed: 89 additions & 31 deletions

File tree

.github/workflows/deploy-website.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@ jobs:
2626
runs-on: ubuntu-latest
2727
steps:
2828
- name: Checkout
29-
uses: actions/checkout@v4
29+
uses: actions/checkout@v5
3030

31-
- name: Setup node
32-
uses: actions/setup-node@v4
31+
- name: Setup Node
32+
uses: actions/setup-node@v6
3333
with:
34-
node-version: 20
34+
node-version: 24
3535
cache: npm
3636

3737
- name: Install dependencies
@@ -62,8 +62,8 @@ jobs:
6262
needs: build
6363

6464
permissions:
65-
pages: write # to deploy to Pages
66-
id-token: write # to verify the deployment originates from an appropriate source
65+
pages: write # to deploy to Pages
66+
id-token: write # to verify the deployment originates from an appropriate source
6767

6868
environment:
6969
name: github-pages

.github/workflows/release-please.yml

Lines changed: 77 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,43 +5,102 @@ on:
55
permissions:
66
contents: write
77
pull-requests: write
8+
id-token: write # Required for npm provenance
89

910
name: Release Please
1011

1112
jobs:
1213
release-please:
1314
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 }}
1419
steps:
15-
- id: release
16-
name: Release Please
20+
- name: Release Please
21+
id: release
1722
uses: googleapis/release-please-action@v4
1823

1924
with:
2025
release-type: node
21-
package-name: '@vis.gl/react-google-maps'
22-
bump-minor-pre-major: true
2326

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
2934

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
3337
with:
34-
node-version: 20
38+
node-version: 24
3539
cache: npm
3640
registry-url: 'https://registry.npmjs.org'
3741

38-
- if: ${{ steps.release.outputs.release_created }}
39-
name: Install Dependencies
42+
- name: Install Dependencies
4043
run: npm ci
4144

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
4546
run: npm publish
4647
env:
4748
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+
})

.github/workflows/test-website.yml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,13 @@ jobs:
77
runs-on: ubuntu-latest
88
steps:
99
- name: Checkout
10-
uses: actions/checkout@v4
10+
uses: actions/checkout@v5
1111

1212
- name: Setup node
13-
uses: actions/setup-node@v4
13+
uses: actions/setup-node@v6
1414
with:
15-
node-version: 20
15+
node-version: 24
1616
cache: npm
17-
cache-dependency-path: ./website/package-lock.json
1817

1918
- name: Install dependencies
2019
working-directory: ./website

.github/workflows/test.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@ jobs:
55
runs-on: ubuntu-latest
66
steps:
77
- name: Checkout
8-
uses: actions/checkout@v4
8+
uses: actions/checkout@v5
99

1010
- name: Setup Node
11-
uses: actions/setup-node@v4
11+
uses: actions/setup-node@v6
1212
with:
13-
node-version: 20
13+
node-version: 24
1414
cache: npm
1515

1616
- name: Install Dependencies

0 commit comments

Comments
 (0)