-
Notifications
You must be signed in to change notification settings - Fork 12
274 lines (253 loc) · 8.35 KB
/
build-package.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
263
264
265
266
267
268
269
270
271
272
273
274
name: Build package
on:
workflow_call:
inputs:
crate:
description: Crate to release
required: true
type: string
version:
description: Version to release
required: true
type: string
target_arch:
description: Target to build against
required: true
type: string
build_os:
description: The OS to use for building
required: true
type: string
branch:
description: The branch which is checked out
required: true
type: string
features:
description: Features to enable
default: ""
type: string
no_default_features:
description: Disable default features
default: ""
type: string
always_build:
description: Always build even if it's already present, set to 1 to enable this
default: ""
type: string
skip_upload:
description: Skip upload
default: ""
type: string
workflow_dispatch:
inputs:
crate:
description: Crate to release
required: true
type: string
version:
description: Version to release
required: true
type: string
target_arch:
description: Target to build against
required: true
type: string
build_os:
description: The OS to use for building
required: true
type: string
branch:
description: The branch which is checked out
required: true
type: string
features:
description: Features to enable
default: ""
type: string
no_default_features:
description: Disable default features
default: ""
type: string
always_build:
description: Always build even if it's already present, set to 1 to enable this
default: ""
type: string
skip_upload:
description: Skip upload
default: ""
type: string
concurrency:
group: build-package-${{ github.event.inputs.crate }}-${{ github.event.inputs.version }}-${{ github.event.inputs.target_arch }}
env:
CRATE: ${{ inputs.crate }}
TARGET_ARCH: ${{ inputs.target_arch }}
VERSION: ${{ inputs.version }}
FEATURES: ${{ inputs.features }}
NO_DEFAULT_FEATURES: ${{ inputs.NO_DEFAULT_FEATURES }}
BUILD_DIR: ${{ github.workspace }}/built.d
jobs:
build-popular-package:
name: build-popular-package-${{ inputs.crate }}-${{ inputs.version }}-${{ inputs.target_arch }}-${{ inputs.features }}
runs-on: ${{ inputs.build_os }}
permissions: {}
defaults:
run:
shell: bash
steps:
- name: Checkout trigger commit
uses: actions/checkout@v4
with:
persist-credentials: false
path: trigger
- name: Checkout main repo
uses: actions/checkout@v4
with:
persist-credentials: false
ref: ${{ inputs.branch }}
path: cargo-quickinstall
- name: Print inputs
run: |
echo $CRATE
echo $VERSION
echo $TARGET_ARCH
echo $FEATURES
- name: Install latest rust
run: rustup toolchain install stable --no-self-update --profile minimal
- name: build package
env:
ALWAYS_BUILD: ${{ inputs.always_build }}
TEMPDIR: ${{ env.BUILD_DIR }}
run: |
set -euxo pipefail
# `tar` does not understand mixed forward and backslashes, but mkdir does.
# Try coercing it into a single style?
mkdir -p "$TEMPDIR"
pushd "$TEMPDIR"
TEMPDIR="$PWD"
popd
cargo-quickinstall/build-version.sh "$CRATE"
touch "$TEMPDIR/dummy-file"
ls "$TEMPDIR"
# At this point, I don't think that you can really trust anything on the system anymore.
# I'm not sure whether the js actions runtime is also affected by this.
# TODO: try breaking things so that uploads don't work.
- name: Upload run-local binary artifact
uses: actions/upload-artifact@v4
with:
name: built-${{ inputs.build_os }}
path: ${{ env.BUILD_DIR }}
if-no-files-found: error
upload-popular-package:
name: Upload
needs: build-popular-package
runs-on: ubuntu-22.04
defaults:
run:
shell: bash
env:
BUILD_ARCHIVE: ${{ github.workspace }}/built.d/${{ inputs.crate }}-${{ inputs.version }}-${{ inputs.target_arch }}.tar.gz
SIG_FILENAME: ${{ github.workspace }}/built.d/${{ inputs.crate }}-${{ inputs.version }}-${{ inputs.target_arch }}.tar.gz.sig
steps:
- name: Checkout trigger commit
uses: actions/checkout@v4
with:
ssh-key: ${{ secrets.CRONJOB_DEPLOY_KEY }}
persist-credentials: true
path: trigger
- name: Checkout main repo
uses: actions/checkout@v4
with:
persist-credentials: false
# TODO: maybe this should be main or configurable or something?
ref: ${{ inputs.branch }}
path: cargo-quickinstall
- name: Download binary artifact
uses: actions/download-artifact@v4
with:
name: built-${{ inputs.build_os }}
# TODO: check that we it can't write anywhere other than built.d
path: ${{ env.BUILD_DIR }}
- name: Check if tarball exists
id: check_files
uses: andstor/file-existence-action@v3
with:
files: ${{ env.BUILD_ARCHIVE }}
- name: Cancel if no tarball
if: steps.check_files.outputs.files_exists == 'false'
uses: andymckay/[email protected]
- name: Wait for cancellation signal if no tarball
if: steps.check_files.outputs.files_exists == 'false'
run: |
sleep 1m
exit 1
- name: Install minisign
run: |
set -euxo pipefail
cd /tmp
curl -L "$URL" | tar -xz
sudo mv minisign-linux/x86_64/minisign /usr/local/bin
env:
URL: https://github.com/jedisct1/minisign/releases/download/0.11/minisign-0.11-linux.tar.gz
- name: Sign the tarball
run: |
echo "$MINISIGN_PRIVATE_KEY" > /tmp/minisign-key
minisign -S -s /tmp/minisign-key -x $SIG_FILENAME -m $BUILD_ARCHIVE
env:
MINISIGN_PRIVATE_KEY: ${{ secrets.MINISIGN_PRIVATE_KEY }}
- name: Tag release
if: "! inputs.skip_upload"
run: |
(
set -euxo pipefail
cd trigger
if ! ../cargo-quickinstall/create_and_upload_tag.sh $CRATE-$VERSION; then
echo "$CRATE-$VERSION tag already exists"
fi
)
- name: Releasing assets in new release format
if: "! inputs.skip_upload"
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
tag: ${{ inputs.crate }}-${{ inputs.version }}
release_name: ${{ inputs.crate }}-${{ inputs.version }}
body: build ${{ inputs.crate }}@${{ inputs.version }}
file: ${{ env.BUILD_ARCHIVE }}
- name: Releasing assets signature in new release format
if: "! inputs.skip_upload"
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
tag: ${{ inputs.crate }}-${{ inputs.version }}
release_name: ${{ inputs.crate }}-${{ inputs.version }}
body: build ${{ inputs.crate }}@${{ inputs.version }}
file: ${{ env.SIG_FILENAME }}
- name: Upload signature
uses: actions/upload-artifact@v4
with:
name: signature
path: ${{ env.SIG_FILENAME }}
if-no-files-found: error
build-popular-package-failure:
needs:
- build-popular-package
if: ${{ failure() }}
runs-on: ubuntu-latest
defaults:
run:
shell: bash
steps:
- name: Checkout trigger branch
uses: actions/checkout@v4
with:
ssh-key: ${{ secrets.CRONJOB_DEPLOY_KEY }}
persist-credentials: true
ref: trigger/${{ inputs.target_arch }}
path: trigger
- name: Checkout trigger commit
uses: actions/checkout@v4
with:
persist-credentials: false
path: cargo-quickinstall
- name: Record failure
run: ${{ github.workspace }}/cargo-quickinstall/add-exclude.sh ${{ github.workspace }}/trigger