-
Notifications
You must be signed in to change notification settings - Fork 0
206 lines (190 loc) · 6.37 KB
/
Copy pathci.yml
File metadata and controls
206 lines (190 loc) · 6.37 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
name: CI + Publish
on:
push:
branches:
- main
tags:
- "*"
pull_request:
branches:
- main
workflow_dispatch:
inputs:
check:
type: boolean
description: "Run lint, fmt, and test?"
required: false
default: true
publish-jsr:
type: boolean
description: "Publish to JSR?"
required: false
default: true
publish-npm:
type: boolean
description: "Publish to NPM?"
required: false
default: true
publish-gpr:
type: boolean
description: "Publish to GPR?"
required: false
default: true
release:
type: boolean
description: "Create a new GitHub Release?"
required: false
default: false
release-title:
type: string
description: |
Release title template ('{0}' -> $GITHUB_REF_NAME)
required: false
default: "{0}"
release-tag:
type: string
description: |
Git tag to create the release for ('{0}' -> $GITHUB_REF_NAME)
required: false
default: "{0}"
release-draft:
type: boolean
description: "Should the release be a draft?"
required: false
default: false
release-discussion-category:
type: string
description: "Discussion category for announcing new Releases"
required: false
default: "Releases"
release-assets:
type: string
description: "Glob pattern for assets to attach to the Release"
required: false
jobs:
check:
if: inputs.check == 'true' || github.event_name != 'workflow_dispatch'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: denoland/setup-deno@v2
with:
deno-version: v2.x
- id: ok
run: deno task ok
- if: success()
run: |
if [ -d .coverage ]; then
cp -r .coverage coverage
else
exit 1
fi
- id: coveralls
if: success()
continue-on-error: true
uses: coverallsapp/github-action@v2
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
file: .coverage/lcov.info
- id: coverage
if: success()
continue-on-error: true
uses: actions/upload-artifact@v6
with:
path: coverage
name: nberlette-math-coverage_${{ github.ref_name }}-${{ github.sha }}
publish:
if: |
(github.event_name == 'push' &&
startsWith(github.ref, 'refs/tags/') &&
needs.check.result == 'success') ||
(github.event_name == 'workflow_dispatch' && (
inputs.publish-jsr == 'true' ||
inputs.publish-npm == 'true' ||
inputs.publish-gpr == 'true'
) && (needs.check.result == 'success' || inputs.check == 'false'))
runs-on: ubuntu-latest
needs: check
permissions:
contents: write
id-token: write
packages: write
concurrency:
cancel-in-progress: true
group: publish-${{ github.ref_name }}
env:
IS_TAG: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') }}
IS_DISPATCHED: ${{ github.event_name == 'workflow_dispatch' }}
PUBLISH_JSR: ${{ (github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') && needs.check.result == 'success') || (github.event_name == 'workflow_dispatch' && inputs.publish-jsr == 'true') }}
PUBLISH_NPM: ${{ (github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') && needs.check.result == 'success') || (github.event_name == 'workflow_dispatch' && inputs.publish-npm == 'true') }}
PUBLISH_GPR: ${{ (github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') && needs.check.result == 'success') || (github.event_name == 'workflow_dispatch' && inputs.publish-gpr == 'true') }}
RELEASE_TITLE: ${{ format(inputs.release-title || '{0}', github.ref_name) }}
RELEASE_TAG: ${{ format(inputs.release-tag || '{0}', github.ref_name) }}
steps:
- uses: actions/checkout@v6
- name: "setup deno"
uses: denoland/setup-deno@v2
with:
deno-version: v2.x
- if: env.PUBLISH_JSR
name: "publish to jsr"
continue-on-error: true
run: deno publish
- if: env.PUBLISH_NPM
name: "setup node for npm"
uses: actions/setup-node@v6
with:
node-version: 24
registry-url: "https://registry.npmjs.org"
- id: build
if: env.PUBLISH_NPM || env.PUBLISH_GPR
name: "build for npm"
run: deno task build
env:
NO_PUBLISH: 1
- id: artifact
if: steps.build.outcome == 'success'
continue-on-error: true
uses: actions/upload-artifact@v6
with:
path: npm
name: nberlette-math-npm_${{ github.ref_name }}-${{ github.sha }}
- if: env.PUBLISH_NPM
name: "publish to npm"
continue-on-error: true
run: npm publish --access public
working-directory: npm
- if: env.PUBLISH_GPR
name: "setup node for gpr"
uses: actions/setup-node@v6
with:
node-version: 24
registry-url: "https://npm.pkg.github.com"
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- if: env.PUBLISH_GPR
name: "publish to gpr"
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.GITHUB_TOKEN }}
continue-on-error: true
working-directory: npm
run: npm publish --access public --registry https://npm.pkg.github.com
- if: inputs.release != 'false' && (env.IS_TAG || github.ref_type == 'tag')
id: release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
# shellcheck disable=SC2086,SC2206
ASSETS=(${INPUT_RELEASE_ASSETS:-})
if [ ${#ASSETS[@]} -eq 0 ]; then
if [ -d npm ]; then
(cd npm && npm pack 2>/dev/null)
ASSETS+=(./npm/*.tgz)
fi
fi
DRAFT=""
if [[ "${INPUT_RELEASE_DRAFT:-false}" == "true" ]]; then
DRAFT=true
fi
gh release create --title "${RELEASE_TITLE:-$GITHUB_REF_NAME}" --generate-notes --discussion-category "${INPUT_RELEASE_DISCUSSION_CATEGORY:-Releases}" "${DRAFT:+--draft}" "${RELEASE_TAG:-$GITHUB_REF_NAME}" "${ASSETS[@]}"