@@ -3,79 +3,124 @@ name: Release
33on :
44 push :
55 tags :
6- - ' v*'
6+ - " v*"
7+
8+ permissions :
9+ contents : write
710
811jobs :
912 build :
1013 name : Build ${{ matrix.target }}
1114 runs-on : ${{ matrix.os }}
15+
1216 strategy :
17+ fail-fast : false
1318 matrix :
1419 include :
20+ # ---------------- Linux x86_64 ----------------
1521 - os : ubuntu-latest
1622 target : x86_64-unknown-linux-gnu
17- artifact_name : polymorph
18- asset_name : polymorph-linux-x64
23+ artifact : polymorph
24+ asset : polymorph-linux-x64.tar.gz
25+
26+ # ---------------- Linux ARM64 ----------------
1927 - os : ubuntu-latest
2028 target : aarch64-unknown-linux-gnu
21- artifact_name : polymorph
22- asset_name : polymorph-linux-arm64
29+ artifact : polymorph
30+ asset : polymorph-linux-arm64.tar.gz
31+ use_cross : true
32+
33+ # ---------------- macOS x86_64 ----------------
2334 - os : macos-latest
2435 target : x86_64-apple-darwin
25- artifact_name : polymorph
26- asset_name : polymorph-macos-x64
36+ artifact : polymorph
37+ asset : polymorph-macos-x64.tar.gz
38+
39+ # ---------------- macOS ARM64 ----------------
2740 - os : macos-latest
2841 target : aarch64-apple-darwin
29- artifact_name : polymorph
30- asset_name : polymorph-macos-arm64
42+ artifact : polymorph
43+ asset : polymorph-macos-arm64.tar.gz
44+
45+ # ---------------- Windows x86_64 ----------------
3146 - os : windows-latest
3247 target : x86_64-pc-windows-msvc
33- artifact_name : polymorph.exe
34- asset_name : polymorph-windows-x64.exe
48+ artifact : polymorph.exe
49+ asset : polymorph-windows-x64.zip
3550
3651 steps :
37- - uses : actions/checkout@v3
38-
39- - uses : actions-rs/toolchain@v1
52+ - uses : actions/checkout@v4
53+
54+ - name : Install Rust toolchain
55+ uses : dtolnay/rust-toolchain@stable
4056 with :
41- toolchain : stable
42- target : ${{ matrix.target }}
43- override : true
44-
45- - name : Install cross-compilation tools
57+ targets : ${{ matrix.target }}
58+
59+ # ---------- Linux ARM64 dependencies ----------
60+ - name : Install aarch64 binutils
4661 if : matrix.target == 'aarch64-unknown-linux-gnu'
47- run : |
48- sudo apt-get update
49- sudo apt-get install -y gcc-aarch64-linux-gnu
50-
51- - name : Build
62+ run : sudo apt-get update && sudo apt-get install -y binutils-aarch64-linux-gnu
63+
64+ # ---------- Install cross ----------
65+ - name : Install cross
66+ if : matrix.use_cross == true
67+ run : cargo install cross --git https://github.com/cross-rs/cross
68+
69+ # ---------- Build ----------
70+ - name : Build (cross)
71+ if : matrix.use_cross == true
72+ run : cross build --release --target ${{ matrix.target }}
73+
74+ - name : Build (native)
75+ if : matrix.use_cross != true
5276 run : cargo build --release --target ${{ matrix.target }}
53-
54- - name : Strip binary (Linux/macOS)
77+
78+ # ---------- Strip (Linux only, correct tool) ----------
79+ - name : Strip Linux x86_64
80+ if : matrix.target == 'x86_64-unknown-linux-gnu'
81+ run : strip target/${{ matrix.target }}/release/${{ matrix.artifact }}
82+
83+ - name : Strip Linux ARM64
84+ if : matrix.target == 'aarch64-unknown-linux-gnu'
85+ run : aarch64-linux-gnu-strip target/${{ matrix.target }}/release/${{ matrix.artifact }}
86+
87+ # ---------- Package ----------
88+ - name : Package (Unix)
5589 if : matrix.os != 'windows-latest'
56- run : strip target/${{ matrix.target }}/release/${{ matrix.artifact_name }}
57-
58- - name : Upload binary
90+ run : |
91+ cd target/${{ matrix.target }}/release
92+ tar czf ../../../${{ matrix.asset }} ${{ matrix.artifact }}
93+
94+ - name : Package (Windows)
95+ if : matrix.os == 'windows-latest'
96+ run : |
97+ mkdir dist
98+ copy target\${{ matrix.target }}\release\${{ matrix.artifact }} dist\
99+ powershell Compress-Archive dist\* ${{ matrix.asset }}
100+
101+ # ---------- Upload ----------
102+ - name : Upload artifact
59103 uses : actions/upload-artifact@v4
60104 with :
61- name : ${{ matrix.asset_name }}
62- path : target/ ${{ matrix.target }}/release/${{ matrix.artifact_name }}
105+ name : ${{ matrix.asset }}
106+ path : ${{ matrix.asset }}
63107
64108 release :
65109 needs : build
66110 runs-on : ubuntu-latest
111+
67112 steps :
68- - uses : actions/checkout@v3
69-
70- - name : Download all artifacts
113+ - uses : actions/checkout@v4
114+
115+ - name : Download artifacts
71116 uses : actions/download-artifact@v4
72117 with :
73- path : artifacts
74-
75- - name : Create Release
118+ path : dist
119+
120+ - name : Create GitHub Release
76121 uses : softprops/action-gh-release@v1
77122 with :
78- files : artifacts /**/*
123+ files : dist /**/*
79124 generate_release_notes : true
80125 env :
81126 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
0 commit comments