13
13
steps :
14
14
- name : Create artifacts directory
15
15
run : mkdir artifacts
16
-
17
16
- name : Get the release version from the tag
18
17
if : env.VERSION == ''
19
18
run : |
@@ -23,16 +22,12 @@ jobs:
23
22
else
24
23
echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
25
24
fi
26
-
27
25
- name : Validate version environment variable
28
- run : |
29
- echo "Version being built against is version ${{ env.VERSION }}"!
30
-
26
+ run : echo "Version being built against is version ${{ env.VERSION }}"!
31
27
- name : Save version number to artifact
32
28
run : echo "${{ env.VERSION }}" > artifacts/release-version
33
-
34
29
- name : Upload artifacts
35
- uses : actions/upload-artifact@v1
30
+ uses : actions/upload-artifact@v3
36
31
with :
37
32
name : artifacts
38
33
path : artifacts
@@ -46,27 +41,39 @@ jobs:
46
41
strategy :
47
42
fail-fast : false
48
43
matrix :
49
- rust : [stable]
44
+ # prettier-ignore
50
45
job :
51
- - { name: "macOS-arm64", os: "macOS-latest", target: "aarch64-apple-darwin", artifact_prefix: "macos-arm64", use-cross: true }
52
- - { name: "macOS-amd64", os: "macOS-latest", target: "x86_64-apple-darwin", artifact_prefix: "macos" }
53
- - { name: "windows-amd64", os: "windows-latest", target: "x86_64-pc-windows-msvc", artifact_prefix: "windows" }
54
- - { name: "linux-gnu", os: "ubuntu-latest", target: "x86_64-unknown-linux-gnu", artifact_prefix: "linux", }
55
- # seems impossible to build static musl binaries due to XCB dependency. See https://github.com/rust-lang/rust/issues/116348
56
- # { name: "linux-musl", os: "ubuntu-latest", target: "x86_64-unknown-linux-musl", artifact_prefix: "linux-musl", }
57
- - { name: "aarch64-gnu", os: "ubuntu-latest", target: "aarch64-unknown-linux-gnu", artifact_prefix: "aarch64-gnu", use-cross: true, test-bin: "--bin jwtui" }
58
- - { name: "aarch64-musl", os: "ubuntu-latest", target: "aarch64-unknown-linux-musl", artifact_prefix: "aarch64-musl", use-cross: true, test-bin: "--bin jwtui" }
59
- - { name: "arm-gnu", os: "ubuntu-latest", target: "arm-unknown-linux-gnueabihf", artifact_prefix: "arm-gnu", use-cross: true, test-bin: "--bin jwtui" }
60
- - { name: "arm-musl", os: "ubuntu-latest", target: "arm-unknown-linux-musleabihf", artifact_prefix: "arm-musl", use-cross: true, test-bin: "--bin jwtui" }
46
+ - { name: "macOS-arm64", os: "macOS-latest", target: "aarch64-apple-darwin", artifact_suffix: "macos-arm64", use-cross: true }
47
+ - { name: "macOS-amd64", os: "macOS-latest", target: "x86_64-apple-darwin", artifact_suffix: "macos" }
48
+ - { name: "windows-amd64", os: "windows-latest", target: "x86_64-pc-windows-msvc", artifact_suffix: "windows" }
49
+ - { name: "windows-aarch64", os: "windows-latest", target: "aarch64-pc-windows-msvc", artifact_suffix: "windows-aarch64", use-cross: true }
50
+ - { name: "linux-gnu", os: "ubuntu-latest", target: "x86_64-unknown-linux-gnu", artifact_suffix: "linux" }
51
+ - { name: "linux-musl", os: "ubuntu-latest", target: "x86_64-unknown-linux-musl", artifact_suffix: "linux-musl", use-cross: true, }
52
+ - { name: "linux-aarch64-gnu", os: "ubuntu-latest", target: "aarch64-unknown-linux-gnu", artifact_suffix: "aarch64-gnu", use-cross: true, test-bin: "--bin jwtui" }
53
+ - { name: "linux-aarch64-musl", os: "ubuntu-latest", target: "aarch64-unknown-linux-musl", artifact_suffix: "aarch64-musl", use-cross: true, test-bin: "--bin jwtui" }
54
+ - { name: "linux-arm-gnu", os: "ubuntu-latest", target: "arm-unknown-linux-gnueabi", artifact_suffix: "armv6-gnu", use-cross: true, test-bin: "--bin jwtui" }
55
+ - { name: "linux-arm-musl", os: "ubuntu-latest", target: "arm-unknown-linux-musleabihf", artifact_suffix: "armv6-musl", use-cross: true, test-bin: "--bin jwtui" }
56
+ - { name: "linux-armv7-gnu", os: "ubuntu-latest", target: "armv7-unknown-linux-gnueabihf", artifact_suffix: "armv7-gnu", use-cross: true, test-bin: "--bin jwtui" }
57
+ - { name: "linux-armv7-musl", os: "ubuntu-latest", target: "armv7-unknown-linux-musleabihf", artifact_suffix: "armv7-musl", use-cross: true, test-bin: "--bin jwtui" }
58
+ rust : [stable]
61
59
62
60
steps :
63
61
- name : Checkout repository
64
- uses : actions/checkout@v2
62
+ uses : actions/checkout@v4
65
63
with :
66
64
fetch-depth : 1
67
-
65
+ - uses : actions/cache@v3
66
+ name : Cache Cargo registry
67
+ with :
68
+ path : ~/.cargo/registry
69
+ key : ${{ runner.os }}-cargo-registry-${{ hashFiles('Cargo.lock') }}
70
+ - uses : actions/cache@v3
71
+ if : startsWith(matrix.job.name, 'linux-')
72
+ with :
73
+ path : ~/.cargo/bin
74
+ key : ${{ runner.os }}-cargo-bin-${{ hashFiles('.github/workflows/cd.yml') }}
68
75
- name : Get shared artifacts
69
- uses : actions/download-artifact@v2
76
+ uses : actions/download-artifact@v3
70
77
with :
71
78
name : artifacts
72
79
path : artifacts
@@ -81,59 +88,50 @@ jobs:
81
88
run : |
82
89
echo "Release version: ${{ env.RELEASE_VERSION }}"
83
90
84
- - name : Install toolchain
85
- uses : actions-rs/ toolchain@v1
91
+ - uses : dtolnay/rust- toolchain@stable
92
+ name : Set Rust toolchain
86
93
with :
87
- toolchain : ${{ matrix.rust }}
88
- override : true
94
+ targets : ${{ matrix.job.target }}
95
+ - uses : taiki-e/setup-cross-toolchain-action@v1
96
+ with :
97
+ # NB: sets CARGO_BUILD_TARGET evar - do not need --target flag in build
89
98
target : ${{ matrix.job.target }}
90
- profile : minimal # minimal component installation (ie, no documentation)
91
-
92
- - name : Installing needed macOS dependencies
93
- if : matrix.job.os == 'macos-latest'
94
- run : brew install openssl@1.1
99
+ - uses : taiki-e/install-action@cross
100
+ if : ${{ matrix.job.use-cross }}
95
101
96
102
- name : Installing needed Ubuntu dependencies
97
103
if : matrix.job.os == 'ubuntu-latest'
98
104
shell : bash
99
105
run : |
100
106
sudo apt-get -y update
101
- sudo apt-get -y install -qq pkg-config libssl-dev libxcb1-dev libxcb-render0-dev libxcb-shape0-dev libxcb-xfixes0-dev musl-tools
102
107
case ${{ matrix.job.target }} in
103
108
arm-unknown-linux-*) sudo apt-get -y install gcc-arm-linux-gnueabihf ;;
104
109
aarch64-unknown-linux-*) sudo apt-get -y install gcc-aarch64-linux-gnu ;;
105
110
esac
106
111
107
112
- name : Build
108
- uses : actions-rs/cargo@v1
109
- with :
110
- use-cross : ${{ matrix.job.use-cross }}
111
- command : build
112
- args : --release --verbose --target=${{ matrix.job.target }}
113
- toolchain : ${{ matrix.rust }}
113
+ run : cargo build --release --verbose --target=${{ matrix.job.target }} --locked
114
114
115
115
- name : Verify file
116
116
shell : bash
117
117
run : |
118
118
file target/${{ matrix.job.target }}/release/jwtui
119
119
120
120
- name : Test
121
- if : matrix.job.target != 'aarch64-apple-darwin'
122
- uses : actions-rs/cargo@v1
123
- with :
124
- use-cross : ${{ matrix.job.use-cross }}
125
- command : test
126
- args : --target=${{ matrix.job.target }} ${{ matrix.job.test-bin }}
121
+ if : matrix.job.target != 'aarch64-apple-darwin' && matrix.job.target != 'aarch64-pc-windows-msvc'
122
+ run : cargo test --release --verbose --target=${{ matrix.job.target }} ${{ matrix.job.test-bin }}
127
123
128
124
- name : Packaging final binary (Windows)
129
125
if : matrix.job.os == 'windows-latest'
130
126
shell : bash
131
127
run : |
132
128
cd target/${{ matrix.job.target }}/release
133
129
BINARY_NAME=jwtui.exe
134
- # strip the binary
135
- strip $BINARY_NAME
136
- RELEASE_NAME=jwtui-${{ matrix.job.artifact_prefix }}
130
+ if [ "${{ matrix.job.target }}" != "aarch64-pc-windows-msvc" ]; then
131
+ # strip the binary
132
+ strip $BINARY_NAME
133
+ fi
134
+ RELEASE_NAME=jwtui-${{ matrix.job.artifact_suffix }}
137
135
tar czvf $RELEASE_NAME.tar.gz $BINARY_NAME
138
136
# create sha checksum files
139
137
certutil -hashfile $RELEASE_NAME.tar.gz sha256 | grep -E [A-Fa-f0-9]{64} > $RELEASE_NAME.sha256
@@ -146,14 +144,14 @@ jobs:
146
144
# set the right strip executable
147
145
STRIP="strip";
148
146
case ${{ matrix.job.target }} in
149
- arm- *-linux-*) STRIP="arm-linux-gnueabihf-strip" ;;
147
+ arm*-linux-*) STRIP="arm-linux-gnueabihf-strip" ;;
150
148
aarch64-*-linux-*) STRIP="aarch64-linux-gnu-strip" ;;
151
149
esac;
152
150
cd target/${{ matrix.job.target }}/release
153
151
BINARY_NAME=jwtui
154
152
# strip the binary
155
153
"$STRIP" "$BINARY_NAME"
156
- RELEASE_NAME=jwtui-${{ matrix.job.artifact_prefix }}
154
+ RELEASE_NAME=jwtui-${{ matrix.job.artifact_suffix }}
157
155
tar czvf $RELEASE_NAME.tar.gz $BINARY_NAME
158
156
# create sha checksum files
159
157
shasum -a 256 $RELEASE_NAME.tar.gz > $RELEASE_NAME.sha256
@@ -173,7 +171,7 @@ jobs:
173
171
cp target/${{ matrix.job.target }}/release/${{ env.RELEASE_NAME }}.sha256 artifacts/
174
172
175
173
- name : Upload artifacts
176
- uses : actions/upload-artifact@v1
174
+ uses : actions/upload-artifact@v3
177
175
with :
178
176
name : artifacts
179
177
path : artifacts
@@ -184,12 +182,12 @@ jobs:
184
182
runs-on : ubuntu-latest
185
183
steps :
186
184
- name : Checkout repository
187
- uses : actions/checkout@v2
185
+ uses : actions/checkout@v4
188
186
with :
189
187
fetch-depth : 1
190
188
191
189
- name : Get release artifacts
192
- uses : actions/download-artifact@v2
190
+ uses : actions/download-artifact@v3
193
191
with :
194
192
name : artifacts
195
193
path : artifacts
@@ -201,7 +199,7 @@ jobs:
201
199
echo "MACOS_SHA=$macos_sha" >> $GITHUB_ENV
202
200
macos_sha_arm="$(cat ./artifacts/jwtui-macos-arm64.sha256 | awk '{print $1}')"
203
201
echo "MACOS_SHA_ARM=$macos_sha_arm" >> $GITHUB_ENV
204
- linux_sha="$(cat ./artifacts/jwtui-linux.sha256 | awk '{print $1}')"
202
+ linux_sha="$(cat ./artifacts/jwtui-linux-musl .sha256 | awk '{print $1}')"
205
203
echo "LINUX_SHA=$linux_sha" >> $GITHUB_ENV
206
204
release_version="$(cat ./artifacts/release-version)"
207
205
echo "RELEASE_VERSION=$release_version" >> $GITHUB_ENV
@@ -210,7 +208,7 @@ jobs:
210
208
run : |
211
209
echo "Release SHA macos: ${{ env.MACOS_SHA }}"
212
210
echo "Release SHA macos-arm: ${{ env.MACOS_SHA_ARM }}"
213
- echo "Release SHA linux: ${{ env.LINUX_SHA }}"
211
+ echo "Release SHA linux musl : ${{ env.LINUX_SHA }}"
214
212
echo "Release version: ${{ env.RELEASE_VERSION }}"
215
213
216
214
- name : Execute Homebrew packaging script
@@ -235,12 +233,12 @@ jobs:
235
233
runs-on : ubuntu-latest
236
234
steps :
237
235
- name : Checkout repository
238
- uses : actions/checkout@v2
236
+ uses : actions/checkout@v4
239
237
with :
240
238
fetch-depth : 1
241
239
242
240
- name : Get release artifacts
243
- uses : actions/download-artifact@v2
241
+ uses : actions/download-artifact@v3
244
242
with :
245
243
name : artifacts
246
244
path : artifacts
@@ -279,27 +277,26 @@ jobs:
279
277
name : Publishing to Cargo
280
278
runs-on : ubuntu-latest
281
279
steps :
282
- - uses : actions/checkout@v2
283
- - uses : actions-rs/toolchain@v1
280
+ - uses : actions/checkout@v4
281
+ - uses : actions/cache@v3
282
+ name : Cache Cargo registry
284
283
with :
285
- toolchain : stable
286
- override : true
287
- profile : minimal # minimal component installation (ie, no documentation)
288
- - run : |
289
- sudo apt-get update
290
- sudo apt-get install -y -qq pkg-config libssl-dev libxcb1-dev libxcb-render0-dev libxcb-shape0-dev libxcb-xfixes0-dev
291
- - uses : actions-rs/cargo@v1
284
+ path : ~/.cargo/registry
285
+ key : ${{ runner.os }}-cargo-registry-${{ hashFiles('Cargo.lock') }}
286
+ - uses : actions/cache@v3
292
287
with :
293
- command : publish
294
- args : --token ${{ secrets.CARGO_API_KEY }} --allow-dirty
288
+ path : ~/.cargo/bin
289
+ key : ${{ runner.os }}-cargo-bin-${{ hashFiles('.github/workflows/cd.yml') }}
290
+ - uses : dtolnay/rust-toolchain@stable
291
+ - run : cargo publish --token ${{ secrets.CARGO_API_KEY }} --allow-dirty
295
292
296
293
publish-docker-image :
297
294
needs : [build-release-artifacts]
298
295
name : Publishing Docker image to Docker Hub
299
296
runs-on : ubuntu-latest
300
297
steps :
301
298
- name : Get release artifacts
302
- uses : actions/download-artifact@v2
299
+ uses : actions/download-artifact@v3
303
300
with :
304
301
name : artifacts
305
302
path : artifacts
0 commit comments