1313 steps :
1414 - name : Create artifacts directory
1515 run : mkdir artifacts
16-
1716 - name : Get the release version from the tag
1817 if : env.VERSION == ''
1918 run : |
@@ -23,16 +22,12 @@ jobs:
2322 else
2423 echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
2524 fi
26-
2725 - 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 }}"!
3127 - name : Save version number to artifact
3228 run : echo "${{ env.VERSION }}" > artifacts/release-version
33-
3429 - name : Upload artifacts
35- uses : actions/upload-artifact@v1
30+ uses : actions/upload-artifact@v3
3631 with :
3732 name : artifacts
3833 path : artifacts
@@ -46,27 +41,39 @@ jobs:
4641 strategy :
4742 fail-fast : false
4843 matrix :
49- rust : [stable]
44+ # prettier-ignore
5045 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]
6159
6260 steps :
6361 - name : Checkout repository
64- uses : actions/checkout@v2
62+ uses : actions/checkout@v4
6563 with :
6664 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') }}
6875 - name : Get shared artifacts
69- uses : actions/download-artifact@v2
76+ uses : actions/download-artifact@v3
7077 with :
7178 name : artifacts
7279 path : artifacts
@@ -81,59 +88,50 @@ jobs:
8188 run : |
8289 echo "Release version: ${{ env.RELEASE_VERSION }}"
8390
84- - name : Install toolchain
85- uses : actions-rs/ toolchain@v1
91+ - uses : dtolnay/rust- toolchain@stable
92+ name : Set Rust toolchain
8693 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
8998 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 [email protected] 99+ - uses : taiki-e/install-action@cross
100+ if : ${{ matrix.job.use-cross }}
95101
96102 - name : Installing needed Ubuntu dependencies
97103 if : matrix.job.os == 'ubuntu-latest'
98104 shell : bash
99105 run : |
100106 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
102107 case ${{ matrix.job.target }} in
103108 arm-unknown-linux-*) sudo apt-get -y install gcc-arm-linux-gnueabihf ;;
104109 aarch64-unknown-linux-*) sudo apt-get -y install gcc-aarch64-linux-gnu ;;
105110 esac
106111
107112 - 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
114114
115115 - name : Verify file
116116 shell : bash
117117 run : |
118118 file target/${{ matrix.job.target }}/release/jwtui
119119
120120 - 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 }}
127123
128124 - name : Packaging final binary (Windows)
129125 if : matrix.job.os == 'windows-latest'
130126 shell : bash
131127 run : |
132128 cd target/${{ matrix.job.target }}/release
133129 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 }}
137135 tar czvf $RELEASE_NAME.tar.gz $BINARY_NAME
138136 # create sha checksum files
139137 certutil -hashfile $RELEASE_NAME.tar.gz sha256 | grep -E [A-Fa-f0-9]{64} > $RELEASE_NAME.sha256
@@ -146,14 +144,14 @@ jobs:
146144 # set the right strip executable
147145 STRIP="strip";
148146 case ${{ matrix.job.target }} in
149- arm- *-linux-*) STRIP="arm-linux-gnueabihf-strip" ;;
147+ arm*-linux-*) STRIP="arm-linux-gnueabihf-strip" ;;
150148 aarch64-*-linux-*) STRIP="aarch64-linux-gnu-strip" ;;
151149 esac;
152150 cd target/${{ matrix.job.target }}/release
153151 BINARY_NAME=jwtui
154152 # strip the binary
155153 "$STRIP" "$BINARY_NAME"
156- RELEASE_NAME=jwtui-${{ matrix.job.artifact_prefix }}
154+ RELEASE_NAME=jwtui-${{ matrix.job.artifact_suffix }}
157155 tar czvf $RELEASE_NAME.tar.gz $BINARY_NAME
158156 # create sha checksum files
159157 shasum -a 256 $RELEASE_NAME.tar.gz > $RELEASE_NAME.sha256
@@ -173,7 +171,7 @@ jobs:
173171 cp target/${{ matrix.job.target }}/release/${{ env.RELEASE_NAME }}.sha256 artifacts/
174172
175173 - name : Upload artifacts
176- uses : actions/upload-artifact@v1
174+ uses : actions/upload-artifact@v3
177175 with :
178176 name : artifacts
179177 path : artifacts
@@ -184,12 +182,12 @@ jobs:
184182 runs-on : ubuntu-latest
185183 steps :
186184 - name : Checkout repository
187- uses : actions/checkout@v2
185+ uses : actions/checkout@v4
188186 with :
189187 fetch-depth : 1
190188
191189 - name : Get release artifacts
192- uses : actions/download-artifact@v2
190+ uses : actions/download-artifact@v3
193191 with :
194192 name : artifacts
195193 path : artifacts
@@ -201,7 +199,7 @@ jobs:
201199 echo "MACOS_SHA=$macos_sha" >> $GITHUB_ENV
202200 macos_sha_arm="$(cat ./artifacts/jwtui-macos-arm64.sha256 | awk '{print $1}')"
203201 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}')"
205203 echo "LINUX_SHA=$linux_sha" >> $GITHUB_ENV
206204 release_version="$(cat ./artifacts/release-version)"
207205 echo "RELEASE_VERSION=$release_version" >> $GITHUB_ENV
@@ -210,7 +208,7 @@ jobs:
210208 run : |
211209 echo "Release SHA macos: ${{ env.MACOS_SHA }}"
212210 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 }}"
214212 echo "Release version: ${{ env.RELEASE_VERSION }}"
215213
216214 - name : Execute Homebrew packaging script
@@ -235,12 +233,12 @@ jobs:
235233 runs-on : ubuntu-latest
236234 steps :
237235 - name : Checkout repository
238- uses : actions/checkout@v2
236+ uses : actions/checkout@v4
239237 with :
240238 fetch-depth : 1
241239
242240 - name : Get release artifacts
243- uses : actions/download-artifact@v2
241+ uses : actions/download-artifact@v3
244242 with :
245243 name : artifacts
246244 path : artifacts
@@ -279,27 +277,26 @@ jobs:
279277 name : Publishing to Cargo
280278 runs-on : ubuntu-latest
281279 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
284283 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
292287 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
295292
296293 publish-docker-image :
297294 needs : [build-release-artifacts]
298295 name : Publishing Docker image to Docker Hub
299296 runs-on : ubuntu-latest
300297 steps :
301298 - name : Get release artifacts
302- uses : actions/download-artifact@v2
299+ uses : actions/download-artifact@v3
303300 with :
304301 name : artifacts
305302 path : artifacts
0 commit comments