forked from zdz/ServerStatus-Rust
-
Notifications
You must be signed in to change notification settings - Fork 0
194 lines (174 loc) · 6.37 KB
/
Copy pathrelease.yml
File metadata and controls
194 lines (174 loc) · 6.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
name: Release
on:
push:
tags:
- "v*"
workflow_dispatch:
env:
CARGO_TERM_COLOR: always
jobs:
release:
name: Cross build for ${{ matrix.target }}
runs-on: ${{ matrix.os }}
permissions:
contents: write
strategy:
matrix:
include:
- os: ubuntu-latest
target: x86_64-unknown-linux-musl
suffix: ""
use-cross: true
cargo-flags: "--no-default-features --features stat_client/native"
- os: ubuntu-latest
target: aarch64-unknown-linux-musl
suffix: ""
use-cross: true
cargo-flags: "--no-default-features --features stat_client/native"
- os: ubuntu-latest
target: aarch64-linux-android
suffix: ""
use-cross: true
cargo-flags: ""
# 32bit
- os: ubuntu-latest
target: armv7-linux-androideabi
suffix: ""
use-cross: true
cargo-flags: ""
- os: ubuntu-latest
target: armv7-unknown-linux-musleabihf
suffix: ""
use-cross: true
cargo-flags: ""
- os: macos-latest
target: x86_64-apple-darwin
suffix: ""
use-cross: false
cargo-flags: ""
- os: macos-latest
target: aarch64-apple-darwin
suffix: ""
use-cross: true
cargo-flags: ""
- os: windows-latest
target: x86_64-pc-windows-msvc
suffix: .exe
use-cross: false
cargo-flags: ""
# - os: windows-latest
# target: x86_64-pc-windows-gnu
# suffix: .exe
# use-cross: false
# cargo-flags: ""
steps:
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1
with:
override: true
profile: minimal
toolchain: stable
target: ${{ matrix.target }}
- name: Install Protoc
if: matrix.os == 'windows-latest'
uses: arduino/setup-protoc@v1
with:
version: '3.x'
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Build release
uses: actions-rs/cargo@v1
with:
command: build
use-cross: ${{ matrix.use-cross }}
args: --locked --release --target=${{ matrix.target }} ${{ matrix.cargo-flags }}
- name: Strip (MacOS/Window)
if: matrix.os != 'ubuntu-latest'
continue-on-error: true
run: |
strip target/${{ matrix.target }}/release/stat_server${{matrix.suffix}}
strip target/${{ matrix.target }}/release/stat_client${{matrix.suffix}}
cp config.toml target/${{ matrix.target }}/release/
cp systemd/stat_server.service target/${{ matrix.target }}/release/
cp systemd/stat_client.service target/${{ matrix.target }}/release/
- name: LLVM Strip (Linux)
if: matrix.os == 'ubuntu-latest'
continue-on-error: true
run: |
sudo apt-get install -y llvm
llvm-strip target/${{ matrix.target }}/release/stat_server${{matrix.suffix}}
llvm-strip target/${{ matrix.target }}/release/stat_client${{matrix.suffix}}
cp config.toml target/${{ matrix.target }}/release/
cp systemd/stat_server.service target/${{ matrix.target }}/release/
cp systemd/stat_client.service target/${{ matrix.target }}/release/
- name: Compress binaries
# Upx may not support some platforms. Ignore the errors
continue-on-error: true
# Disable upx for mips. See https://github.com/upx/upx/issues/387
if: true && !contains(matrix.target, 'mips')
uses: svenstaro/upx-action@v2
with:
strip: false
args: -q --best --lzma
files: |
target/${{ matrix.target }}/release/stat_server${{matrix.suffix}}
target/${{ matrix.target }}/release/stat_client${{matrix.suffix}}
- uses: actions/upload-artifact@v3
with:
name: ServerStatus-${{ matrix.target }}
path: |
target/${{ matrix.target }}/release/stat_server${{matrix.suffix}}
target/${{ matrix.target }}/release/stat_client${{matrix.suffix}}
target/${{ matrix.target }}/release/config.toml
target/${{ matrix.target }}/release/stat_server.service
target/${{ matrix.target }}/release/stat_client.service
- name: Zip Release For Server (Linux)
if: matrix.os == 'ubuntu-latest' && contains(matrix.target, 'linux')
uses: TheDoctor0/zip-release@0.7.1
with:
type: zip
filename: server-${{ matrix.target }}.zip
directory: target/${{ matrix.target }}/release/
path: |
stat_server${{matrix.suffix}}
stat_server.service
config.toml
- name: Zip Release For Client (Linux)
if: matrix.os == 'ubuntu-latest' && contains(matrix.target, 'linux')
uses: TheDoctor0/zip-release@0.7.1
with:
type: zip
filename: client-${{ matrix.target }}.zip
directory: target/${{ matrix.target }}/release/
path: |
stat_client${{matrix.suffix}}
stat_client.service
- name: Zip Release For Server (MacOS/Window)
if: true && !contains(matrix.target, 'linux')
uses: TheDoctor0/zip-release@0.7.1
with:
type: zip
filename: server-${{ matrix.target }}.zip
directory: target/${{ matrix.target }}/release/
path: |
stat_server${{matrix.suffix}}
config.toml
- name: Zip Release For Client (MacOS/Window)
if: true && !contains(matrix.target, 'linux')
uses: TheDoctor0/zip-release@0.7.1
with:
type: zip
filename: client-${{ matrix.target }}.zip
directory: target/${{ matrix.target }}/release/
path: |
stat_client${{matrix.suffix}}
- name: Publish
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
files: |
target/${{ matrix.target }}/release/server-${{ matrix.target }}.zip
target/${{ matrix.target }}/release/client-${{ matrix.target }}.zip
generate_release_notes: true
draft: true