forked from FuelLabs/fuels-wallet
-
Notifications
You must be signed in to change notification settings - Fork 0
177 lines (161 loc) · 5.91 KB
/
release-npm-changeset.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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
name: "Release"
on:
push:
branches:
- master
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
BUILD_VERSION: ""
jobs:
check-commit:
name: Decide if releases or create PR
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: read
outputs:
is_changeset_pr: ${{ steps.check-commit.outputs.is_changeset_pr }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- id: check-commit
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
# Store commit message in a variable and escape it
COMMIT_MSG=$(git log -1 --pretty=%B)
FIRST_LINE=$(echo "$COMMIT_MSG" | head -n1)
if [[ "$FIRST_LINE" == "ci(changesets): versioning packages"* ]]; then
PR_NUMBER=$(echo "$FIRST_LINE" | grep -o '#[0-9]\+' | head -n1 | tr -d '#')
if [ -n "$PR_NUMBER" ]; then
PR_TITLE=$(gh pr view "$PR_NUMBER" --json title -q .title)
if [[ "$PR_TITLE" == "ci(changesets): versioning packages"* ]]; then
echo "is_changeset_pr=true" >> "$GITHUB_OUTPUT"
exit 0
fi
fi
fi
echo "is_changeset_pr=false" >> "$GITHUB_OUTPUT"
create-pr:
name: Push changes to Changeset PR
needs: check-commit
if: needs.check-commit.outputs.is_changeset_pr == 'false'
runs-on: buildjet-4vcpu-ubuntu-2204
permissions:
contents: write
pull-requests: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
persist-credentials: false
- name: Extract pnpm version from .tool-versions
id: get_pnpm
run: |
PNPM_VERSION=$(grep '^pnpm' .tool-versions | awk '{print $2}')
echo "PNPM_VERSION=${PNPM_VERSION}" >> $GITHUB_ENV
- uses: FuelLabs/github-actions/setups/node@master
with:
node-version: 20.11.0
pnpm-version: ${{ env.PNPM_VERSION }}
- name: Setup git user (for changelog step)
run: |
git config --global user.name "${{ github.actor }}"
git config --global user.email "${{ github.actor }}@users.noreply.github.com"
- name: Create Changeset PR
uses: changesets/action@v1
with:
commit: "ci(changesets): versioning packages"
title: "ci(changesets): versioning packages"
createGithubReleases: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
publish-npm:
name: Release to NPM
needs: check-commit
if: needs.check-commit.outputs.is_changeset_pr == 'true'
runs-on: ubuntu-latest
environment: npm-deploy
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
persist-credentials: false
- name: Extract pnpm version from .tool-versions
id: get_pnpm
run: |
PNPM_VERSION=$(grep '^pnpm' .tool-versions | awk '{print $2}')
echo "PNPM_VERSION=${PNPM_VERSION}" >> $GITHUB_ENV
- uses: FuelLabs/github-actions/setups/node@master
with:
node-version: 20.11.0
pnpm-version: ${{ env.PNPM_VERSION }}
- uses: FuelLabs/github-actions/setups/npm@master
with:
npm-token: ${{ secrets.NPM_TOKEN_WALLET }}
- name: Bump and Collect Version
run: |
pnpm changeset version
echo "BUILD_VERSION=$(pnpm -s packages:version)" >> $GITHUB_ENV
git reset --hard
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Build packages
run: pnpm build:libs
- name: Publish to NPM
id: changesets
uses: FuelLabs/changesets-action@v2.0.0
with:
publish: pnpm changeset publish --tag next
createGithubReleases: aggregate
version: pnpm changeset version
env:
GITHUB_TOKEN: ${{ secrets.REPO_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN_WALLET }}
- name: Build Fuel Wallet
if: steps.changesets.outputs.published == 'true'
run: pnpm build:crx
env:
## increase node.js m memory limit for building
## with sourcemaps
NODE_OPTIONS: "--max-old-space-size=4096"
- name: Build Fuel Wallet Development
if: steps.changesets.outputs.published == 'true'
run: pnpm build:crx
env:
VITE_CRX_RELEASE: false
VITE_CRX_NAME: "Fuel Wallet Development"
CRX_OUT: "dist-crx-dev"
APP_VERSION_POSTFIX: "-development"
NODE_OPTIONS: "--max-old-space-size=4096"
- name: Upload Production artifacts to Sentry
if: steps.changesets.outputs.published == 'true'
run: |
pnpm sentry-cli sourcemaps inject --release ${{ env.BUILD_VERSION }} ./dist-crx
pnpm sentry-cli sourcemaps upload --release ${{ env.BUILD_VERSION }} ./dist-crx
env:
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
SENTRY_ORG: ${{ vars.SENTRY_ORG }}
SENTRY_PROJECT: ${{ vars.SENTRY_PROJECT }}
working-directory: ./packages/app
- name: Upload Development artifacts to Sentry
if: steps.changesets.outputs.published == 'true'
run: |
pnpm sentry-cli sourcemaps inject --release ${{ env.BUILD_VERSION }} ./dist-crx-dev
pnpm sentry-cli sourcemaps upload --release ${{ env.BUILD_VERSION }} ./dist-crx-dev
env:
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
SENTRY_ORG: ${{ vars.SENTRY_ORG }}
SENTRY_PROJECT: ${{ vars.SENTRY_PROJECT }}
working-directory: ./packages/app
- name: Attach Fuel Wallet to release
if: steps.changesets.outputs.published == 'true'
uses: softprops/action-gh-release@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
tag_name: v${{ env.BUILD_VERSION }}
files: |
./packages/app/dist/*.zip