-
Notifications
You must be signed in to change notification settings - Fork 2
235 lines (195 loc) · 7.63 KB
/
release.yml
File metadata and controls
235 lines (195 loc) · 7.63 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
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
name: Build and Release
on:
push:
tags:
- 'v*.*.*'
workflow_dispatch:
inputs:
version:
description: 'Release version (e.g., v1.0.0)'
required: true
default: 'v0.1.0'
permissions:
contents: write
env:
CARGO_TERM_COLOR: always
jobs:
build:
name: Build on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- os: windows-latest
target: x86_64-pc-windows-msvc
artifact_name: netassistant.exe
asset_name: netassistant-windows-x86_64
- os: ubuntu-22.04
target: x86_64-unknown-linux-gnu
artifact_name: netassistant
asset_name: netassistant-linux-x86_64
- os: macos-latest
target: x86_64-apple-darwin
artifact_name: netassistant
asset_name: netassistant-macos-x86_64
- os: macos-latest
target: aarch64-apple-darwin
artifact_name: netassistant
asset_name: netassistant-macos-aarch64
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Get Rust version
id: rust-version
run: echo "VERSION=$(rustc --version)" >> $GITHUB_OUTPUT
- name: Install Rust targets
run: |
rustup target add ${{ matrix.target }}
- name: Cache cargo registry
uses: actions/cache@v4
with:
path: ~/.cargo/registry
key: ${{ runner.os }}-cargo-registry-${{ steps.rust-version.outputs.VERSION }}-${{ hashFiles('**/Cargo.lock') }}
- name: Cache cargo index
uses: actions/cache@v4
with:
path: ~/.cargo/git
key: ${{ runner.os }}-cargo-index-${{ steps.rust-version.outputs.VERSION }}-${{ hashFiles('**/Cargo.lock') }}
- name: Cache cargo build
uses: actions/cache@v4
with:
path: target
key: ${{ runner.os }}-cargo-build-target-${{ matrix.target }}-${{ steps.rust-version.outputs.VERSION }}-${{ hashFiles('**/Cargo.lock') }}
- name: Install dependencies (Ubuntu)
if: matrix.os == 'ubuntu-22.04'
run: |
sudo apt-get update
sudo apt-get install -y libgtk-3-dev libwebkit2gtk-4.1-dev libappindicator3-dev librsvg2-dev patchelf libxkbcommon-x11-dev
- name: Install dependencies (macOS)
if: matrix.os == 'macos-latest'
run: |
brew install openssl
- name: Build release
env:
BUILD_VERSION: ${{ inputs.version || github.ref_name }}
run: |
cargo build --release --target ${{ matrix.target }}
- name: Prepare artifact (Windows)
if: matrix.os == 'windows-latest'
shell: pwsh
run: |
Copy-Item target\${{ matrix.target }}\release\netassistant.exe netassistant.exe
Compress-Archive -Path netassistant.exe -DestinationPath ${{ matrix.asset_name }}.zip
- name: Prepare artifact (Unix)
if: matrix.os != 'windows-latest'
run: |
strip target/${{ matrix.target }}/release/netassistant || true
tar -czf ${{ matrix.asset_name }}.tar.gz -C target/${{ matrix.target }}/release netassistant
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.asset_name }}
path: ${{ matrix.os == 'windows-latest' && format('{0}.zip', matrix.asset_name) || format('{0}.tar.gz', matrix.asset_name) }}
release:
name: Create Release
needs: build
runs-on: ubuntu-latest
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
- name: Display structure of downloaded files
run: ls -R artifacts
- name: Get version from tag
id: get_version
run: echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
- name: Get commit history between tags
id: get_commits
run: |
# Get current tag
CURRENT_TAG=${GITHUB_REF#refs/tags/}
# Get all tags sorted by version
ALL_TAGS=$(git tag -l | sort -Vr)
# Find previous tag
PREVIOUS_TAG=""
found_current=false
for tag in $ALL_TAGS; do
if [ "$found_current" = true ]; then
PREVIOUS_TAG=$tag
break
fi
if [ "$tag" = "$CURRENT_TAG" ]; then
found_current=true
fi
done
# Get repository URL
REPO_URL=$(git config --get remote.origin.url | sed 's/\.git$//')
# Get commits
if [ -z "$PREVIOUS_TAG" ]; then
# If no previous tag, get all commits
COMMITS=$(git log --pretty=format:"%H %s" --no-merges)
else
# Get commits between previous tag and current tag
COMMITS=$(git log $PREVIOUS_TAG..$CURRENT_TAG --pretty=format:"%H %s" --no-merges)
fi
# Filter and format commits
FORMATTED_COMMITS=$(echo "$COMMITS" | while IFS= read -r line; do
hash=$(echo "$line" | cut -d ' ' -f 1)
msg=$(echo "$line" | cut -d ' ' -f 2-)
if [[ ! "$msg" =~ ^build: && ! "$msg" =~ ^doc: ]]; then
echo "- [$msg]($REPO_URL/commit/$hash)"
fi
done)
# Store commits in output
echo "COMMITS<<EOF" >> $GITHUB_OUTPUT
echo "$FORMATTED_COMMITS" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
- name: Create Release
uses: softprops/action-gh-release@v1
with:
files: artifacts/*/*
name: Release ${{ steps.get_version.outputs.VERSION }}
body: |
## NetAssistant ${{ steps.get_version.outputs.VERSION }}
### 下载说明
- **Windows**: 下载 `netassistant-windows-x86_64.zip`
- **Linux**: 下载 `netassistant-linux-x86_64.tar.gz`
- **macOS (Intel)**: 下载 `netassistant-macos-x86_64.tar.gz`
- **macOS (Apple Silicon)**: 下载 `netassistant-macos-aarch64.tar.gz`
### 安装方法
#### Windows
1. **推荐方法:使用 winget 安装**
- 安装:`winget install SunJary.NetAssistant`
- 升级:`winget upgrade SunJary.NetAssistant`
2. **备选方法:手动安装**
- 下载并解压 `netassistant-windows-x86_64.zip`
- 运行 `netassistant.exe`
#### Linux
1. 下载并解压 `netassistant-linux-x86_64.tar.gz`
2. 添加执行权限:`chmod +x netassistant`
3. 运行:`./netassistant`
#### macOS
1. 下载对应的 macOS 版本
2. 解压:`tar -xzf netassistant-macos-*.tar.gz`
3. 添加执行权限:`chmod +x netassistant`
4. 运行:`./netassistant`
### 系统要求
- Windows 10 或更高版本
- Linux (需要 GTK3 库)
- macOS 10.15 或更高版本
### 更新内容
${{ steps.get_commits.outputs.COMMITS }}
draft: false
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}