-
Notifications
You must be signed in to change notification settings - Fork 1
507 lines (447 loc) Β· 22.1 KB
/
submit.yml
File metadata and controls
507 lines (447 loc) Β· 22.1 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
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
name: Release Management
on:
push:
branches: [main]
pull_request:
types: [opened, synchronize, reopened]
# Manual workflow dispatch for releases
workflow_dispatch:
inputs:
action:
description: 'Action to perform'
required: true
default: 'build'
type: choice
options:
- build
- release
- submit
dryRun:
description: 'Perform dry run (no actual submission)'
default: false
type: boolean
# Comment-triggered releases
issue_comment:
types: [created]
jobs:
# Dry run check on every PR
pr_check:
name: PR Build Check
runs-on: ubuntu-24.04-arm
if: github.event_name == 'pull_request'
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
name: Install pnpm
with:
run_install: false
- uses: actions/setup-node@v4
with:
node-version: 24
cache: "pnpm"
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Check for changesets
id: changeset-check
run: |
if [ -z "$(ls .changeset/*.md 2>/dev/null | grep -v README)" ]; then
echo "hasChangesets=false" >> "$GITHUB_OUTPUT"
echo "β οΈ No changesets found."
else
echo "hasChangesets=true" >> "$GITHUB_OUTPUT"
echo "β
Changesets found."
fi
- name: Validate changeset format (if changesets exist)
if: steps.changeset-check.outputs.hasChangesets == 'true'
run: |
echo "Validating changeset format..."
# Check if changesets are properly formatted
git fetch origin main --depth 1
pnpm changeset status
echo "β
Changeset format is valid"
- name: Test version bump (dry run)
if: steps.changeset-check.outputs.hasChangesets == 'true'
run: |
echo "Testing version bump..."
# Create a temporary branch to test version bump
git checkout -b temp-version-test
pnpm changeset version
echo "β
Version bump test successful"
git checkout -
git branch -D temp-version-test
- name: Build extension (dry run)
run: |
echo "Testing build process..."
pnpm run zip:all
echo "β
Build test successful"
- name: Validate build outputs
run: |
echo "Validating build outputs..."
# Check if required files are generated
if [ ! -f "dist/*-chrome.zip" ] && [ ! -f dist/*-chrome.zip ]; then
echo "β Chrome build not found"
exit 1
fi
if [ ! -f "dist/*-firefox.zip" ] && [ ! -f dist/*-firefox.zip ]; then
echo "β Firefox build not found"
exit 1
fi
if [ ! -f "dist/*-sources.zip" ] && [ ! -f dist/*-sources.zip ]; then
echo "β Source build not found"
exit 1
fi
echo "β
All required build outputs present"
- name: Test submission format (dry run)
run: |
echo "Testing submission format..."
# Test the submission command in dry run mode
DRY_RUN=true pnpm wxt submit \
--chrome-zip dist/*-chrome.zip \
--firefox-zip dist/*-firefox.zip --firefox-sources-zip dist/*-sources.zip || true
echo "β
Submission format test completed"
- name: Comment on PR with check results
uses: actions/github-script@v7
with:
script: |
const hasChangesets = '${{ steps.changeset-check.outputs.hasChangesets }}' === 'true';
let body = '## π PR Build Check Results\n\n';
body += 'β
**All checks passed!** This PR is ready for merge.\n\n';
body += '### Validation Results:\n';
body += '- β
Dependencies installed successfully\n';
body += '- β
Build process completed without errors\n';
body += '- β
All required output files generated\n';
body += '- β
Submission format validated\n';
if (hasChangesets) {
body += '- β
Changesets found and validated\n';
body += '- β
Version bump test successful\n\n';
body += '> **Note**: This PR includes changesets and will trigger a version bump when merged.';
} else {
body += '- β οΈ No changesets found\n\n';
body += '> **Note**: This PR does not include changesets. No version bump will occur when merged.';
}
await github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: body
});
- name: Comment on PR with failure results
if: failure()
uses: actions/github-script@v7
with:
script: |
let body = '## β PR Build Check Failed\n\n';
body += '**This PR has build issues that need to be resolved before merging.**\n\n';
body += '### Common Issues:\n';
body += '- Build process failed (check build logs)\n';
body += '- Missing required dependencies\n';
body += '- Invalid changeset format\n';
body += '- Missing required output files\n\n';
body += '> Please check the workflow logs above for specific error details and fix the issues.';
await github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: body
});
# Check if comment triggers a release
check_comment:
name: Check Release Comment
runs-on: ubuntu-24.04-arm
if: github.event_name == 'issue_comment' && github.event.issue.pull_request && contains(github.event.comment.body, '/release')
outputs:
should_release: ${{ steps.check.outputs.should_release }}
steps:
- name: Check if comment author has permission
id: check
uses: actions/github-script@v7
with:
script: |
const { owner, repo } = context.repo;
const { data: collaborator } = await github.rest.repos.getCollaboratorPermissionLevel({
owner,
repo,
username: context.actor
});
const hasPermission = ['admin', 'write'].includes(collaborator.permission);
console.log(`User ${context.actor} has permission: ${hasPermission}`);
if (hasPermission) {
core.setOutput('should_release', 'true');
// Add reaction to comment
await github.rest.reactions.createForIssueComment({
owner,
repo,
comment_id: context.payload.comment.id,
content: 'rocket'
});
} else {
core.setOutput('should_release', 'false');
// Add reaction to comment
await github.rest.reactions.createForIssueComment({
owner,
repo,
comment_id: context.payload.comment.id,
content: 'confused'
});
}
changeset:
name: Version with Changeset
runs-on: ubuntu-24.04-arm
if: |
github.event_name == 'push' ||
github.event_name == 'workflow_dispatch' ||
(github.event_name == 'issue_comment' && needs.check_comment.outputs.should_release == 'true')
needs: [check_comment]
outputs:
hasChangesets: ${{ steps.changeset-check.outputs.hasChangesets }}
newVersion: ${{ steps.version.outputs.newVersion }}
currentVersion: ${{ steps.current-version.outputs.currentVersion }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
# For PR comments, checkout the PR branch
ref: ${{ github.event_name == 'issue_comment' && github.event.issue.pull_request.head.ref || github.ref }}
- uses: pnpm/action-setup@v4
name: Install pnpm
with:
run_install: false
- uses: actions/setup-node@v4
with:
node-version: 24
cache: "pnpm"
- name: Configure Git
run: |
git config user.email "github-actions@users.noreply.github.com"
git config user.name "GitHub Actions"
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Check for changesets
id: changeset-check
run: |
if [ -z "$(ls .changeset/*.md 2>/dev/null | grep -v README)" ]; then
echo "hasChangesets=false" >> "$GITHUB_OUTPUT"
echo "β οΈ No changesets found. Skipping version bump."
else
echo "hasChangesets=true" >> "$GITHUB_OUTPUT"
echo "β
Changesets found. Proceeding with version bump."
fi
- name: Version packages
if: steps.changeset-check.outputs.hasChangesets == 'true'
id: version
run: |
pnpm changeset version
NEW_VERSION=$(node -p "require('./package.json').version")
echo "newVersion=$NEW_VERSION" >> "$GITHUB_OUTPUT"
echo "π¦ New version: $NEW_VERSION"
- name: Get current version (if no changesets)
if: steps.changeset-check.outputs.hasChangesets == 'false'
id: current-version
run: |
CURRENT_VERSION=$(node -p "require('./package.json').version")
echo "currentVersion=$CURRENT_VERSION" >> "$GITHUB_OUTPUT"
echo "π¦ Current version: $CURRENT_VERSION"
# Only auto-commit on push to main
- name: Commit and Push (with version bump)
if: ${{ github.event_name == 'push' && steps.changeset-check.outputs.hasChangesets == 'true' }}
run: |
git add .
git commit -m "chore(release): v$NEW_VERSION"
git tag v$NEW_VERSION
git push
git push --tags
env:
NEW_VERSION: ${{ steps.version.outputs.newVersion }}
# Comment on PR when triggered by comment
- name: Comment on PR - Changeset Results
if: github.event_name == 'issue_comment'
uses: actions/github-script@v7
with:
script: |
const hasChangesets = '${{ steps.changeset-check.outputs.hasChangesets }}' === 'true';
const newVersion = '${{ steps.version.outputs.newVersion }}';
const currentVersion = '${{ steps.current-version.outputs.currentVersion }}';
let body = '## π Changeset Processing Complete\n\n';
if (hasChangesets) {
body += `β
**Changesets found and processed**\n`;
body += `π¦ **New version**: \`v${newVersion}\`\n\n`;
body += `The following changes will be included in the release:\n`;
body += `- Version bumped from previous version to \`v${newVersion}\`\n`;
body += `- Changelog updated with changeset entries\n\n`;
body += `> **Note**: Version changes are staged but not committed yet. The build and release process will continue.`;
} else {
body += `β οΈ **No changesets found**\n`;
body += `π¦ **Current version**: \`v${currentVersion}\`\n\n`;
body += `No version bump will be performed. This will create a build release instead.\n\n`;
body += `> **Note**: Consider adding a changeset if you want to bump the version for this release.`;
}
await github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: body
});
build:
name: Build
runs-on: ubuntu-24.04-arm
needs: [changeset]
if: |
github.event_name == 'workflow_dispatch' ||
(github.event_name == 'issue_comment' && needs.check_comment.outputs.should_release == 'true')
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.event_name == 'issue_comment' && github.event.issue.pull_request.head.ref || github.ref }}
- uses: pnpm/action-setup@v4
name: Install pnpm
with:
run_install: false
- uses: actions/setup-node@v4
with:
node-version: 24
cache: "pnpm"
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Build and Zip
run: |
pnpm run zip:all
- name: Upload Artifacts
uses: actions/upload-artifact@v4
with:
name: extension-build-${{ github.run_number }}
path: dist/*.zip
if-no-files-found: error
include-hidden-files: true
release:
name: Create Release
runs-on: ubuntu-24.04-arm
needs: [changeset, build]
if: |
(github.event_name == 'workflow_dispatch' && inputs.action == 'release') ||
(github.event_name == 'issue_comment' && needs.check_comment.outputs.should_release == 'true')
steps:
- name: Download build artifacts
uses: actions/download-artifact@v4
with:
name: extension-build-${{ github.run_number }}
path: dist/
- name: Create GitHub Release (with version bump)
if: ${{ needs.changeset.outputs.hasChangesets == 'true' }}
uses: softprops/action-gh-release@v1
with:
tag_name: v${{ needs.changeset.outputs.newVersion }}
name: Release v${{ needs.changeset.outputs.newVersion }}
body: |
## Changes
Check the [CHANGELOG.md](./CHANGELOG.md) for detailed changes.
## Extension Files
- Chrome: `amgiflol-${{ needs.changeset.outputs.newVersion }}-chrome.zip`
- Firefox: `amgiflol-${{ needs.changeset.outputs.newVersion }}-firefox.zip`
files: |
dist/*-chrome.zip
dist/*-firefox.zip
draft: false
prerelease: false
- name: Create GitHub Release (no version bump)
if: ${{ needs.changeset.outputs.hasChangesets == 'false' }}
uses: softprops/action-gh-release@v1
with:
tag_name: v${{ needs.changeset.outputs.currentVersion }}-build-${{ github.run_number }}
name: Build v${{ needs.changeset.outputs.currentVersion }}-build-${{ github.run_number }}
body: |
## Build Release
This is a build release without version changes.
## Extension Files
- Chrome: `amgiflol-${{ needs.changeset.outputs.currentVersion }}-chrome.zip`
- Firefox: `amgiflol-${{ needs.changeset.outputs.currentVersion }}-firefox.zip`
files: |
dist/*-chrome.zip
dist/*-firefox.zip
draft: false
prerelease: true
- name: Comment on PR (if triggered by comment)
if: github.event_name == 'issue_comment'
uses: actions/github-script@v7
with:
script: |
const hasChangesets = '${{ needs.changeset.outputs.hasChangesets }}' === 'true';
const version = hasChangesets ? '${{ needs.changeset.outputs.newVersion }}' : '${{ needs.changeset.outputs.currentVersion }}';
const releaseUrl = `https://github.com/${context.repo.owner}/${context.repo.repo}/releases/tag/v${version}${hasChangesets ? '' : '-build-' + context.runNumber}`;
let body = '## π Release Created Successfully!\n\n';
body += `π¦ **Version**: \`v${version}${hasChangesets ? '' : '-build-' + context.runNumber}\`\n`;
body += `π **Release URL**: ${releaseUrl}\n\n`;
if (hasChangesets) {
body += `β
**Full release** with version bump and changelog updates\n`;
} else {
body += `β οΈ **Build release** without version changes (marked as prerelease)\n`;
}
body += `\nπ **Extension files are attached to the release**\n`;
body += `- Chrome: \`amgiflol-${version}-chrome.zip\`\n`;
body += `- Firefox: \`amgiflol-${version}-firefox.zip\``;
await github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: body
});
submit:
name: Submit to Stores
runs-on: ubuntu-24.04-arm
needs: [changeset, build, release]
if: |
(github.event_name == 'workflow_dispatch' && inputs.action == 'submit') ||
(github.event_name == 'issue_comment' && needs.check_comment.outputs.should_release == 'true')
steps:
- uses: actions/checkout@v4
- name: Download build artifacts
uses: actions/download-artifact@v4
with:
name: extension-build-${{ github.run_number }}
path: dist/
- name: Submit to stores
run: |
pnpm wxt submit \
--chrome-zip dist/*-chrome.zip \
--firefox-zip dist/*-firefox.zip --firefox-sources-zip dist/*-sources.zip
env:
DRY_RUN: ${{ github.event_name == 'workflow_dispatch' && inputs.dryRun || false }}
CHROME_EXTENSION_ID: ${{ secrets.CHROME_EXTENSION_ID }}
CHROME_CLIENT_ID: ${{ secrets.CHROME_CLIENT_ID }}
CHROME_CLIENT_SECRET: ${{ secrets.CHROME_CLIENT_SECRET }}
CHROME_REFRESH_TOKEN: ${{ secrets.CHROME_REFRESH_TOKEN }}
FIREFOX_EXTENSION_ID: ${{ secrets.FIREFOX_EXTENSION_ID }}
FIREFOX_JWT_ISSUER: ${{ secrets.FIREFOX_JWT_ISSUER }}
FIREFOX_JWT_SECRET: ${{ secrets.FIREFOX_JWT_SECRET }}
EDGE_PRODUCT_ID: ${{ secrets.EDGE_PRODUCT_ID }}
EDGE_CLIENT_ID: ${{ secrets.EDGE_CLIENT_ID }}
EDGE_CLIENT_SECRET: ${{ secrets.EDGE_CLIENT_SECRET }}
EDGE_ACCESS_TOKEN_URL: ${{ secrets.EDGE_ACCESS_TOKEN_URL }}
- name: Comment on PR with submission result
if: github.event_name == 'issue_comment'
uses: actions/github-script@v7
with:
script: |
const dryRun = '${{ github.event_name == 'workflow_dispatch' && inputs.dryRun || false }}' === 'true';
let body = '## π€ Store Submission ';
body += dryRun ? 'Dry Run Complete' : 'Complete';
body += '\n\n';
if (dryRun) {
body += 'π **Dry run mode** - No actual submission performed\n';
body += 'β
All validation checks passed\n';
body += 'π Ready for actual submission when you\'re ready\n\n';
body += '> Run the workflow again without dry run to submit to stores.';
} else {
body += 'β
**Extension submitted to stores successfully!**\n\n';
body += 'π± **Submitted to**:\n';
body += '- Chrome Web Store\n';
body += '- Firefox Add-ons (AMO)\n';
body += '- Microsoft Edge Add-ons\n\n';
body += '> Store reviews typically take 1-3 business days. You\'ll receive email notifications about the review status.';
}
await github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: body
});