-
Notifications
You must be signed in to change notification settings - Fork 15
210 lines (180 loc) · 6.09 KB
/
release-please.yml
File metadata and controls
210 lines (180 loc) · 6.09 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
name: Release
on:
workflow_run:
workflows: ["CI"]
branches: [master]
types: [completed]
permissions:
contents: write
pull-requests: write
issues: write
actions: write
statuses: write
id-token: write
concurrency:
group: release-please-master
cancel-in-progress: false
env:
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
jobs:
release-please:
name: Release Please
if: >-
github.event.workflow_run.conclusion == 'success' &&
github.event.workflow_run.event == 'push'
runs-on: ubuntu-latest
outputs:
release_created: ${{ steps.release.outputs.release_created }}
tag_name: ${{ steps.release.outputs.tag_name }}
pr_head_sha: ${{ steps.pr-sha.outputs.sha }}
steps:
- name: Release Please
id: release
uses: googleapis/release-please-action@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Update release title with date
if: ${{ steps.release.outputs.release_created }}
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TAG: ${{ steps.release.outputs.tag_name }}
REPO: ${{ github.repository }}
run: |
DATE=$(date -u +"%Y/%m/%d")
gh release edit "$TAG" --repo "$REPO" --title "$TAG ($DATE)"
- name: Get PR head SHA
id: pr-sha
if: ${{ !steps.release.outputs.release_created }}
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
REPO: ${{ github.repository }}
run: |
SHA=$(gh pr list --repo "$REPO" --head release-please--branches--master --state open --json headRefOid --jq '.[0].headRefOid // empty')
echo "sha=${SHA:-}" >> "$GITHUB_OUTPUT"
test-release-pr:
name: Test (Release PR)
needs: release-please
if: ${{ !needs.release-please.outputs.release_created && needs.release-please.outputs.pr_head_sha != '' }}
runs-on: ubuntu-latest
steps:
- name: Set pending status
continue-on-error: true
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SHA: ${{ needs.release-please.outputs.pr_head_sha }}
REPO: ${{ github.repository }}
run: |
gh api "repos/$REPO/statuses/$SHA" \
-f state=pending -f context="Test" -f description="Running tests..."
- name: Checkout
uses: actions/checkout@v6
with:
ref: ${{ needs.release-please.outputs.pr_head_sha }}
- name: Setup pnpm
uses: pnpm/action-setup@v5
- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version: 18
cache: pnpm
cache-dependency-path: pnpm-lock.yaml
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Test (unit only)
run: pnpm test:ci
- name: Build
run: pnpm tsup
- name: Report success
if: success()
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SHA: ${{ needs.release-please.outputs.pr_head_sha }}
REPO: ${{ github.repository }}
run: |
gh api "repos/$REPO/statuses/$SHA" \
-f state=success -f context="Test" -f description="Tests passed"
- name: Report failure
if: failure()
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SHA: ${{ needs.release-please.outputs.pr_head_sha }}
REPO: ${{ github.repository }}
run: |
gh api "repos/$REPO/statuses/$SHA" \
-f state=failure -f context="Test" -f description="Tests failed"
lint-release-pr:
name: Lint (Release PR)
needs: release-please
if: ${{ !needs.release-please.outputs.release_created && needs.release-please.outputs.pr_head_sha != '' }}
runs-on: ubuntu-latest
steps:
- name: Set pending status
continue-on-error: true
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SHA: ${{ needs.release-please.outputs.pr_head_sha }}
REPO: ${{ github.repository }}
run: |
gh api "repos/$REPO/statuses/$SHA" \
-f state=pending -f context="Lint" -f description="Running lint..."
- name: Checkout
uses: actions/checkout@v6
with:
ref: ${{ needs.release-please.outputs.pr_head_sha }}
- name: Setup pnpm
uses: pnpm/action-setup@v5
- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version: 18
cache: pnpm
cache-dependency-path: pnpm-lock.yaml
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Lint
run: pnpm lint:ci
- name: Report success
if: success()
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SHA: ${{ needs.release-please.outputs.pr_head_sha }}
REPO: ${{ github.repository }}
run: |
gh api "repos/$REPO/statuses/$SHA" \
-f state=success -f context="Lint" -f description="Lint passed"
- name: Report failure
if: failure()
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SHA: ${{ needs.release-please.outputs.pr_head_sha }}
REPO: ${{ github.repository }}
run: |
gh api "repos/$REPO/statuses/$SHA" \
-f state=failure -f context="Lint" -f description="Lint failed"
publish:
name: Publish to npm
needs: release-please
if: ${{ needs.release-please.outputs.release_created == 'true' }}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v6
with:
ref: ${{ needs.release-please.outputs.tag_name }}
- name: Setup pnpm
uses: pnpm/action-setup@v5
- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version: 18
cache: pnpm
cache-dependency-path: pnpm-lock.yaml
registry-url: https://registry.npmjs.org
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Build
run: pnpm tsup
- name: Publish with provenance
run: npm publish --provenance --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}