Skip to content

Commit cb55080

Browse files
committed
feat: enable test releases
1 parent e68435f commit cb55080

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed

.github/workflows/pr-release.yaml

+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: Release to @pr-<number> tag on npm
2+
on:
3+
pull_request:
4+
types: [opened, synchronize, reopened]
5+
6+
jobs:
7+
release-pr:
8+
name: 'Release PR to npm'
9+
runs-on: buildjet-4vcpu-ubuntu-2204
10+
# Comment if:false to enable release PR to npm
11+
# if: false
12+
permissions: write-all
13+
steps:
14+
- uses: actions/checkout@v3
15+
with:
16+
# need this to get full git-history/clone in order to build changelogs and check changesets
17+
fetch-depth: 0
18+
ref: ${{ github.event.pull_request.head.ref }}
19+
20+
- uses: FuelLabs/github-actions/setups/node@master
21+
with:
22+
node-version: 20.11.0
23+
pnpm-version: 9.5.0
24+
- uses: FuelLabs/github-actions/setups/npm@master
25+
with:
26+
npm-token: ${{ secrets.NPM_TOKEN }}
27+
28+
- name: Build packages
29+
run: pnpm build:libs
30+
31+
- name: Release to @pr-${{ github.event.pull_request.number }} tag on npm
32+
id: release
33+
run: |
34+
pnpm changeset:next
35+
git add .changeset/fuel-labs-ci.md
36+
pnpm changeset version --snapshot pr-${{ env.PR_NUMBER }}
37+
changetsets=$(pnpm changeset publish --tag pr-${{ env.PR_NUMBER }})
38+
published_version=$(echo "$changetsets" | grep -oP '@\K([0-9]+\.){2}[0-9]+-pr-${{ env.PR_NUMBER }}-\d+' | head -1)
39+
echo "published_version=$published_version" >> $GITHUB_OUTPUT
40+
env:
41+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
42+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
43+
PR_NUMBER: ${{ github.event.pull_request.number }}
44+
45+
- uses: mshick/add-pr-comment@v2
46+
with:
47+
message: |
48+
This PR is published in NPM with version **${{ steps.release.outputs.published_version }}**
49+
env:
50+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)