-
Notifications
You must be signed in to change notification settings - Fork 1.4k
245 lines (225 loc) · 7.98 KB
/
cd.yml
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
name: CD
on:
push:
branches:
- main
paths:
- README.md
workflow_dispatch:
concurrency:
group: distribute
cancel-in-progress: true
jobs:
check:
permissions:
actions: write # for cancel-action
runs-on: ubuntu-latest
outputs:
version: ${{ steps.tea.outputs.version }}
steps:
- uses: actions/checkout@v3
- uses: teaxyz/setup@v0
id: tea
- name: sanity check
run: |
test -n "$(echo ${{ steps.tea.outputs.version }} | cut -f1 -d.)"
test -n "$(echo ${{ steps.tea.outputs.version }} | cut -f2 -d.)"
test -n "$(echo ${{ steps.tea.outputs.version }} | cut -f3 -d.)"
- id: rev-parse
name: did we already publish this version?
run: |
# fetch tags since actions/checkout is a shallow checkout
git fetch --prune --unshallow --tags
if git show-ref --tags v${{ steps.tea.outputs.version }} --quiet; then
echo "result=cancel" >> $GITHUB_OUTPUT
else
echo "result=commence" >> $GITHUB_OUTPUT
fi
- uses: andymckay/[email protected]
if: ${{ steps.rev-parse.outputs.result == 'cancel' }}
qa:
# run tests on all our runners since we’ve had issues in the past where
# subtle differences weren’t caught and pantry builds started failing :/
needs: [check]
runs-on: ${{ matrix.os }}
strategy:
matrix:
os:
- [self-hosted, macOS, ARM64]
- [self-hosted, linux, ARM64]
- [self-hosted, macOS, X64]
- [self-hosted, linux, X64]
steps:
- uses: actions/checkout@v3
- uses: teaxyz/setup@v0
- run: deno task test
# we compile here so we can attach binaries to the release itself
# we do this because people expect that, and will be confused otherwise
# and we want people to be able to just grab the single binaries as
# they wish
compile:
needs: [qa, check, bundle-src]
permissions:
contents: read
actions: write
strategy:
matrix:
platform:
- os: macos-latest
build-id: darwin+x86-64
- os: ubuntu-latest
build-id: linux+x86-64
- os: [self-hosted, macOS, ARM64]
build-id: darwin+aarch64
- os: [self-hosted, linux, ARM64]
build-id: linux+aarch64
runs-on: ${{ matrix.platform.os }}
name: ${{ matrix.platform.build-id }}
steps:
- uses: actions/download-artifact@v3
with:
name: srcs
- run: tar xJf tea-${{ needs.check.outputs.version }}.tar.xz --strip-components=1
- uses: teaxyz/cli/.github/actions/cache@v0 # avoids sporadic 500s from deno’s CDN
- uses: teaxyz/setup@v0
- run: deno task compile
- uses: teaxyz/brewkit/actions/setup-codesign@v0
if: startsWith(matrix.platform.build-id, 'darwin+')
with:
p12-file-base64: ${{ secrets.APPLE_CERTIFICATE_P12 }}
p12-password: ${{ secrets.APPLE_CERTIFICATE_P12_PASSWORD }}
# codesign always fails for deno binaries, even though it
# signs fine. See https://github.com/denoland/deno/issues/575
- run: codesign --sign "$APPLE_IDENTITY" --force --preserve-metadata=entitlements,requirements,flags,runtime ./tea || true
env:
APPLE_IDENTITY: ${{ secrets.APPLE_IDENTITY }}
- name: sanity check
run: test "$(./tea --version)" = "tea ${{ needs.check.outputs.version }}"
- run: tar cJf tea-${{ needs.check.outputs.version }}+${{ matrix.platform.build-id }}.tar.xz tea
- name: GPG sign archive
run: |
tea gpg-agent --daemon || true
echo $GPG_PRIVATE_KEY | \
base64 -d | \
tea gpg --import --batch --yes
tea gpg \
--detach-sign --armor \
--local-user $GPG_KEY_ID \
tea-${{ needs.check.outputs.version }}+${{ matrix.platform.build-id }}.tar.xz
env:
GPG_KEY_ID: ${{ secrets.GPG_KEY_ID }}
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
- uses: actions/upload-artifact@v3
with:
name: binaries
path: |
tea-${{ needs.check.outputs.version }}+${{ matrix.platform.build-id }}.tar.xz
tea-${{ needs.check.outputs.version }}+${{ matrix.platform.build-id }}.tar.xz.asc
if-no-files-found: error
bundle-src:
runs-on: ubuntu-latest
needs: [qa, check]
env:
FILENAME: tea-${{ needs.check.outputs.version }}
steps:
- uses: actions/checkout@v3
with:
path: ${{ env.FILENAME }}
- name: Clean
run: rm -rf ${{ env.FILENAME }}/.github .gitpod.yml
- name: Stamp Version
run: echo "export default function() { return '${{ needs.check.outputs.version }}' }" > $FILENAME/src/hooks/useVersion.ts
- name: Include GPG pubkey
run: echo $PUBKEY | base64 -d > $FILENAME/tea.xyz.pub.asc
env:
PUBKEY: ${{ secrets.GPG_PUBLIC_KEY }}
- run: tar cJf $FILENAME.tar.xz $FILENAME
- uses: actions/upload-artifact@v3
with:
name: srcs
path: ${{ env.FILENAME }}.tar.xz
if-no-files-found: error
release:
permissions:
contents: write
needs: [check, compile, bundle-src]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/download-artifact@v3
- uses: softprops/action-gh-release@v1
with:
tag_name: v${{ needs.check.outputs.version }}
files: |
binaries/*
srcs/*
fail_on_unmatched_files: true
generate_release_notes: true
token: ${{secrets.TEMP_JACOBS_GITHUB_PAT}} # using our own PAT so other workflows run
bump-tap:
needs: [release]
runs-on: ubuntu-latest
steps:
- uses: aurelien-baudet/workflow-dispatch@v2
with:
workflow: bump.yml
repo: teaxyz/homebrew-pkgs
ref: main
token: ${{secrets.TEMP_JACOBS_GITHUB_PAT}}
# these are the binaries that curl https://tea.xyz/platform/arch/ download
upload-binaries:
needs: [release]
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v3
with:
name: binaries
path: binaries
- uses: aws-actions/configure-aws-credentials@v1
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: Unpack Binaries
working-directory: binaries
run: |
for filename in *.tar.xz; do
tar xJf $filename
result="${filename#*+}"
result="${result%.tar.xz}"
mv tea tea-$result
rm $filename
done
- name: Upload to S3
run: |
aws s3 cp binaries/tea-darwin+aarch64 s3://www.tea.xyz/Darwin/arm64 $FLAGS
aws s3 cp binaries/tea-darwin+x86-64 s3://www.tea.xyz/Darwin/x86_64 $FLAGS
# Both because, iirc, some linuxen are inconsistent
aws s3 cp binaries/tea-linux+aarch64 s3://www.tea.xyz/Linux/arm64 $FLAGS
aws s3 cp binaries/tea-linux+aarch64 s3://www.tea.xyz/Linux/aarch64 $FLAGS
aws s3 cp binaries/tea-linux+x86-64 s3://www.tea.xyz/Linux/x86_64 $FLAGS
env:
FLAGS: --metadata-directive REPLACE --cache-control no-cache,must-revalidate
- name: Invalidate CloudFront
run:
aws cloudfront create-invalidation
--distribution-id ${{ secrets.AWS_CF_DISTRIBUTION_ID }}
--paths $STATIC_PATHS
env:
STATIC_PATHS: >-
/Darwin/arm64
/Darwin/x86_64
/Linux/arm64
/Linux/aarch64
/Linux/x86_64
smoke-teaxyz-setup-github-action:
needs: [upload-binaries]
runs-on: ubuntu-latest
steps:
- uses: aurelien-baudet/workflow-dispatch@v2
with:
workflow: smoke-test.yml
repo: teaxyz/setup
ref: main
token: ${{secrets.TEMP_JACOBS_GITHUB_PAT}}
wait-for-completion: false