-
Notifications
You must be signed in to change notification settings - Fork 0
/
action.yml
274 lines (244 loc) · 9.13 KB
/
action.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: Create a binary artifact
description: |
Create a binary artifact for a cargo crate
author: "rustic-rs maintainers"
inputs:
toolchain:
description: |
The rust toolchain to use
required: true
target:
description: |
The target to build for
required: true
use-cross:
description: |
Use cross to build the binary
required: false
default: "false"
describe-tag-suffix:
description: |
Suffix for the git describe tag
required: false
default: ""
binary-postfix:
description: |
Postfix for the binary name
required: false
default: ""
os:
description: |
The operating system to build for
required: true
binary-name:
description: |
The name of the binary
required: true
package-secondary-name:
description: |
The secondary name for the package
required: true
github-token:
description: |
The github token to use
required: true
gpg-release-private-key:
description: |
The private key to use for signing the release
required: false
gpg-passphrase:
description: |
The passphrase to use for signing the release
required: false
architecture:
description: |
The architecture to build for
required: false
default: ""
sign-release:
description: |
Sign the release
required: true
default: "false"
hash-release:
description: |
Hash the release
required: true
default: "false"
github-ref:
description: |
The github ref in use
required: true
use-project-version:
description: |
Get the project version
required: false
default: "false"
use-release-profile:
description: |
Use the release profile to build the binary
required: false
default: "false"
rsign-release-private-key:
description: |
The rsign private key to use for signing the release
required: false
rsign-passphrase:
description: |
The rsign passphrase to use for signing the release
required: false
use-tag-version:
description: |
Use the tag as version in filename for a release
required: false
default: "false"
runs:
using: "composite"
steps:
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@1482605bfc5719782e1267fd0c0cc350fe7646b8 # v1
with:
toolchain: ${{ inputs.toolchain }}
targets: ${{ inputs.target }}
- name: install compiler
shell: bash
if: inputs.target == 'x86_64-unknown-linux-musl'
run: |
sudo apt update
sudo apt-get install -y musl-tools
# FIXME: Brew compilation doesn't work currently?
# - name: install compiler on macos
# shell: bash
# if: inputs.target == 'x86_64-apple-darwin' && inputs.use-cross == 'false'
# run: |
# brew install michaeleisel/zld/zld
# Doesn't work with cargo auditable build
# - name: install mold linker on linux gnu
# if: inputs.target == 'x86_64-unknown-linux-gnu' && inputs.use-cross == 'false'
# uses: rui314/setup-mold@v1
- name: install cargo-auditable for non-cross builds
if: inputs.use_cross != 'true'
uses: taiki-e/install-action@a9ad291c84ac90f1efe474097e3563d80d7c1cdf # v2
with:
tool: cargo-auditable,cargo-audit
- uses: Swatinem/rust-cache@d30f1144e884b1fe579845ed7a339c640dff522e # v2
with:
key: ${{ inputs.target }}
- name: install rsign2 for signing binaries
uses: taiki-e/install-action@a9ad291c84ac90f1efe474097e3563d80d7c1cdf # v2
if: inputs.sign-release == 'true'
with:
tool: rsign2
- uses: Swatinem/rust-cache@d30f1144e884b1fe579845ed7a339c640dff522e # v2
with:
key: ${{ inputs.target }}
- name: Set Version
if: inputs.use-project-version == 'true'
shell: bash
run: |
echo "PROJECT_VERSION=$(git describe --tags)${{ inputs.describe-tag-suffix }}" >> $GITHUB_ENV
- name: Use win config
shell: bash
if: inputs.target == 'x86_64-pc-windows-msvc'
run: |
cp -T ${GITHUB_ACTION_PATH:?}/.config/config-win.toml ${GITHUB_WORKSPACE:?}/.cargo/config.toml
- name: Use linux config
shell: bash
if: inputs.target == 'x86_64-unknown-linux-gnu' && inputs.use-cross == 'false'
run: |
cp -T ${GITHUB_ACTION_PATH:?}/.config/config-linux.toml ${GITHUB_WORKSPACE:?}/.cargo/config.toml
- name: Use darwin config
shell: bash
if: inputs.target == 'x86_64-apple-darwin' && inputs.use-cross == 'false'
run: |
cp ${GITHUB_ACTION_PATH:?}/.config/config-darwin.toml ${GITHUB_WORKSPACE:?}/.cargo/config.toml
- name: Cargo build
uses: ClementTsang/cargo-action@a211c79cf22973eb590277586fbea20269ca3ca0 # v0 (attention: this should be double checked for security issues)
if: inputs.use-cross == 'true'
with:
command: build
use-cross: ${{ inputs.use-cross }}
toolchain: ${{ inputs.toolchain }}
args: --release --target ${{ inputs.target }}
- name: Cargo auditable build
uses: ClementTsang/cargo-action@a211c79cf22973eb590277586fbea20269ca3ca0 # v0 (attention: this should be double checked for security issues)
if: inputs.use-cross == 'false'
with:
command: auditable
use-cross: ${{ inputs.use-cross }}
toolchain: ${{ inputs.toolchain }}
args: build --release --target ${{ inputs.target }}
- name: Determining Release name
shell: bash
id: package-name
run: |
if [[ ${{ inputs.use-tag-version }} == 'false' ]]; then
PACKAGE_NAME=${{ inputs.binary-name }}-${{ inputs.package-secondary-name }}.tar.gz
else
PACKAGE_NAME=${{ inputs.binary-name }}-${{ env.PROJECT_VERSION }}-${{ inputs.package-secondary-name }}.tar.gz
fi
echo "name=$PACKAGE_NAME" >> $GITHUB_OUTPUT
- name: Copy assets
shell: bash
id: copy-assets
run: |
if [[ ${{ inputs.use-tag-version }} == 'false' ]]; then
WORKING_DIR=${{ inputs.binary-name }}-${{ inputs.target }}
else
WORKING_DIR=${{ inputs.binary-name }}-${{ env.PROJECT_VERSION }}-${{ inputs.target }}
fi
mkdir -p $WORKING_DIR
# We need to account for the fact that the scheduler has two binaries
if [[ ${{ inputs.binary-name }} == 'rustic-scheduler' ]]; then
cp -a target/${{ inputs.target }}/release/${{ inputs.binary-name }}-server${{ inputs.binary-postfix }} $WORKING_DIR
cp -a target/${{ inputs.target }}/release/${{ inputs.binary-name }}-client${{ inputs.binary-postfix }} $WORKING_DIR
else
cp -a target/${{ inputs.target }}/release/${{ inputs.binary-name }}${{ inputs.binary-postfix }} $WORKING_DIR
fi
cp -a config $WORKING_DIR/config
echo "working_dir=$WORKING_DIR" >> $GITHUB_OUTPUT
- name: Create package
shell: bash
run: |
RELEASE_NAME=${{ steps.package-name.outputs.name }}
# FIXME: This doesn't work with the current version of self-update
# See https://github.com/jaemk/self_update/issues/122
# tar czvf $RELEASE_NAME ${{ steps.copy-assets.outputs.working_dir }}/*
# FIXME: We actually need to implement the fix from above issue, when it's available
# Then after a few versions we should be able to remove the workaround below.
# Hacky workaround to only pack the binary and the config without the parent directory
cd ${{ steps.copy-assets.outputs.working_dir }} && tar czvf ../$RELEASE_NAME * && cd -
- name: Create SHA256
shell: bash
if: inputs.hash-release == 'true'
run: |
RELEASE_NAME=${{ steps.package-name.outputs.name }}
if [[ ${{ inputs.os }} == 'Windows' ]]; then
certutil -hashfile $RELEASE_NAME sha256 | grep -E [A-Fa-f0-9]{64} > $RELEASE_NAME.sha256
else
shasum -a 256 $RELEASE_NAME > $RELEASE_NAME.sha256
fi
- name: Create GPG signature
shell: bash
if: inputs.sign-release == 'true'
run: |
RELEASE_NAME=${{ steps.package-name.outputs.name }}
echo "${{ inputs.gpg-release-private-key }}" > private.key
echo "${{ inputs.gpg-passphrase }}" | gpg --pinentry-mode=loopback \
--passphrase-fd 0 --import private.key
echo "${{ inputs.gpg-passphrase }}" | gpg --pinentry-mode=loopback \
--passphrase-fd 0 --local-user 12B7166D9FD59124416952E34018C5DE3BF8C081 \
--armor --output $RELEASE_NAME.asc --detach-sign $RELEASE_NAME
- name: Create Minisign/rsign2 signature
shell: bash
if: inputs.sign-release == 'true'
run: |
RELEASE_NAME=${{ steps.package-name.outputs.name }}
echo "${{ inputs.rsign-release-private-key }}" > private.key
### FIXME: Add password to key when input from stdin is available https://github.com/jedisct1/rsign2/issues/26
rsign sign -W -t "Signed by rustic Maintainers" -x $RELEASE_NAME.sig -s private.key $RELEASE_NAME
- name: Storing package as artefact
uses: actions/upload-artifact@cf8714cfeaba5687a442b9bcb85b29e23f468dfa # v4
with:
name: binary-${{ inputs.target }}
path: ${{ steps.package-name.outputs.name }}*