@@ -3,6 +3,12 @@ name: Build
33on :
44 release :
55 types : [created]
6+ workflow_dispatch :
7+ inputs :
8+ os :
9+ required : true
10+ type : choice
11+ options : ['ubuntu', 'macos', 'windows']
612
713env :
814 CARGO_TERM_COLOR : always
@@ -11,32 +17,40 @@ jobs:
1117 build :
1218 name : Build binary on ${{ matrix.os }}
1319
14- runs-on : ${{ matrix.os }}
20+ runs-on : ${{ matrix.os }}-latest
1521 strategy :
1622 fail-fast : false
1723 matrix :
18- include :
19- - os : ubuntu-latest
20- file : target/release/simple_backup
21- - os : windows-latest
22- file : target/release/simple_backup.exe
23- - os : macOS-latest
24- file : target/release/simple_backup
25-
24+ os : ${{ fromJSON(format('[{0}]', inputs.os || 'ubuntu, macos, windows')) }}
2625
2726 steps :
2827 - name : Checkout
2928 uses : actions/checkout@v4
30- - name : Build
31- run : cargo build --verbose
32- - name : Run tests
33- run : cargo test --verbose
3429 - name : Build release
3530 run : cargo build --release
31+
32+ - name : Set ENV Windows
33+ if : runner.os == 'Windows'
34+ run : echo "{executable}={target/release/simple_backup.exe}" >> $GITHUB_ENV
35+ - name : Set ENV Linux
36+ if : runner.os == 'Linux'
37+ run : echo "{executable}={target/release/simple_backup}" >> $GITHUB_ENV
38+ - name : Set ENV Mac
39+ if : runner.os == 'Mac'
40+ run : |
41+ mv target/release/simple_backup target/release/simple_backup_mac
42+ echo "{executable}={target/release/simple_backup_mac}" >> $GITHUB_ENV
43+
3644 - name : Run
37- run : ${{ matrix.file }} --help
38- - name : Release
45+ run : ${{ env.executable }} --help
46+ - name : Upload Release
394740- if : startsWith(github.ref, 'refs/tags/')
48+ if : ${{ startsWith(github.ref, 'refs/tags/') }}
49+ with :
50+ files : ${{ env.executable }}
51+ - name : Upload Artifact
52+ uses : actions/upload-artifact@v4
53+ if : ${{ ! startsWith(github.ref, 'refs/tags/') }}
4154 with :
42- files : ${{ matrix.file }}
55+ path : ${{ env.executable }}
56+ retention-days : 2
0 commit comments