1
- name : build
1
+ name : release
2
2
3
3
on :
4
4
push :
5
- tags : ['v*.*.*']
5
+ tags : [ 'v*.*.*' ]
6
6
7
7
env :
8
8
CARGO_TERM_COLOR : always
9
- CARGO_TOKEN : ${{ secrets.CRATES_IO_TOKEN }}
9
+ CRATES_IO_TOKEN : ${{ secrets.CRATES_IO_TOKEN }}
10
10
NPM_TOKEN : ${{ secrets.NPM_ACCESS_TOKEN }}
11
11
12
12
jobs :
13
- release :
13
+ tests :
14
14
runs-on : ubuntu-latest
15
-
16
15
steps :
17
16
- name : Checkout
18
17
uses : actions/checkout@v1
19
-
20
18
- name : Run tests
21
19
run : cargo test --verbose
22
20
23
- - name : Install dependencies
24
- run : |
25
- sudo apt-get update
26
- sudo apt-get -y install gcc-mingw-w64-x86-64 gcc-mingw-w64-i686
27
- rustup target add x86_64-pc-windows-gnu
28
- rustup target add i686-pc-windows-gnu
29
- rustup target add x86_64-unknown-linux-gnu
30
- rustup target add x86_64-apple-darwin
31
- rustup target add aarch64-apple-darwin
32
- mkdir dist
33
- mkdir builds
34
-
35
-
36
- - name : Build Win64
37
- run : |
38
- cargo rustc --release --target=x86_64-pc-windows-gnu -- -C linker=x86_64-w64-mingw32-gcc
39
- mkdir builds/protofetch-win64
40
- cp target/x86_64-pc-windows-gnu/release/swp.exe builds/protofetch-win64
41
- tar -C builds -czvf dist/protofetch-win64.tar.gz protofetch-win64
21
+ release-linux :
22
+ runs-on : ubuntu-latest
23
+ needs : tests
24
+ steps :
25
+ - name : Checkout
26
+ uses : actions/checkout@v1
42
27
43
- - name : Build Win32
44
- run : |
45
- cargo rustc --release --target=i686-pc-windows-gnu -- -C linker=i686-w64-mingw32-gcc -C link-args=-mwindows -C panic=abort
46
- mkdir builds/protofetch-win32
47
- cp target/i686-pc-windows-gnu/release/swp.exe builds/protofetch-win32
48
- tar -C builds -czvf dist/protofetch-win32.tar.gz protofetch-win32
28
+ - name : Cache Rust dependencies
29
+
30
+ with :
31
+ path : target
32
+ key : ${{ runner.OS }}-build-${{ hashFiles('**/Cargo.lock') }}
33
+ restore-keys : |
34
+ ${{ runner.OS }}-build-
35
+
36
+ - name : Install stable toolchain linux
37
+ uses : actions-rs/toolchain@v1
38
+ with :
39
+ profile : minimal
40
+ toolchain : stable
41
+ override : true
49
42
50
- - name : Build Linux
43
+ - name : Build for release linux
51
44
run : |
52
- cargo rustc --release --target=x86_64-unknown-linux-gnu
53
- mkdir builds/protofetch_linux_amd64
54
- cp target/x86_64-unknown-linux-gnu/release/swp builds/protofetch_linux_amd64
55
- tar -C builds -czvf dist/protofetch_linux_amd64.tar.gz protofetch_linux_amd64
56
-
57
- - name : Cache Mac OS dependencies
58
- id : cache-macos
59
- uses : actions/cache@v1
45
+ cargo build --release
46
+ tar -czvf protofetch_linux_amd64.tar.gz target/release/protofetch
47
+
48
+ - name : Upload release
49
+ uses : softprops/action-gh-release@v1
50
+ with :
51
+ files : |
52
+ protofetch_linux_amd64.tar.gz
53
+
54
+ release-mac-arm :
55
+ runs-on : macos-latest
56
+ needs : tests
57
+ steps :
58
+ - name : Checkout
59
+ uses : actions/checkout@v1
60
+
61
+ - name : Cache Rust dependencies
62
+
63
+ with :
64
+ path : target
65
+ key : ${{ runner.OS }}-build-${{ hashFiles('**/Cargo.lock') }}
66
+ restore-keys : |
67
+ ${{ runner.OS }}-build-
68
+
69
+ - name : Install stable toolchain mac-arm64
70
+ uses : actions-rs/toolchain@v1
60
71
with :
61
- path : osxcross
62
- key : ${{ runner.os }}-osxcross
72
+ profile : minimal
73
+ toolchain : stable
74
+ override : true
75
+ target : aarch64-apple-darwin
63
76
64
- - name : Install Mac OS dependencies
65
- if : steps.cache-macos.outputs.cache-hit != 'true'
77
+ - name : Build for release mac-arm64
78
+ # We would need self-hosted arm runner for the correct target - for now we use `vendored-openssl` feature on `git2-rs dependency to overcome it
66
79
run : |
67
- git clone https://github.com/tpoechtrager/osxcross
68
- cd osxcross
69
- sudo tools/get_dependencies.sh
70
- wget -nc https://s3.dockerproject.org/darwin/v2/MacOSX10.10.sdk.tar.xz
71
- mv MacOSX10.10.sdk.tar.xz tarballs/
72
- UNATTENDED=yes OSX_VERSION_MIN=10.7 ./build.sh
73
-
74
- - name : Build Mac OS amd64
80
+ cargo build --release # --target=aarch64-apple-darwin
81
+ tar -czvf protofetch_darwin_arm64.tar.gz target/release/protofetch
82
+
83
+ - name : Upload release
84
+ uses : softprops/action-gh-release@v1
85
+ with :
86
+ files : |
87
+ protofetch_darwin_arm64.tar.gz
88
+
89
+ release-mac-amd :
90
+ runs-on : macos-latest
91
+ needs : tests
92
+ steps :
93
+ - name : Checkout
94
+ uses : actions/checkout@v1
95
+
96
+ - name : Cache Rust dependencies
97
+
98
+ with :
99
+ path : target
100
+ key : ${{ runner.OS }}-build-${{ hashFiles('**/Cargo.lock') }}
101
+ restore-keys : |
102
+ ${{ runner.OS }}-build-
103
+
104
+ - name : Install stable toolchain mac-amd64
105
+ uses : actions-rs/toolchain@v1
106
+ with :
107
+ profile : minimal
108
+ toolchain : stable
109
+ override : true
110
+ target : x86_64-apple-darwin
111
+
112
+ - name : Build for release mac-amd64
75
113
run : |
76
- export PATH="$(pwd)/osxcross/target/bin:$PATH"
77
- export LIBZ_SYS_STATIC=1
78
- export CC=o64-clang
79
- export CXX=o64-clang++
80
- cargo build --release --target "x86_64-apple-darwin"
81
- mkdir builds/protofetch_darwin_amd64
82
- cp target/x86_64-apple-darwin/release/swp builds/protofetch_darwin_amd64
83
- tar -C builds -czvf dist/protofetch_darwin_amd64.tar.gz protofetch_darwin_amd64
84
-
85
- - name : Build Mac OS arm64
114
+ cargo build --release
115
+ tar -czvf protofetch_darwin_amd64.tar.gz target/release/protofetch
116
+
117
+ - name : Upload release
118
+ uses : softprops/action-gh-release@v1
119
+ with :
120
+ files : |
121
+ protofetch_darwin_amd64.tar.gz
122
+
123
+ release-windows :
124
+ runs-on : windows-latest
125
+ needs : tests
126
+ steps :
127
+ - name : Checkout
128
+ uses : actions/checkout@v1
129
+
130
+ - name : Cache Rust dependencies
131
+
132
+ with :
133
+ path : target
134
+ key : ${{ runner.OS }}-build-${{ hashFiles('**/Cargo.lock') }}
135
+ restore-keys : |
136
+ ${{ runner.OS }}-build-
137
+
138
+ - name : Install stable toolchain win64
139
+ uses : actions-rs/toolchain@v1
140
+ with :
141
+ profile : minimal
142
+ toolchain : stable
143
+ override : true
144
+ target : x86_64-pc-windows-gnu
145
+
146
+ - name : Build for release win64
86
147
run : |
87
- export PATH="$(pwd)/osxcross/target/bin:$PATH"
88
- export LIBZ_SYS_STATIC=1
89
- export CC=o64-clang
90
- export CXX=o64-clang++
91
- cargo build --release --target "aarch64-apple-darwin"
92
- mkdir builds/protofetch_darwin_arm64
93
- cp target/aarch64-apple-darwin/release/swp builds/protofetch_darwin_arm64
94
- tar -C builds -czvf dist/protofetch_darwin_arm64.tar.gz protofetch_darwin_arm64
148
+ cargo build --release
149
+ tar -czvf protofetch_win64.tar.gz target/release/protofetch.exe
95
150
96
151
- name : Upload release
97
152
uses : softprops/action-gh-release@v1
98
153
with :
99
154
files : |
100
- dist/protofetch-win64.tar.gz
101
- dist/protofetch-win32.tar.gz
102
- dist/protofetch_linux_amd64.tar.gz
103
- dist/protofetch_darwin_amd64.tar.gz
104
- dist/protofetch_darwin_arm64.tar.gz
155
+ protofetch_win64.tar.gz
156
+
157
+ npm-release :
158
+ runs-on : ubuntu-latest
159
+ needs : [ release-mac-amd, release-mac-arm, release-linux, release-windows, tests ]
160
+ steps :
161
+ - name : Checkout
162
+ uses : actions/checkout@v1
105
163
106
164
- name : Publish npm package
107
165
run : |
@@ -110,9 +168,12 @@ jobs:
110
168
echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > ".npmrc"
111
169
npm publish
112
170
171
+ crates-io :
172
+ runs-on : ubuntu-latest
173
+ needs : tests
174
+ steps :
175
+ - name : Checkout
176
+ uses : actions/checkout@v1
177
+
113
178
- name : Publish cargo package
114
- env :
115
- CARGO_ACCESS_TOKEN : ${{ secrets.CARGO_ACCESS_TOKEN }}
116
- run : |
117
- cargo login "$CARGO_ACCESS_TOKEN"
118
- cargo publish
179
+ run : cargo publish --token ${{ env.CARGO_TOKEN }}
0 commit comments