-
Notifications
You must be signed in to change notification settings - Fork 448
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e68435f
commit 47bb239
Showing
1 changed file
with
48 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
name: Release to @pr-<number> tag on npm | ||
on: | ||
pull_request: | ||
types: [opened, synchronize, reopened] | ||
|
||
jobs: | ||
release-pr: | ||
name: 'Release PR to npm' | ||
runs-on: buildjet-4vcpu-ubuntu-2204 | ||
# Comment if:false to enable release PR to npm | ||
# if: false | ||
permissions: write-all | ||
steps: | ||
- uses: actions/checkout@v3 | ||
with: | ||
# need this to get full git-history/clone in order to build changelogs and check changesets | ||
fetch-depth: 0 | ||
ref: ${{ github.event.pull_request.head.ref }} | ||
|
||
- uses: FuelLabs/github-actions/setups/node@master | ||
with: | ||
node-version: 20.11.0 | ||
pnpm-version: 9.5.0 | ||
- uses: FuelLabs/github-actions/setups/npm@master | ||
with: | ||
npm-token: ${{ secrets.NPM_TOKEN }} | ||
|
||
- name: Build packages | ||
run: pnpm build:libs | ||
|
||
- name: Release to @pr-${{ github.event.pull_request.number }} tag on npm | ||
id: release | ||
run: | | ||
pnpm changeset version --snapshot pr-${{ env.PR_NUMBER }} | ||
changetsets=$(pnpm changeset publish --tag pr-${{ env.PR_NUMBER }}) | ||
published_version=$(echo "$changetsets" | grep -oP '@\K([0-9]+\.){2}[0-9]+-pr-${{ env.PR_NUMBER }}-\d+' | head -1) | ||
echo "published_version=$published_version" >> $GITHUB_OUTPUT | ||
env: | ||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
PR_NUMBER: ${{ github.event.pull_request.number }} | ||
|
||
- uses: mshick/add-pr-comment@v2 | ||
with: | ||
message: | | ||
This PR is published in NPM with version **${{ steps.release.outputs.published_version }}** | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |