Repository navigation
247 lines (234 loc) · 9.24 KB
/
Copy pathpullRequestsCommandAlpha.yml
File metadata and controls
247 lines (234 loc) · 9.24 KB
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
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
# This file was automatically generated by github-actions-wac.
# DO NOT MODIFY IT BY HAND. Instead, modify the source *.wac.ts file(s)
# and run "github-actions-wac build" (or "ghawac build") to regenerate this file.
# For more information, run "github-actions-wac --help".
name: 💬 PR Command - Alpha Release
'on':
issue_comment:
types:
- created
concurrency:
group: alpha-release-${{ github.event.issue.number }}
cancel-in-progress: true
jobs:
checkComment:
name: Check comment for /alpha
if: >-
${{ github.event.issue.pull_request && (github.event.comment.body ==
'/alpha' || startsWith(github.event.comment.body, '/alpha ')) }}
permissions:
contents: read
actions: write
pull-requests: write
issues: write
steps:
- uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444
with:
node-version: 24
- name: Check permission and react to comment
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: >-
PERMISSION=$(gh api "/repos/${{ github.repository }}/collaborators/${{
github.event.comment.user.login }}/permission" -q .permission)
if [ "$PERMISSION" != "write" ] && [ "$PERMISSION" != "admin" ]; then
echo "::error::User ${{ github.event.comment.user.login }} does not have write permission (has: $PERMISSION)."
exit 1
fi
gh api --silent -X POST "/repos/${{ github.repository
}}/issues/comments/${{ github.event.comment.id }}/reactions" -f
content=eyes
- name: Create comment
id: create-comment
uses: >-
peter-evans/create-or-update-comment@e8674b075228eee787fea43ef493e45ece1004c9
with:
issue-number: ${{ github.event.issue.number }}
body: >-
Alpha release has been initiated (for more information, click
[here](https://github.com/webiny/webiny-js/actions/runs/${{
github.run_id }})). :sparkles:
runs-on: ubuntu-latest
env:
NODE_OPTIONS: '--max_old_space_size=4096'
YARN_ENABLE_IMMUTABLE_INSTALLS: false
prBranch:
needs: checkComment
name: Get PR branch
permissions:
contents: read
actions: write
pull-requests: read
outputs:
pr-branch: ${{ steps.pr-branch.outputs.pr-branch }}
pr-sha: ${{ steps.pr-sha.outputs.pr-sha }}
release-version: ${{ steps.release-version.outputs.release-version }}
steps:
- uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444
with:
node-version: 24
- name: Get PR branch
id: pr-branch
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: >-
echo "pr-branch=$(gh pr view ${{ github.event.issue.number }} --repo
${{ github.repository }} --json headRefName -q .headRefName)" >>
$GITHUB_OUTPUT
- name: Get PR head SHA
id: pr-sha
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: >-
echo "pr-sha=$(gh pr view ${{ github.event.issue.number }} --repo ${{
github.repository }} --json headRefOid -q .headRefOid)" >>
$GITHUB_OUTPUT
- name: Parse release version from branch name
id: release-version
run: >-
BRANCH="${{ steps.pr-branch.outputs.pr-branch }}"
VERSION="${BRANCH#release/}"
if [ "$VERSION" = "$BRANCH" ]; then echo "Branch does not match
release/* pattern" && exit 1; fi
echo "release-version=$VERSION" >> $GITHUB_OUTPUT
runs-on: ubuntu-latest
env:
NODE_OPTIONS: '--max_old_space_size=4096'
YARN_ENABLE_IMMUTABLE_INSTALLS: false
build:
name: Build
needs:
- prBranch
runs-on: webiny-build-packages
steps:
- uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444
with:
node-version: 24
- uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09
with:
path: ${{ needs.prBranch.outputs.pr-branch }}
ref: ${{ needs.prBranch.outputs.pr-sha }}
- name: Resolve Yarn cache folder
id: yarn-cache-folder
working-directory: ${{ needs.prBranch.outputs.pr-branch }}
run: echo "path=$(yarn config get cacheFolder)" >> $GITHUB_OUTPUT
- uses: actions/cache/restore@caa296126883cff596d87d8935842f9db880ef25
with:
path: ${{ steps.yarn-cache-folder.outputs.path }}
key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }}
restore-keys: yarn-${{ runner.os }}-
- name: Install dependencies
run: yarn --immutable
working-directory: ${{ needs.prBranch.outputs.pr-branch }}
- name: Build packages
run: yarn build
working-directory: ${{ needs.prBranch.outputs.pr-branch }}
- name: Compress build cache
run: >-
tar -cf run-build-cache.tzst --use-compress-program=zstdmt -C
"${WEBINY_JS_DIR:-.}" .webiny/cached-packages
env:
WEBINY_JS_DIR: ${{ needs.prBranch.outputs.pr-branch }}
- name: Upload build cache
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a
with:
name: run-build-cache
path: run-build-cache.tzst
retention-days: 7
compression-level: 0
if-no-files-found: error
overwrite: true
env:
NODE_OPTIONS: '--max_old_space_size=4096'
YARN_ENABLE_IMMUTABLE_INSTALLS: false
permissions:
contents: read
actions: write
npmReleaseAlpha:
needs:
- prBranch
- build
name: NPM release (alpha)
env:
NODE_OPTIONS: '--max_old_space_size=4096'
YARN_ENABLE_IMMUTABLE_INSTALLS: false
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
SLACK_RELEASE_CHANNEL_WEBHOOK: ${{ secrets.SLACK_RELEASE_CHANNEL_WEBHOOK }}
steps:
- uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444
with:
node-version: 24
- uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09
with:
path: ${{ needs.prBranch.outputs.pr-branch }}
ref: ${{ needs.prBranch.outputs.pr-sha }}
fetch-depth: 0
- name: Resolve Yarn cache folder
id: yarn-cache-folder
working-directory: ${{ needs.prBranch.outputs.pr-branch }}
run: echo "path=$(yarn config get cacheFolder)" >> $GITHUB_OUTPUT
- uses: actions/cache/restore@caa296126883cff596d87d8935842f9db880ef25
with:
path: ${{ steps.yarn-cache-folder.outputs.path }}
key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }}
restore-keys: yarn-${{ runner.os }}-
- name: Download build cache
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c
with:
name: run-build-cache
continue-on-error: true
- name: Extract build cache
run: >-
if [ ! -f run-build-cache.tzst ]; then
echo "::warning::No build cache artifact - building from scratch. This job will be slower than usual."
exit 0
fi
tar -xf run-build-cache.tzst --use-compress-program=zstdmt -C
"${WEBINY_JS_DIR:-.}"
env:
WEBINY_JS_DIR: ${{ needs.prBranch.outputs.pr-branch }}
- name: Install dependencies
run: yarn --immutable
working-directory: ${{ needs.prBranch.outputs.pr-branch }}
- name: Build packages
run: yarn build
working-directory: ${{ needs.prBranch.outputs.pr-branch }}
- name: Create ".npmrc" file in the project root
run: echo "//registry.npmjs.org/:_authToken=\${NPM_TOKEN}" > .npmrc
working-directory: ${{ needs.prBranch.outputs.pr-branch }}
- name: Set git email
run: git config --global user.email "webiny-bot@webiny.com"
working-directory: ${{ needs.prBranch.outputs.pr-branch }}
- name: Set git username
run: git config --global user.name "webiny-bot"
working-directory: ${{ needs.prBranch.outputs.pr-branch }}
- name: Version and publish alpha to NPM
id: release
run: >-
set -o pipefail
yarn release --type=alpha --version=${{
needs.prBranch.outputs.release-version }} 2>&1 | tee
/tmp/release-output.txt
ALPHA_VERSION=$(grep -oE '[0-9]+\.[0-9]+\.[0-9]+-alpha\.[0-9]+'
/tmp/release-output.txt | tail -1)
echo "alpha-version=$ALPHA_VERSION" >> $GITHUB_OUTPUT
working-directory: ${{ needs.prBranch.outputs.pr-branch }}
- name: Notify Slack - Alpha Release
env:
ALPHA_VERSION: ${{ steps.release.outputs.alpha-version }}
run: >-
[ -z "$SLACK_RELEASE_CHANNEL_WEBHOOK" ] && echo "Slack webhook not
configured, skipping." && exit 0
PROJECT_NAME=webiny-$(echo $ALPHA_VERSION | tr . -)
INSTALL_CMD="npx create-webiny-project@${ALPHA_VERSION}
${PROJECT_NAME}"
MSG="Webiny \`${ALPHA_VERSION}\` (alpha) is out! :rocket:\nTo install,
run: \`\`\`${INSTALL_CMD}\`\`\`"
curl -s -o /dev/null -X POST \
-H "Content-type: application/json" \
--data "{\"text\":\"${MSG}\"}" \
"$SLACK_RELEASE_CHANNEL_WEBHOOK"
runs-on: ubuntu-latest
permissions:
contents: read
actions: write