1+ name : ' Release binary'
12on :
3+ workflow_dispatch :
4+ inputs :
5+ test_release :
6+ description : ' Test release'
7+ required : false
8+ type : boolean
9+
210 release :
311 types : [created]
12+ pull_request :
13+ types : [opened, synchronize]
414
515jobs :
616 release :
7- name : release ${{ matrix.target }}
8- runs-on : ubuntu-latest
9- if : github.event_name == 'release'
17+ if : ${{ github.event_name == 'release' || github.event.inputs.test_release == 'true' }}
1018 strategy :
11- fail-fast : false
19+ fail-fast : true
1220 matrix :
13- include :
14- - target : x86_64-pc-windows-gnu
15- archive : zip
16- - target : x86_64-unknown-linux-musl
17- archive : tar.gz
18- - target : x86_64-apple-darwin
19- archive : zip
20- - target : wasm32-wasi
21- archive : zip tar.gz
21+ platform :
22+
23+ # linux
24+ - release_for : Linux-x86_64
25+ os : ubuntu-20.04
26+ target : x86_64-unknown-linux-musl
27+ bin : khmercut
28+ name : khmercut-Linux-x86_64-musl.tar.gz
29+ command : build
30+
31+ - release_for : Linux-aarch64
32+ os : ubuntu-20.04
33+ target : aarch64-unknown-linux-musl
34+ bin : khmercut
35+ name : khmercut-Linux-aarch64-musl.tar.gz
36+ command : build
37+
38+
39+ # windows
40+ - release_for : Windows-x86_64
41+ os : windows-latest
42+ target : x86_64-pc-windows-msvc
43+ bin : khmercut.exe
44+ name : khmercut-Windows-x86_64.zip
45+ command : build
46+
47+ - release_for : Windows-aarch64
48+ os : windows-latest
49+ target : aarch64-pc-windows-msvc
50+ bin : khmercut.exe
51+ name : khmercut-Windows-aarch64.zip
52+ command : build
53+
54+ # macOS
55+ - release_for : macOS-x86_64
56+ os : macOS-latest
57+ target : x86_64-apple-darwin
58+ bin : khmercut
59+ name : khmercut-Darwin-x86_64.tar.gz
60+ command : build
61+
62+ - release_for : macOS-aarch64
63+ os : macOS-latest
64+ target : aarch64-apple-darwin
65+ bin : khmercut
66+ name : khmercut-Darwin-aarch64.tar.gz
67+ command : build
68+
69+ # wasm
70+ - release_for : WASM
71+ os : ubuntu-20.04
72+ target : wasm32-unknown-unknown
73+ bin : khmercut.wasm
74+ name : khmercut-wasm.tar.gz
75+ command : build
76+
77+ toolchain :
78+ - stable
79+
80+ runs-on : ${{ matrix.platform.os }}
2281 steps :
23- - uses : actions/checkout@master
24- - name : Compile and release
25- uses : rust-build/rust-build.action@master
82+ - uses : actions/checkout@v4
83+ - name : Cache cargo & target directories
84+ uses : Swatinem/rust-cache@v2
85+ with :
86+ key : " v2"
2687 env :
2788 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
89+
90+ - name : Install cross
91+ run : cargo install cross
92+
93+ - name : Update Cargo.lock
94+ run : cargo update
95+
96+ - name : Build binary
97+ uses : houseabsolute/actions-rust-cross@v0
98+ with :
99+ command : ${{ matrix.platform.command }}
100+ target : ${{ matrix.platform.target }}
101+ args : " --locked --release"
102+ strip : true
103+
104+ - name : Package as archive
105+ shell : bash
106+ run : |
107+ cd target/${{ matrix.platform.target }}/release
108+ if [[ "${{ matrix.platform.os }}" == "windows-latest" ]]; then
109+ 7z a ../../../${{ matrix.platform.name }} ${{ matrix.platform.bin }}
110+ else
111+ tar czvf ../../../${{ matrix.platform.name }} ${{ matrix.platform.bin }}
112+ fi
113+ cd -
114+ if : |
115+ matrix.toolchain == 'stable' && startsWith( github.ref, 'refs/tags' )
116+
117+ - name : Publish release artifacts
118+ uses : actions/upload-artifact@v3
119+ with :
120+ name : khmercut-${{ matrix.platform.os_name }}
121+ path : " khmercut-*"
122+ if : matrix.toolchain == 'stable' && github.ref == 'refs/tags'
123+
124+ - name : Generate SHA-256
125+ run : shasum -a 256 ${{ matrix.platform.name }}
126+ if : |
127+ matrix.toolchain == 'stable' &&
128+ matrix.platform.os == 'macOS-latest' && startsWith( github.ref, 'refs/tags' )
129+
130+ - name : Publish GitHub release
131+ uses : softprops/action-gh-release@v2
28132 with :
29- RUSTTARGET : ${{ matrix.target }}
30- EXTRA_FILES : " README.md"
31- ARCHIVE_TYPES : ${{ matrix.archive }}
32- MINIFY : " yes"
33- TOOLCHAIN_VERSION : stable
133+ draft : true
134+ files : " khmercut*"
135+ body_path : CHANGELOG.md
136+ if : matrix.toolchain == 'stable' && startsWith( github.ref, 'refs/tags' )
0 commit comments