Skip to content

Commit 1a13532

Browse files
authored
fix: release workflow (#11)
* fix: release workflow * fix
1 parent dc1d04d commit 1a13532

File tree

2 files changed

+52
-12
lines changed

2 files changed

+52
-12
lines changed

.github/workflows/ci.yml

Lines changed: 35 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,33 @@ env:
1919

2020
jobs:
2121
checks:
22-
runs-on: ubuntu-latest
22+
runs-on: ${{ matrix.os }}
23+
strategy:
24+
matrix:
25+
include:
26+
- os: ubuntu-latest
27+
target: x86_64-unknown-linux-gnu
28+
use-cross: false
29+
- os: ubuntu-latest
30+
target: aarch64-unknown-linux-gnu
31+
use-cross: true
32+
- os: macos-latest
33+
target: x86_64-apple-darwin
34+
use-cross: false
35+
- os: macos-latest
36+
target: aarch64-apple-darwin
37+
use-cross: false
38+
- os: windows-latest
39+
target: x86_64-pc-windows-msvc
40+
use-cross: false
2341
steps:
2442
- name: Checkout
2543
uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0
2644

2745
- name: Install toolchain
2846
uses: dtolnay/rust-toolchain@stable
47+
with:
48+
targets: ${{ matrix.target }}
2949

3050
- name: Cache cargo registry
3151
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
@@ -40,13 +60,24 @@ jobs:
4060
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
4161
with:
4262
path: target
43-
key: ${{ runner.os }}-ci-target-${{ hashFiles('**/Cargo.lock') }}
44-
restore-keys: ${{ runner.os }}-ci-target-
63+
key: ${{ runner.os }}-ci-${{ matrix.target }}-${{ hashFiles('**/Cargo.lock') }}
64+
restore-keys: ${{ runner.os }}-ci-${{ matrix.target }}-
4565

4666
- name: Install cargo-make
4767
uses: taiki-e/install-action@e43a5023a747770bfcb71ae048541a681714b951 # v2.62.33
4868
with:
4969
tool: cargo-make
5070

71+
- name: Install cross
72+
if: matrix.use-cross == true
73+
uses: taiki-e/install-action@e43a5023a747770bfcb71ae048541a681714b951 # v2.62.33
74+
with:
75+
tool: cross
76+
77+
- name: Run CI task (cross)
78+
if: matrix.use-cross == true
79+
run: cross make ci -- --locked
80+
5181
- name: Run CI task
52-
run: cargo make ci
82+
if: matrix.use-cross != true
83+
run: cargo make ci -- --locked

.github/workflows/release.yml

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,13 @@ jobs:
5555
with:
5656
tool: cross
5757

58-
- name: Build release binary
59-
run: |
60-
if [ "${{ matrix.use-cross }}" = "true" ]; then
61-
cross build --release --package nblm-cli --target ${{ matrix.target }}
62-
else
63-
cargo build --release --package nblm-cli --target ${{ matrix.target }}
64-
fi
58+
- name: Build release binary (cross)
59+
if: matrix.use-cross == true
60+
run: cross build --release --package nblm-cli --target ${{ matrix.target }}
61+
62+
- name: Build release binary (native)
63+
if: matrix.use-cross != true
64+
run: cargo build --release --package nblm-cli --target ${{ matrix.target }}
6565

6666
- name: Package binary (Unix)
6767
if: runner.os != 'Windows'
@@ -87,11 +87,20 @@ jobs:
8787
name: ${{ matrix.artifact }}
8888
path: dist/${{ matrix.artifact }}
8989

90-
- name: Generate SHA256 checksum
90+
- name: Generate SHA256 checksum (Unix)
91+
if: runner.os != 'Windows'
9192
run: |
9293
cd dist
9394
shasum -a 256 ${{ matrix.artifact }} > ${{ matrix.artifact }}.sha256
9495
96+
- name: Generate SHA256 checksum (Windows)
97+
if: runner.os == 'Windows'
98+
shell: pwsh
99+
run: |
100+
Set-Location dist
101+
$hash = Get-FileHash -Path "${{ matrix.artifact }}" -Algorithm SHA256
102+
"{0} {1}" -f $hash.Hash.ToLower(), $hash.Path | Out-File -FilePath "${{ matrix.artifact }}.sha256" -Encoding ascii
103+
95104
- name: Upload checksum
96105
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
97106
with:

0 commit comments

Comments
 (0)