14
14
matrix :
15
15
os :
16
16
- windows-latest
17
- - ubuntu-latest
17
+ - ubuntu-latest # target: x86_64-unknown-linux-musl
18
18
- macos-latest
19
19
file :
20
20
- ${{ github.event.repository.name }}
23
23
run :
24
24
shell : bash
25
25
env :
26
- # 构建文件路径, Windows 平台有 .exe 后缀
27
- NAME : ${{ format('target/release/{0}{1}', matrix.file, startsWith(matrix.os, 'windows') && '.exe' || '') }}
26
+ # 不同构建目标对应的 release 目录
27
+ TARGET : ${{ matrix.os == 'ubuntu-latest' && 'target/x86_64-unknown-linux-musl/release' || 'target/release' }}
28
+ # 构建文件名, Windows 平台有 .exe 后缀
29
+ NAME : ${{ format('{0}{1}', matrix.file, startsWith(matrix.os, 'windows') && '.exe' || '') }}
28
30
# 上传制品文件名
29
31
ARTIFACT_NAME : Binary-${{ matrix.file }}-${{ matrix.os }}
30
32
steps :
@@ -42,38 +44,54 @@ jobs:
42
44
./target
43
45
key : ${{ runner.os }}-${{ matrix.file }}-cache
44
46
47
+ - name : musl-tools
48
+ if : matrix.os == 'ubuntu-latest'
49
+ run : |
50
+ sudo apt install -y musl-tools
51
+
52
+ - name : Rustup
53
+ if : steps.cache.outputs.cache-hit != 'true' && matrix.os == 'ubuntu-latest'
54
+ run : |
55
+ rustup target add x86_64-unknown-linux-musl
56
+
45
57
- name : Build
46
58
env :
47
59
CARGO_TERM_COLOR : always
48
- run : cargo build --release --verbose
60
+ run : |
61
+ cargo build --release --verbose \
62
+ ${{ matrix.os == 'ubuntu-latest' && '--target x86_64-unknown-linux-musl' || '--' }}
49
63
50
- - name : Naming ${{ env.NEW_NAME }}
64
+ - name : Naming ${{ env.NAMING }}
51
65
id : naming
52
66
env :
53
- NEW_NAME : >-
54
- ${{ format('target/release/{0}-{1}-{2}-{3}{4}',
55
- matrix.file, github.ref_name, runner.os, runner.arch, startsWith(matrix.os, 'windows') && '.exe' || '') }}
67
+ NAMING : >-
68
+ ${{
69
+ format('{0}-{1}-{2}-{3}{4}',
70
+ matrix.file, github.ref_name, runner.os, runner.arch,
71
+ startsWith(matrix.os, 'windows') && '.exe' || ''
72
+ )
73
+ }}
56
74
run : |
57
- export NAME ="$( echo ${{ env.NEW_NAME }} | tr [:upper:] [:lower:] )"
58
- echo "FILENAME=$NAME " >> $GITHUB_OUTPUT
75
+ export NAMING ="$( echo ${{ env.NAMING }} | tr [:upper:] [:lower:] )"
76
+ echo "FILEPATH=$TARGET/$NAMING " >> $GITHUB_OUTPUT
59
77
60
78
- name : Rename file
61
79
run : |
62
- mv $ NAME ${{ steps.naming.outputs.FILENAME }}
80
+ mv "$TARGET/$ NAME" ${{ steps.naming.outputs.FILEPATH }}
63
81
64
82
- name : Upload
65
83
uses : actions/upload-artifact@master
66
84
id : artifact-upload-step
67
85
with :
68
86
name : ${{ env.ARTIFACT_NAME }}
69
- path : ${{ steps.naming.outputs.FILENAME }}
87
+ path : ${{ steps.naming.outputs.FILEPATH }}
70
88
71
89
- name : GH Release on ${{ matrix.os }}
72
90
73
91
if : startsWith(github.ref, 'refs/tags/')
74
92
with :
75
93
token : ${{ secrets.GITHUB_TOKEN }}
76
- files : ${{ steps.naming.outputs.FILENAME }}
94
+ files : ${{ steps.naming.outputs.FILEPATH }}
77
95
78
96
- name : Done
79
97
if : startsWith(github.ref, 'refs/tags/')
0 commit comments