6
6
- ' v[0-9]+.[0-9]+.[0-9]'
7
7
workflow_dispatch :
8
8
9
+ permissions :
10
+ contents : write
11
+
9
12
jobs :
10
- build-nix :
11
- env :
12
- IN_PIPELINE : true
13
+ build-and-upload :
14
+ name : Build and upload
13
15
runs-on : ${{ matrix.os }}
16
+
14
17
strategy :
15
18
matrix :
16
- type : [ubuntu-x64, ubuntu-x86, armv7, aarch64]
19
+ # You can add more, for any target you'd like!
17
20
include :
18
- - type : ubuntu-x64
21
+ - build : linux
19
22
os : ubuntu-latest
20
23
target : x86_64-unknown-linux-musl
21
- name : anew-linux
22
- path : target/x86_64-unknown-linux-musl/release/anew
23
- pkg_config_path : /usr/lib/x86_64-linux-gnu/pkgconfig
24
- - type : ubuntu-x86
25
- os : ubuntu-latest
26
- target : i686-unknown-linux-musl
27
- name : anew-linux-i386
28
- path : target/i686-unknown-linux-musl/release/anew
29
- pkg_config_path : /usr/lib/i686-linux-gnu/pkgconfig
30
- - type : armv7
31
- os : ubuntu-latest
32
- target : armv7-unknown-linux-gnueabihf
33
- name : anew-armv7
34
- path : target/armv7-unknown-linux-gnueabihf/release/anew
35
- pkg_config_path : /usr/lib/x86_64-linux-gnu/pkgconfig
36
- - type : aarch64
37
- os : ubuntu-latest
38
- target : aarch64-unknown-linux-gnu
39
- name : anew-aarch64
40
- path : target/aarch64-unknown-linux-gnu/release/anew
41
- pkg_config_path : /usr/lib/x86_64-linux-gnu/pkgconfig
42
- steps :
43
- - uses : actions/checkout@v2
44
- - name : Install System Dependencies
45
- run : |
46
- env
47
- sudo apt-get update
48
- sudo apt-get install -y --no-install-recommends libssl-dev pkg-config gcc-arm-linux-gnueabihf gcc-aarch64-linux-gnu
49
- - uses : actions-rs/toolchain@v1
50
- with :
51
- toolchain : stable
52
- target : ${{ matrix.target }}
53
- override : true
54
- - uses : actions-rs/cargo@v1
55
- env :
56
- PKG_CONFIG_PATH : ${{ matrix.pkg_config_path }}
57
- OPENSSL_DIR : /usr/lib/ssl
58
- with :
59
- use-cross : true
60
- command : build
61
- args : --release --target=${{ matrix.target }}
62
- - name : Strip symbols from binary
63
- run : |
64
- strip -s ${{ matrix.path }} || arm-linux-gnueabihf-strip -s ${{ matrix.path }} || aarch64-linux-gnu-strip -s ${{ matrix.path }}
65
- - uses : actions/upload-artifact@v2
66
- with :
67
- name : ${{ matrix.name }}
68
- path : ${{ matrix.path }}
69
-
70
- build-macos :
71
- strategy :
72
- matrix :
73
- target : [x86_64-apple-darwin, aarch64-apple-darwin]
74
- include :
75
- - target : x86_64-apple-darwin
76
- arch : x86_64
77
- - target : aarch64-apple-darwin
78
- arch : arm64
79
- env :
80
- IN_PIPELINE : true
81
- runs-on : macos-latest
82
- steps :
83
- - uses : actions/checkout@v2
84
- - uses : actions-rs/toolchain@v1
85
- with :
86
- toolchain : stable
87
- target : ${{ matrix.target }}
88
- override : true
89
- - uses : actions-rs/cargo@v1
90
- with :
91
- use-cross : true
92
- command : build
93
- args : --release --target=${{ matrix.target }}
94
- - name : Strip symbols from binary
95
- run : |
96
- strip -u -r target/${{ matrix.target }}/release/anew
97
- - uses : actions/upload-artifact@v2
98
- with :
99
- name : anew-osx-${{ matrix.arch }}
100
- path : target/${{ matrix.target }}/release/anew
101
-
102
- build-windows :
103
- env :
104
- IN_PIPELINE : true
105
- runs-on : ${{ matrix.os }}
106
- strategy :
107
- matrix :
108
- type : [windows-x64, windows-x86]
109
- include :
110
- - type : windows-x64
24
+ - build : macos
25
+ os : macos-latest
26
+ target : x86_64-apple-darwin
27
+ - build : windows
111
28
os : windows-latest
112
29
target : x86_64-pc-windows-msvc
113
- name : anew-windows.exe
114
- path : target\x86_64-pc-windows-msvc\release\anew.exe
115
- - type : windows-x86
116
- os : windows-latest
117
- target : i686-pc-windows-msvc
118
- name : anew-windows-i686.exe
119
- path : target\i686-pc-windows-msvc\release\anew.exe
30
+
120
31
steps :
121
- - uses : actions/checkout@v2
122
- - uses : actions-rs/toolchain@v1
32
+ - name : Checkout
33
+ uses : actions/checkout@v3
34
+
35
+ - name : Get the release version from the tag
36
+ shell : bash
37
+ run : echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
38
+
39
+ - name : Install Rust
40
+ # Or @nightly if you want
41
+ uses : dtolnay/rust-toolchain@stable
42
+ # Arguments to pass in
123
43
with :
124
- toolchain : stable
125
- target : ${{ matrix.target }}
126
- override : true
127
- - uses : actions-rs/cargo@v1
44
+ # Make Rust compile to our target (defined in the matrix)
45
+ targets : ${{ matrix.target }}
46
+
47
+ - name : Build
48
+ uses : actions-rs/cargo@v1
128
49
with :
129
50
use-cross : true
130
51
command : build
131
- args : --release --target=${{ matrix.target }}
132
- - uses : actions/upload-artifact@v2
133
- with :
134
- name : ${{ matrix.name }}
135
- path : ${{ matrix.path }}
136
- create-release :
137
- # 确保这个任务在所有构建任务完成后执行
138
- needs : [build-nix, build-macos, build-windows]
139
- runs-on : ubuntu-latest
140
- # 这个任务只在标签推送时执行
141
- if : startsWith(github.ref, 'refs/tags/')
52
+ args : --verbose --release --target ${{ matrix.target }}
142
53
143
- steps :
144
- - name : Checkout code
145
- uses : actions/checkout@v2
54
+ - name : Build archive
55
+ shell : bash
56
+ run : |
57
+ # Replace with the name of your binary
58
+ binary_name="anew"
146
59
147
- - name : Download all artifacts
148
- uses : actions/download-artifact@v2
149
- with :
150
- path : artifacts
60
+ dirname="$binary_name-${{ env.VERSION }}-${{ matrix.target }}"
61
+ mkdir "$dirname"
62
+ if [ "${{ matrix.os }}" = "windows-latest" ]; then
63
+ mv "target/${{ matrix.target }}/release/$binary_name.exe" "$dirname"
64
+ else
65
+ mv "target/${{ matrix.target }}/release/$binary_name" "$dirname"
66
+ fi
151
67
152
- - name : List Files
153
- run : |
154
- ls artifacts
68
+ if [ "${{ matrix.os }}" = "windows-latest" ]; then
69
+ 7z a "$dirname.zip" "$dirname"
70
+ echo "ASSET=$dirname.zip" >> $GITHUB_ENV
71
+ else
72
+ tar -czf "$dirname.tar.gz" "$dirname"
73
+ echo "ASSET=$dirname.tar.gz" >> $GITHUB_ENV
74
+ fi
155
75
156
- - name : Create Release
76
+ - name : Release
157
77
uses : softprops/action-gh-release@v1
158
78
with :
159
79
files : |
160
- ${{ github.workspace }}/artifacts/*
161
- tag_name : ${{ github.ref == 'refs/tags/' && github.ref || 'heads/' && github.ref_name }}
162
- env :
163
- GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
80
+ ${{ env.ASSET }}
0 commit comments