Repository navigation
132 lines (114 loc) · 4.01 KB
/
Copy pathrelease.yml
File metadata and controls
132 lines (114 loc) · 4.01 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
name: Release
on:
push:
tags:
- "v*"
workflow_dispatch:
env:
CARGO_TERM_COLOR: always
jobs:
# --- macOS 编译 ---
macos:
runs-on: macos-latest
name: macos (${{ matrix.platform.target }})
permissions:
contents: write
strategy:
fail-fast: false
matrix:
platform:
- target: "aarch64-apple-darwin"
- target: "x86_64-apple-darwin"
steps:
- uses: actions/checkout@v4
- name: Install Protoc
run: brew install protobuf
- uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.platform.target }}
- name: Build release
run: cargo build --release --target ${{ matrix.platform.target }}
- name: Strip & UPX
continue-on-error: true
run: |
strip target/${{ matrix.platform.target }}/release/stat_server
strip target/${{ matrix.platform.target }}/release/stat_client
shell: bash
- name: Package Release
run: |
python3 scripts/package_release.py --target ${{ matrix.platform.target }} --bin-dir target/${{ matrix.platform.target }}/release
shell: bash
- name: Upload binaries to GitHub Release
uses: softprops/action-gh-release@v2
if: startsWith(github.ref, 'refs/tags/') || github.event_name == 'workflow_dispatch'
with:
tag_name: ${{ github.ref_name }}
files: dist/*.zip
generate_release_notes: true
draft: false
# --- Linux, Android, Windows 编译 ---
cross-build:
name: Build for ${{ matrix.platform.target }}
runs-on: ${{ matrix.platform.os }}
permissions:
contents: write
strategy:
fail-fast: false
matrix:
platform:
- os: ubuntu-latest
target: x86_64-unknown-linux-musl
suffix: ""
use-cross: true
- os: ubuntu-latest
target: aarch64-unknown-linux-musl
suffix: ""
use-cross: true
- os: windows-latest
target: x86_64-pc-windows-msvc
suffix: .exe
use-cross: false
steps:
- uses: actions/checkout@v4
- name: Install Protoc
run: |
if [ "${{ matrix.platform.os }}" = "windows-latest" ]; then
choco install protoc --no-progress
else
sudo apt-get update && sudo apt-get install -y protobuf-compiler
fi
shell: bash
- uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.platform.target }}
- name: Install Cross
if: matrix.platform.use-cross
uses: taiki-e/install-action@cross
- name: Build release
run: |
if [ "${{ matrix.platform.use-cross }}" = "true" ]; then
cross build --release --target=${{ matrix.platform.target }}
else
cargo build --release --target=${{ matrix.platform.target }}
fi
shell: bash
- name: Strip & UPX
continue-on-error: true
uses: svenstaro/upx-action@v2
with:
files: |
target/${{ matrix.platform.target }}/release/stat_server${{matrix.platform.suffix}}
target/${{ matrix.platform.target }}/release/stat_client${{matrix.platform.suffix}}
args: --best --lzma
- name: Package Release
run: |
python3 scripts/package_release.py --target ${{ matrix.platform.target }} --bin-dir target/${{ matrix.platform.target }}/release --suffix "${{ matrix.platform.suffix }}" || python scripts/package_release.py --target ${{ matrix.platform.target }} --bin-dir target/${{ matrix.platform.target }}/release --suffix "${{ matrix.platform.suffix }}"
shell: bash
- name: Upload binaries to GitHub Release
uses: softprops/action-gh-release@v2
if: startsWith(github.ref, 'refs/tags/') || github.event_name == 'workflow_dispatch'
with:
tag_name: ${{ github.ref_name }}
files: dist/*.zip
generate_release_notes: true
draft: false