-
Notifications
You must be signed in to change notification settings - Fork 1.4k
95 lines (86 loc) · 3.15 KB
/
breaking-change-pr-release.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
name: Release to @rc-<pr_number> tag on npm
on:
pull_request:
branches:
- "master"
types:
- opened
- edited
- synchronize
- ready_for_review
- converted_to_draft
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number }}
cancel-in-progress: true
jobs:
check-pr:
runs-on: ubuntu-latest
name: "Validate if PR needs to be released"
outputs:
isBreakingChange: ${{ steps.check-title.outputs.isBreakingChange }}
isDraft: ${{ steps.check-draft.outputs.isDraft }}
steps:
- name: Check if PR title is a breaking change
id: check-title
run: |
PR_TITLE=$(jq -r .pull_request.title "$GITHUB_EVENT_PATH")
echo "$PR_TITLE"
if echo "$PR_TITLE" | grep -qE '^\w+!:'; then
echo "isBreakingChange=true" >> "$GITHUB_OUTPUT"
else
echo "isBreakingChange=false" >> "$GITHUB_OUTPUT"
fi
- name: Check if PR is a draft
id: check-draft
run: |
if ${{ github.event.pull_request.draft }}; then
echo "isDraft=true" >> "$GITHUB_OUTPUT"
else
echo "isDraft=false" >> "$GITHUB_OUTPUT"
fi
release-pr:
needs: check-pr
if: needs.check-pr.outputs.isBreakingChange == 'true' && needs.check-pr.outputs.isDraft == 'false'
name: "Release breaking change PR to npm"
runs-on: ubuntu-latest
permissions: write-all
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: ./.github/actions/ci-setup
with:
node-version: 20.14.0
pnpm-version: 9.4.0
- uses: FuelLabs/github-actions/setups/npm@master
with:
npm-token: ${{ secrets.NPM_TOKEN }}
- name: Build
run: pnpm build
- name: Add RC flag to PR name
uses: frabert/replace-string-action@v2
id: release_name
with:
string: ${{ github.event.pull_request.number }}
pattern: "^(.*)$"
replace-with: "rc-$1"
- name: Release to @${{ steps.release_name.outputs.replaced }} tag on npm
id: release
run: |
pnpm changeset:next
git add .changeset/fuel-labs-ci.md
pnpm changeset version --snapshot ${{ steps.release_name.outputs.replaced }}
changetsets=$(pnpm changeset publish --tag ${{ steps.release_name.outputs.replaced }})
published_version=$(echo "$changetsets" | grep -oP '@\K([0-9]+\.){2}[0-9]+-${{ steps.release_name.outputs.replaced }}-\d+' | head -1)
echo "published_version=$published_version" >> $GITHUB_OUTPUT
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Update SDK on Wallet
uses: benc-uk/workflow-dispatch@v1
with:
workflow: update-sdk-manual.yaml
ref: master
repo: FuelLabs/fuels-wallet
inputs: '{ "publisher": "${{ github.event.repository.name }}", "issue": "${{ github.event.pull_request.number }}", "packages": "fuels", "tag": "${{ steps.release_name.outputs.replaced }}" }'
token: ${{ secrets.REPO_TOKEN }}