-
Notifications
You must be signed in to change notification settings - Fork 1
262 lines (208 loc) · 9.54 KB
/
ipso-cli.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
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
name: "ipso-cli"
on:
push:
branches:
- main
tags:
- "v*"
env:
NIX_PUBLIC_KEY: "ipso-binary-cache-1:UMRLNOKcCsb/a2dBhtcZhRZP4RN8yIDsSUwHTObu2w4="
# Note: these values are duplicated in the `UPLOAD_TO_CACHE` script.
BINARY_CACHE_BUCKET: "ipso-binary-cache"
BINARY_CACHE_ENDPOINT: "7065dc7f7d1813a29036535b4c4f4014.r2.cloudflarestorage.com"
# Avoid [rate
# limiting](https://discourse.nixos.org/t/flakes-provide-github-api-token-for-rate-limiting/18609)
# by allowing Nix to make authenticated GitHub requests.
NIX_CONFIG: "access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}"
# The version of ipso to use for CI scripts that are written in the language.
CI_IPSO_VERSION: "v0.5"
jobs:
build-linux:
runs-on: ubuntu-latest
env:
POST_BUILD_HOOK: ".github/workflows/postBuildHook"
UPLOAD_TO_CACHE: ".github/workflows/uploadToCache"
steps:
- uses: actions/[email protected]
- uses: cachix/install-nix-action@v15
# Used by `uploadToCache` to sign store paths.
- run: "sudo bash -c 'echo \"${{ secrets.NIX_SIGNING_KEY }}\" > /run/nix-signing-key'"
# Grants the Nix daemon access to the bucket, which allows `nix build` to
# authenticate with the binary cache bucket and fetch cache items.
- run: sudo mkdir /root/.aws
- run: "sudo bash -c 'echo -e \"[default]\naws_access_key_id=${{ secrets.AWS_ACCESS_KEY_ID }}\naws_secret_access_key=${{ secrets.AWS_SECRET_ACCESS_KEY }}\" > /root/.aws/credentials'"
# Grants the runner access to the bucket, which allows `pueue` to
# authenticate with the binary cache bucket when pushing signed cache items.
- run: sudo mkdir ~/.aws
- run: sudo chown runner ~/.aws
- run: "echo -e \"[default]\naws_access_key_id=${{ secrets.AWS_ACCESS_KEY_ID}}\naws_secret_access_key=${{ secrets.AWS_SECRET_ACCESS_KEY }}\" > ~/.aws/credentials"
# Allow the Nix daemon to execute the post-build-hook script.
- run: "sudo chmod +x $POST_BUILD_HOOK"
# Used in `postBuildHook`.
- run: sudo cp $UPLOAD_TO_CACHE /run/uploadToCache
# See [note: installing Ipso binary]
- name: Install Ipso binary
run: |
mkdir -p $HOME/bin
curl -L \
"https://github.com/LightAndLight/ipso/releases/download/$CI_IPSO_VERSION/ipso-linux-x86_64" \
> $HOME/bin/ipso
chmod +x $HOME/bin/ipso
echo "$HOME/bin" >> $GITHUB_PATH
- run: nix profile install nixpkgs#pueue
# See [note: nix profile install not adding to PATH]
- run: echo "$(readlink ~/.nix-profile)/bin" >> $GITHUB_PATH
- run: pueued -d
- run: >
nix build
--extra-substituters "s3://$BINARY_CACHE_BUCKET?scheme=https&endpoint=$BINARY_CACHE_ENDPOINT"
--extra-trusted-public-keys "$NIX_PUBLIC_KEY"
--post-build-hook "$GITHUB_WORKSPACE/$POST_BUILD_HOOK"
-o result
- name: wait for uploads to finish
if: always()
run: pueue wait
- name: log all uploads
if: always()
run: pueue log --json | jq '.[].task.original_command' -r
- name: log failed uploads
if: always()
run: pueue log --json | jq 'to_entries[] | select(.value.task.status.Done != "Success") | .key' -r | xargs -r pueue log
- name: check uploads succeeded
if: always()
run: "[ \"$(pueue log --json | jq 'to_entries[] | select(.value.task.status.Done != \"Success\") | .key' -r)\" == \"\" ]"
- run: cp result-bin/bin/ipso ipso-linux-x86_64
- uses: actions/upload-artifact@v3
with:
name: ipso-linux-x86_64
path: ipso-linux-x86_64
build-macos:
runs-on: macos-latest
env:
POST_BUILD_HOOK: ".github/workflows/postBuildHookMacos"
UPLOAD_TO_CACHE: ".github/workflows/uploadToCacheMacos"
steps:
- uses: actions/[email protected]
- uses: cachix/install-nix-action@v15
# Used by `uploadToCache` to sign store paths.
- run: "sudo bash -c 'echo \"${{ secrets.NIX_SIGNING_KEY }}\" > /var/run/nix-signing-key'"
# Grants the Nix daemon access to the bucket, which allows `nix build` to
# authenticate with the binary cache bucket and fetch cache items.
- run: sudo mkdir /var/root/.aws
- run: "sudo bash -c 'echo -e \"[default]\naws_access_key_id=${{ secrets.AWS_ACCESS_KEY_ID }}\naws_secret_access_key=${{ secrets.AWS_SECRET_ACCESS_KEY }}\" > /var/root/.aws/credentials'"
# Grants the runner access to the bucket, which allows `pueue` to
# authenticate with the binary cache bucket when pushing signed cache items.
- run: sudo mkdir ~/.aws
- run: sudo chown runner ~/.aws
- run: "echo -e \"[default]\naws_access_key_id=${{ secrets.AWS_ACCESS_KEY_ID}}\naws_secret_access_key=${{ secrets.AWS_SECRET_ACCESS_KEY }}\" > ~/.aws/credentials"
# Allow the Nix daemon to execute the post-build-hook script.
- run: "sudo chmod +x $POST_BUILD_HOOK"
# Used in `postBuildHookMacos`.
- run: sudo cp $UPLOAD_TO_CACHE /var/run/uploadToCache
# See [note: installing Ipso binary]
- name: Install Ipso binary
run: |
mkdir -p $HOME/bin
curl -L \
"https://github.com/LightAndLight/ipso/releases/download/$CI_IPSO_VERSION/ipso-macos-x86_64" \
> $HOME/bin/ipso
chmod +x $HOME/bin/ipso
echo "$HOME/bin" >> $GITHUB_PATH
- run: nix profile install nixpkgs#pueue
# See [note: nix profile install not adding to PATH]
- run: echo "$(readlink ~/.nix-profile)/bin" >> $GITHUB_PATH
- run: pueued -d
- run: >
nix build
--extra-substituters "s3://$BINARY_CACHE_BUCKET?scheme=https&endpoint=$BINARY_CACHE_ENDPOINT"
--extra-trusted-public-keys "$NIX_PUBLIC_KEY"
--post-build-hook "$GITHUB_WORKSPACE/$POST_BUILD_HOOK"
-o result
- name: wait for uploads to finish
if: always()
run: pueue wait
- name: log all uploads
if: always()
run: pueue log --json | jq '.[].task.original_command' -r
- name: log failed uploads
if: always()
run: pueue log --json | jq 'to_entries[] | select(.value.task.status.Done != "Success") | .key' -r | xargs -r pueue log
- name: check uploads succeeded
if: always()
run: "[ \"$(pueue log --json | jq 'to_entries[] | select(.value.task.status.Done != \"Success\") | .key' -r)\" == \"\" ]"
- run: cp result-bin/bin/ipso ipso-macos-x86_64
- uses: actions/upload-artifact@v3
with:
name: ipso-macos-x86_64
path: ipso-macos-x86_64
release:
needs: [build-linux, build-macos]
if: startsWith(github.ref, 'refs/tags/v') && github.event_name == 'push'
runs-on: ubuntu-latest
env:
POST_BUILD_HOOK: ".github/workflows/postBuildHook"
UPLOAD_TO_CACHE: ".github/workflows/uploadToCache"
steps:
- uses: actions/[email protected]
# Nix setup
- uses: actions/[email protected]
- uses: cachix/install-nix-action@v15
# Used by `uploadToCache` to sign store paths.
- run: "sudo bash -c 'echo \"${{ secrets.NIX_SIGNING_KEY }}\" > /run/nix-signing-key'"
# Grants the Nix daemon access to the bucket, which allows `nix build` to
# authenticate with the binary cache bucket and fetch cache items.
- run: sudo mkdir /root/.aws
- run: "sudo bash -c 'echo -e \"[default]\naws_access_key_id=${{ secrets.AWS_ACCESS_KEY_ID }}\naws_secret_access_key=${{ secrets.AWS_SECRET_ACCESS_KEY }}\" > /root/.aws/credentials'"
# Grants the runner access to the bucket, which allows `pueue` to
# authenticate with the binary cache bucket when pushing signed cache items.
- run: sudo mkdir ~/.aws
- run: sudo chown runner ~/.aws
- run: "echo -e \"[default]\naws_access_key_id=${{ secrets.AWS_ACCESS_KEY_ID}}\naws_secret_access_key=${{ secrets.AWS_SECRET_ACCESS_KEY }}\" > ~/.aws/credentials"
# Allow the Nix daemon to execute the post-build-hook script.
- run: "sudo chmod +x $POST_BUILD_HOOK"
# Used in `postBuildHook`.
- run: sudo cp $UPLOAD_TO_CACHE /run/uploadToCache
# See [note: installing Ipso binary]
- name: Install Ipso binary
run: |
mkdir -p $HOME/bin
curl -L \
"https://github.com/LightAndLight/ipso/releases/download/$CI_IPSO_VERSION/ipso-linux-x86_64" \
> $HOME/bin/ipso
chmod +x $HOME/bin/ipso
echo "$HOME/bin" >> $GITHUB_PATH
- run: nix profile install nixpkgs#pueue
# See [note: nix profile install not adding to PATH]
- run: echo "$(readlink ~/.nix-profile)/bin" >> $GITHUB_PATH
- run: pueued -d
- name: Check release version
run: >
nix shell
--extra-substituters "s3://$BINARY_CACHE_BUCKET?scheme=https&endpoint=$BINARY_CACHE_ENDPOINT"
--extra-trusted-public-keys "$NIX_PUBLIC_KEY"
--post-build-hook "$GITHUB_WORKSPACE/$POST_BUILD_HOOK"
-c .github/workflows/checkReleaseVersion
- uses: actions/download-artifact@v3
with:
name: ipso-linux-x86_64
- uses: actions/download-artifact@v3
with:
name: ipso-macos-x86_64
- name: wait for uploads to finish
if: always()
run: pueue wait
- name: log all uploads
if: always()
run: pueue log --json | jq '.[].task.original_command' -r
- name: log failed uploads
if: always()
run: pueue log --json | jq 'to_entries[] | select(.value.task.status.Done != "Success") | .key' -r | xargs -r pueue log
- name: check uploads succeeded
if: always()
run: "[ \"$(pueue log --json | jq 'to_entries[] | select(.value.task.status.Done != \"Success\") | .key' -r)\" == \"\" ]"
- uses: softprops/action-gh-release@v1
with:
name: ${{ github.ref_name }}
files: |
ipso-linux-x86_64
ipso-macos-x86_64