-
Notifications
You must be signed in to change notification settings - Fork 19
171 lines (139 loc) · 4.34 KB
/
Copy pathpublish.yml
File metadata and controls
171 lines (139 loc) · 4.34 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
name: Publish
on:
push:
tags:
- "v*.*.*"
workflow_dispatch:
inputs:
tag:
description: "Existing annotated release tag to publish"
required: true
type: string
env:
RELEASE_TAG: ${{ inputs.tag || github.ref_name }}
permissions:
contents: write
id-token: write
concurrency:
group: release-${{ inputs.tag || github.ref }}
cancel-in-progress: false
jobs:
validate:
name: Validate Release Tag
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ env.RELEASE_TAG }}
submodules: recursive
fetch-depth: 0
- name: Setup Bun
uses: oven-sh/setup-bun@v2
with:
bun-version: latest
- name: Verify annotated release tag
run: |
git fetch --force origin "refs/tags/$RELEASE_TAG:refs/tags/$RELEASE_TAG"
TAG_REF="refs/tags/$RELEASE_TAG"
TAG_TYPE="$(git cat-file -t "$TAG_REF")"
if [ "$TAG_TYPE" != "tag" ]; then
echo "Release tags must be annotated. Use: git tag -a $RELEASE_TAG -m $RELEASE_TAG"
exit 1
fi
TAG_COMMIT="$(git rev-parse "$TAG_REF^{}")"
HEAD_COMMIT="$(git rev-parse HEAD)"
if [ "$TAG_COMMIT" != "$HEAD_COMMIT" ]; then
echo "Checked out commit $HEAD_COMMIT does not match tag target $TAG_COMMIT"
exit 1
fi
- name: Install dependencies
run: bun install --frozen-lockfile
- name: Verify tag matches package version
run: |
VERSION="${RELEASE_TAG#v}"
PACKAGE_VERSION="$(bun -e "console.log((await Bun.file('package.json').json()).version)")"
if [ "$PACKAGE_VERSION" != "$VERSION" ]; then
echo "Tag version $VERSION does not match package.json version $PACKAGE_VERSION"
exit 1
fi
- name: Verify changelog release notes
run: bun run scripts/extract-changelog-release-notes.ts "${RELEASE_TAG#v}" /tmp/release-notes.md
- name: Verify generated themes
run: bun run check:themes
- name: Check formatting
run: bun run format:check
- name: Lint
run: bun run lint
- name: Build package
run: bun run build
- name: Build playground
run: bun run playground:build
- name: Run tests
run: bun run test:ci
publish:
name: Publish to npm
runs-on: ubuntu-latest
timeout-minutes: 30
needs: validate
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ env.RELEASE_TAG }}
submodules: recursive
fetch-depth: 0
- name: Setup Bun
uses: oven-sh/setup-bun@v2
with:
bun-version: latest
- name: Setup Node.js for npm
uses: actions/setup-node@v4
with:
node-version: 24
registry-url: "https://registry.npmjs.org/"
- name: Upgrade npm for trusted publishing
run: |
npm install -g npm@latest
npm --version
- name: Install dependencies
run: bun install --frozen-lockfile
- name: Build package
run: bun run build
- name: Publish package
run: npm publish --provenance --access public
github-release:
name: Create GitHub Release
runs-on: ubuntu-latest
timeout-minutes: 10
needs: publish
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ env.RELEASE_TAG }}
fetch-depth: 0
- name: Setup Bun
uses: oven-sh/setup-bun@v2
with:
bun-version: latest
- name: Extract changelog release notes
run: bun run scripts/extract-changelog-release-notes.ts "${RELEASE_TAG#v}" RELEASE_NOTES.md
- name: Create GitHub Release
env:
GH_TOKEN: ${{ github.token }}
run: |
if gh release view "$RELEASE_TAG" >/dev/null 2>&1; then
gh release edit "$RELEASE_TAG" \
--title "$RELEASE_TAG" \
--notes-file RELEASE_NOTES.md \
--latest \
--verify-tag
else
gh release create "$RELEASE_TAG" \
--title "$RELEASE_TAG" \
--notes-file RELEASE_NOTES.md \
--latest \
--verify-tag
fi