-
Notifications
You must be signed in to change notification settings - Fork 0
117 lines (97 loc) · 3.52 KB
/
Copy pathrelease.yml
File metadata and controls
117 lines (97 loc) · 3.52 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
name: Release
on:
push:
tags:
- 'v*'
permissions:
contents: write
jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
# Full history + tags needed to diff against the previous release tag below.
fetch-depth: 0
- name: Install pnpm
uses: pnpm/action-setup@v4
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 22
cache: pnpm
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Sync package.json version with tag
run: pnpm pkg set version="${GITHUB_REF_NAME#v}"
- name: Type-check
run: pnpm compile
- name: Lint
run: pnpm lint
- name: Test
run: pnpm test
- name: Build & zip (Chrome)
run: pnpm zip
- name: Build & zip (Firefox)
run: pnpm zip:firefox
- name: Generate release notes
id: notes
run: |
PREV_TAG=$(git describe --tags --abbrev=0 "${GITHUB_REF_NAME}^" 2>/dev/null || echo "")
RANGE="${PREV_TAG:+$PREV_TAG..}$GITHUB_REF_NAME"
# This repo commits straight to main (no PRs), so GitHub's PR-based
# release-notes generator has nothing to work with — build the notes
# from the commit log instead. Excludes the release-automation's own
# bookkeeping commits (version bump, changelog update) as noise.
COMMITS=$(git log "$RANGE" --no-merges \
--grep '^chore: release v' --grep '^docs: update changelog for v' --invert-grep \
--pretty=format:'- %s (%h)')
{
echo "body<<NOTES_EOF"
echo "${COMMITS:-No notable changes.}"
if [ -n "$PREV_TAG" ]; then
echo ""
echo "**Full Changelog**: https://github.com/${{ github.repository }}/compare/${PREV_TAG}...${GITHUB_REF_NAME}"
fi
echo "NOTES_EOF"
} >> "$GITHUB_OUTPUT"
- name: Create GitHub release
uses: softprops/action-gh-release@v2
with:
files: .output/*.zip
body: ${{ steps.notes.outputs.body }}
- name: Checkout main
uses: actions/checkout@v4
with:
ref: main
- name: Update changelog
env:
NOTES: ${{ steps.notes.outputs.body }}
run: |
node .github/scripts/update-changelog.mjs \
"${GITHUB_REF_NAME#v}" \
"$(date -u +%Y-%m-%d)" \
"$NOTES"
- name: Commit changelog
id: changelog
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add docs/changelog.md
if git diff --cached --quiet; then
echo "No changelog changes to commit"
echo "changed=false" >> "$GITHUB_OUTPUT"
else
git commit -m "docs: update changelog for ${GITHUB_REF_NAME}"
git push origin HEAD:main
echo "changed=true" >> "$GITHUB_OUTPUT"
fi
# The tag was pushed (and the release created) before the changelog commit
# existed, so it points one commit behind main. Move it onto the changelog
# commit so the release/tag actually contains the changelog update.
- name: Move release tag onto changelog commit
if: steps.changelog.outputs.changed == 'true'
run: |
git tag -f "$GITHUB_REF_NAME"
git push origin "$GITHUB_REF_NAME" --force