-
Notifications
You must be signed in to change notification settings - Fork 133
306 lines (274 loc) · 10.2 KB
/
pkg-platform.yml
File metadata and controls
306 lines (274 loc) · 10.2 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
name: pkg for platform
run-name: pkging ${{ fromJSON(inputs.pkg).project }} (${{ inputs.name }})
on:
workflow_call:
inputs:
name:
description: brewkit platform unique ID
type: string
tinyname:
description: >
GitHub Actions has a non resizable sidebar so we need a shorter name
or it’s much harder to differentiate the different jobs.
type: string
default: ${{ inputs.name }}
os:
type: string
container:
required: false
type: string
pkg:
description: eg. `example.com@1.2.3`
type: string
dry-run:
description: dry runs do not modify bottle storage
type: boolean
default: false
test-os:
description: a JSON array of runner-names
type: string
test-container:
description: >
A JSON array of docker image names or `[null]`.
Indeed! You cannot leave this as `null` or undefined.
Sorry, GHA is not flexible enough to efficiently work around this.
type: string
complain:
type: boolean
default: false
invalidate-cloudfront:
type: boolean
default: true
secrets:
APPLE_CERTIFICATE_P12: { required: false }
APPLE_CERTIFICATE_P12_PASSWORD: { required: false }
APPLE_IDENTITY: { required: false }
GPG_KEY_ID: { required: true }
GPG_PRIVATE_KEY: { required: true }
AWS_ACCESS_KEY_ID: { required: false }
AWS_S3_BUCKET: { required: true }
AWS_SECRET_ACCESS_KEY: { required: true }
AWS_CF_DISTRIBUTION_ID: { required: true }
IPFS_API_URL: { required: false }
IPFS_API_TOKEN: { required: false }
IPFS_CLUSTER_API_URL: { required: false }
IPFS_CLUSTER_AUTH: { required: false }
env:
BREWKIT_PKGJSON: ${{ inputs.pkg }}
jobs:
build:
name: build ${{inputs.tinyname}}
runs-on: ${{ fromJSON(inputs.os) }}
container: ${{ inputs.container }}
permissions: {}
outputs:
project: ${{ steps.build.outputs.project }}
version: ${{ steps.build.outputs.version }}
platform: ${{ steps.build.outputs.platform }}
arch: ${{ steps.build.outputs.arch }}
env:
PKGX_PANTRY_PATH: ${{ github.workspace }}
PKGX_PANTRY_DIR: ${{ github.workspace }}
steps:
- uses: actions/checkout@v6
- uses: ./.github/actions/setup
with:
p12-file-base64: ${{ secrets.APPLE_CERTIFICATE_P12 }}
p12-password: ${{ secrets.APPLE_CERTIFICATE_P12_PASSWORD }}
APPLE_IDENTITY: ${{ secrets.APPLE_IDENTITY }}
- uses: pkgxdev/setup@v5
with:
PKGX_DIR: /opt
- uses: pkgxdev/brewkit/build@v1
with:
pkg: ${{ inputs.pkg }}
id: build
env:
APPLE_IDENTITY: ${{ secrets.APPLE_IDENTITY }}
- uses: styfle/cancel-workflow-action@0.13.1
if: steps.build.outputs.noop
- uses: pkgxdev/brewkit/audit@v1
with:
pkg: ${{ inputs.pkg }}
- uses: pkgxdev/brewkit/upload-build-artifact@v1
test:
name: test ${{inputs.tinyname}} ${{ matrix.container || ''}} ${{ matrix.container || '' }} ${{ join(matrix.os, '+') }}
needs: build
strategy:
matrix:
os: ${{ fromJSON(inputs.test-os) }}
container: ${{ fromJSON(inputs.test-container) }}
permissions: {}
runs-on: ${{ matrix.os }}
container: ${{ matrix.container }}
env:
PKGX_PANTRY_PATH: ${{ github.workspace }}
PKGX_PANTRY_DIR: ${{ github.workspace }}
steps:
# pkgxdev/setup no longer seeds the base, and many tests
# expect libc6-dev and possibly other base libraries.
- run: apt-get -y update && apt-get -y install build-essential
if: matrix.container == 'ubuntu'
# need to update archlinux-keyring on run
# https://bbs.archlinux.org/viewtopic.php?id=304755
- run: |
if command -v pacman; then
pacman-key --init
pacman-key --populate archlinux
pacman -Sy --noconfirm --overwrite '*' archlinux-keyring
pacman -Sy --noconfirm --overwrite '*' gcc libatomic_ops libxcrypt-compat
fi
- uses: actions/checkout@v6
- uses: ./.github/actions/setup
- uses: pkgxdev/setup@v5
- uses: pkgxdev/brewkit/download-build-artifact@v1
with:
pkg: ${{ inputs.pkg }}
- uses: pkgxdev/brewkit/test@v1
with:
pkg: ${{ inputs.pkg }}
bottle:
name: bottle (${{inputs.tinyname}}.${{matrix.compression}})
needs: [build, test]
permissions: {}
strategy:
matrix:
compression: [xz, gz]
runs-on: ubuntu-latest
env:
AWS: ${{ inputs.dry-run && 'echo' || 'aws' }}
PREFIX: ${{ needs.build.outputs.project }}/${{ needs.build.outputs.platform }}/${{ needs.build.outputs.arch }}/v${{ needs.build.outputs.version }}.tar.${{ matrix.compression }}
steps:
- uses: pkgxdev/setup@v5
- uses: actions/checkout@v6
- uses: aws-actions/configure-aws-credentials@v6
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: us-east-1
- name: import GPG key
run: echo $GPG_PRIVATE_KEY |
base64 -d |
pkgx gpg --import --batch --yes
env:
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
- uses: pkgxdev/brewkit/download-build-artifact@v1
id: dl
with:
pkg: ${{ inputs.pkg }}
platform: ${{ inputs.name }}
extract: false
- uses: pkgxdev/brewkit/bottle@v1
id: bottle
with:
file: ${{ steps.dl.outputs.filename }}
compression: ${{ matrix.compression }}
- name: gpg
run: pkgx gpg
--detach-sign
--armor
--output ${{ steps.bottle.outputs.filename }}.asc
--local-user ${{ secrets.GPG_KEY_ID }}
${{ steps.bottle.outputs.filename }}
- name: sha
run: pkgx
sha256sum
${{ steps.bottle.outputs.filename }} > ${{ steps.bottle.outputs.filename }}.sha256sum
- name: ipfs
id: ipfs
uses: ./.github/actions/ipfs
with:
bottle-file: ${{ steps.bottle.outputs.filename }}
dry-run: ${{ inputs.dry-run }}
ipfs-api-url: ${{ secrets.IPFS_API_URL }}
ipfs-api-token: ${{ secrets.IPFS_API_TOKEN }}
ipfs-cluster-api-url: ${{ secrets.IPFS_CLUSTER_API_URL }}
ipfs-cluster-auth: ${{ secrets.IPFS_CLUSTER_AUTH }}
ipfs-gateway-url: ${{ secrets.IPFS_GATEWAY_URL }}
- name: s3 put
run: |
$AWS s3 cp $FILENAME $URL
$AWS s3 cp $FILENAME.asc $URL.asc
$AWS s3 cp $FILENAME.sha256sum $URL.sha256sum
if ! test -z "$CID"; then
echo "$CID" >$FILENAME.cid
$AWS s3 cp $FILENAME.cid $URL.cid
echo "cf-paths=/$PREFIX /$PREFIX.asc /$PREFIX.sha256sum /$PREFIX.cid" >> $GITHUB_OUTPUT
else
echo "cf-paths=/$PREFIX /$PREFIX.asc /$PREFIX.sha256sum" >> $GITHUB_OUTPUT
fi
env:
FILENAME: ${{ steps.bottle.outputs.filename }}
URL: s3://${{ secrets.AWS_S3_BUCKET }}/${{ env.PREFIX }}
CID: ${{ steps.ipfs.outputs.cid }}
id: put
- name: s3 put file listing
if: ${{ matrix.compression == 'gz' }}
id: files
run: |
PREFIX=$(dirname $PREFIX)
tar tf ${{ steps.bottle.outputs.filename }} \
| grep -v '/$' \
| grep -v '^venv/' \
> $FILENAME
$AWS s3 cp $FILENAME s3://${{ secrets.AWS_S3_BUCKET }}/$PREFIX/$FILENAME
echo "cf-paths=/$PREFIX/$FILENAME" >> $GITHUB_OUTPUT
env:
FILENAME: v${{ needs.build.outputs.version }}.files.txt
- name: invalidate cloudfront
run: $AWS cloudfront create-invalidation
--distribution-id ${{ secrets.AWS_CF_DISTRIBUTION_ID }}
--paths
${{ steps.put.outputs.cf-paths }} ${{ steps.files.outputs.cf-paths }}
if: inputs.invalidate-cloudfront
publish:
name: publish ${{inputs.tinyname}} ${{ inputs.dry-run && '(dry-run)' }}
runs-on: ubuntu-latest
needs: [bottle, build]
permissions: {}
env:
AWS: ${{ inputs.dry-run && 'echo' || 'aws' }}
DIRNAME: ${{ needs.build.outputs.project }}/${{ needs.build.outputs.platform }}/${{ needs.build.outputs.arch }}
steps:
- uses: aws-actions/configure-aws-credentials@v6
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: us-east-1
- uses: pkgxdev/setup@v5
- name: generate versions.txt
run: |
if ! aws s3 cp \
s3://${{ secrets.AWS_S3_BUCKET }}/$DIRNAME/versions.txt \
./remote-versions.txt; then
touch remote-versions.txt
fi
echo "$SCRIPT" > script.ts
pkgx deno run -A script.ts ./remote-versions.txt ${{ needs.build.outputs.version }} > versions.txt
env:
# FIXME: revert to v0.18.1 since v0.19 changed deps.ts
SCRIPT: |
import SemVer, { compare } from "https://raw.githubusercontent.com/pkgxdev/libpkgx/v0.18.1/src/utils/semver.ts"
const versions = new Set(Deno.readTextFileSync(Deno.args[0]).trim().split("\n").filter(x => x))
versions.add(Deno.args[1])
const out = [...versions].map(x => new SemVer(x)).sort(compare).join("\n")
await Deno.stdout.write(new TextEncoder().encode(out.trim()))
- name: s3 put
run: $AWS s3 cp versions.txt s3://${{ secrets.AWS_S3_BUCKET }}/$DIRNAME/versions.txt
- name: invalidate cloudfront
run: $AWS cloudfront create-invalidation
--distribution-id ${{ secrets.AWS_CF_DISTRIBUTION_ID }}
--paths
/$DIRNAME/versions.txt
if: inputs.invalidate-cloudfront
complain:
needs: bottle
if: failure() && !inputs.dry-run && inputs.complain
runs-on: ubuntu-latest
permissions:
issues: write
steps:
- uses: actions/checkout@v6
- uses: ./.github/actions/complain
with:
pkg: ${{ fromJSON(inputs.pkg).project }}=${{ fromJSON(inputs.pkg).version.value }}