@@ -3,7 +3,10 @@ name: Release
33on :
44 push :
55 tags :
6- - ' v*'
6+ - " v*"
7+
8+ permissions :
9+ contents : write
710
811jobs :
912 build :
@@ -14,68 +17,89 @@ jobs:
1417 include :
1518 - os : ubuntu-latest
1619 target : x86_64-unknown-linux-gnu
17- artifact_name : polymorph
18- asset_name : polymorph-linux-x64
20+ artifact : polymorph
21+ asset : polymorph-linux-x64.tar.gz
22+
1923 - os : ubuntu-latest
2024 target : aarch64-unknown-linux-gnu
21- artifact_name : polymorph
22- asset_name : polymorph-linux-arm64
25+ artifact : polymorph
26+ asset : polymorph-linux-arm64.tar.gz
27+ use_cross : true
28+
2329 - os : macos-latest
2430 target : x86_64-apple-darwin
25- artifact_name : polymorph
26- asset_name : polymorph-macos-x64
31+ artifact : polymorph
32+ asset : polymorph-macos-x64.tar.gz
33+
2734 - os : macos-latest
2835 target : aarch64-apple-darwin
29- artifact_name : polymorph
30- asset_name : polymorph-macos-arm64
36+ artifact : polymorph
37+ asset : polymorph-macos-arm64.tar.gz
38+
3139 - os : windows-latest
3240 target : x86_64-pc-windows-msvc
33- artifact_name : polymorph.exe
34- asset_name : polymorph-windows-x64.exe
41+ artifact : polymorph.exe
42+ asset : polymorph-windows-x64.zip
3543
3644 steps :
37- - uses : actions/checkout@v3
38-
39- - uses : actions-rs/ toolchain@v1
45+ - uses : actions/checkout@v4
46+
47+ - uses : dtolnay/rust- toolchain@stable
4048 with :
41- toolchain : stable
42- target : ${{ matrix.target }}
43- override : true
44-
45- - name : Install cross-compilation tools
46- 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
49+ targets : ${{ matrix.target }}
50+
51+ - name : Install cross
52+ if : matrix.use_cross == true
53+ run : cargo install cross --git https://github.com/cross-rs/cross
54+
55+ - name : Build (cross)
56+ if : matrix.use_cross == true
57+ run : cross build --release --target ${{ matrix.target }}
58+
59+ - name : Build (native)
60+ if : matrix.use_cross != true
5261 run : cargo build --release --target ${{ matrix.target }}
53-
54- - name : Strip binary (Linux/macOS)
62+
63+ # Strip ONLY Linux (safe)
64+ - name : Strip Linux binary
65+ if : startsWith(matrix.target, 'x86_64-unknown-linux') || startsWith(matrix.target, 'aarch64-unknown-linux')
66+ run : strip target/${{ matrix.target }}/release/${{ matrix.artifact }}
67+
68+ # Package artifacts
69+ - name : Package (Unix)
5570 if : matrix.os != 'windows-latest'
56- run : strip target/${{ matrix.target }}/release/${{ matrix.artifact_name }}
57-
58- - name : Upload binary
71+ run : |
72+ cd target/${{ matrix.target }}/release
73+ tar czf ../../../${{ matrix.asset }} ${{ matrix.artifact }}
74+
75+ - name : Package (Windows)
76+ if : matrix.os == 'windows-latest'
77+ run : |
78+ mkdir dist
79+ copy target\${{ matrix.target }}\release\${{ matrix.artifact }} dist\
80+ powershell Compress-Archive dist\* ${{ matrix.asset }}
81+
82+ - name : Upload artifact
5983 uses : actions/upload-artifact@v4
6084 with :
61- name : ${{ matrix.asset_name }}
62- path : target/ ${{ matrix.target }}/release/${{ matrix.artifact_name }}
85+ name : ${{ matrix.asset }}
86+ path : ${{ matrix.asset }}
6387
6488 release :
6589 needs : build
6690 runs-on : ubuntu-latest
6791 steps :
68- - uses : actions/checkout@v3
69-
70- - name : Download all artifacts
92+ - uses : actions/checkout@v4
93+
94+ - name : Download artifacts
7195 uses : actions/download-artifact@v4
7296 with :
73- path : artifacts
74-
75- - name : Create Release
97+ path : dist
98+
99+ - name : Create GitHub Release
76100 uses : softprops/action-gh-release@v1
77101 with :
78- files : artifacts /**/*
102+ files : dist /**/*
79103 generate_release_notes : true
80104 env :
81105 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
0 commit comments