Skip to content

Commit cc22cdd

Browse files
committed
ci(release): 添加 macOS x86_64 构建和包管理器支持
- 在 macOS 构建作业中引入矩阵策略,同时构建 ARM64 和 x86_64 架构 - 更新发布说明,添加 Homebrew 和 cargo-binstall 安装说明 - 新增 Homebrew 公式自动更新工作流,在发布稳定版时同步 - 在 Cargo.toml 中添加 cargo-binstall 配置,支持多平台二进制分发 - 更新版本至 0.3.0-beta.3 并同步更新 CHANGELOG
1 parent 3f7f44c commit cc22cdd

4 files changed

Lines changed: 202 additions & 9 deletions

File tree

.github/workflows/rust-release.yml

Lines changed: 142 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,13 @@ jobs:
149149
build-macos:
150150
needs: build-frontend
151151
runs-on: macos-latest
152+
strategy:
153+
matrix:
154+
include:
155+
- target: aarch64-apple-darwin
156+
name: macos_aarch64
157+
- target: x86_64-apple-darwin
158+
name: macos_x86_64
152159
steps:
153160
- uses: actions/checkout@v4
154161

@@ -159,25 +166,25 @@ jobs:
159166

160167
- uses: dtolnay/rust-toolchain@stable
161168
with:
162-
targets: aarch64-apple-darwin
169+
targets: ${{ matrix.target }}
163170

164171
- uses: Swatinem/rust-cache@v2
165172
with:
166-
key: aarch64-apple-darwin
173+
key: ${{ matrix.target }}
167174

168175
- name: Build
169176
env:
170177
RUSTFLAGS: "-C link-arg=-s"
171-
run: cargo build --release --target aarch64-apple-darwin --all-features
178+
run: cargo build --release --target ${{ matrix.target }} --all-features
172179

173180
- name: Rename binary
174181
run: |
175182
VERSION="${GITHUB_REF#refs/tags/}"
176-
mv target/aarch64-apple-darwin/release/shortlinker "shortlinker_${VERSION}_macos_aarch64"
183+
mv target/${{ matrix.target }}/release/shortlinker "shortlinker_${VERSION}_${{ matrix.name }}"
177184
178185
- uses: actions/upload-artifact@v4
179186
with:
180-
name: binary-macos_aarch64
187+
name: binary-${{ matrix.name }}
181188
path: shortlinker_*
182189

183190
release:
@@ -223,13 +230,26 @@ jobs:
223230
224231
---
225232
226-
## Downloads
233+
## Installation
234+
235+
### Homebrew (macOS/Linux)
236+
```bash
237+
brew install AptS-1547/tap/shortlinker
238+
```
239+
240+
### Cargo Binstall
241+
```bash
242+
cargo binstall shortlinker
243+
```
244+
245+
### Manual Download
227246
228247
| Platform | Architecture | Download |
229248
|----------|--------------|----------|
230249
| Linux | x86_64 | [shortlinker_${{ github.ref_name }}_linux_x86_64](https://github.com/${{ github.repository }}/releases/download/${{ github.ref_name }}/shortlinker_${{ github.ref_name }}_linux_x86_64) |
231250
| Linux | ARM64 | [shortlinker_${{ github.ref_name }}_linux_aarch64](https://github.com/${{ github.repository }}/releases/download/${{ github.ref_name }}/shortlinker_${{ github.ref_name }}_linux_aarch64) |
232251
| Windows | x86_64 | [shortlinker_${{ github.ref_name }}_windows_x86_64.exe](https://github.com/${{ github.repository }}/releases/download/${{ github.ref_name }}/shortlinker_${{ github.ref_name }}_windows_x86_64.exe) |
252+
| macOS | x86_64 | [shortlinker_${{ github.ref_name }}_macos_x86_64](https://github.com/${{ github.repository }}/releases/download/${{ github.ref_name }}/shortlinker_${{ github.ref_name }}_macos_x86_64) |
233253
| macOS | ARM64 | [shortlinker_${{ github.ref_name }}_macos_aarch64](https://github.com/${{ github.repository }}/releases/download/${{ github.ref_name }}/shortlinker_${{ github.ref_name }}_macos_aarch64) |
234254
| Admin Panel | - | [shortlinker-admin-panel_${{ github.ref_name }}.tar.gz](https://github.com/${{ github.repository }}/releases/download/${{ github.ref_name }}/shortlinker-admin-panel_${{ github.ref_name }}.tar.gz) |
235255
@@ -239,3 +259,119 @@ jobs:
239259
prerelease: ${{ contains(github.ref_name, 'alpha') || contains(github.ref_name, 'beta') || contains(github.ref_name, 'rc') }}
240260
env:
241261
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
262+
263+
update-homebrew:
264+
name: Update Homebrew Tap
265+
needs: release
266+
runs-on: ubuntu-latest
267+
# 只在非预发布版本时更新 Homebrew
268+
if: ${{ !contains(github.ref_name, 'alpha') && !contains(github.ref_name, 'beta') && !contains(github.ref_name, 'rc') }}
269+
steps:
270+
- name: Download release assets and calculate SHA256
271+
id: sha256
272+
run: |
273+
VERSION="${GITHUB_REF#refs/tags/}"
274+
BASE_URL="https://github.com/${{ github.repository }}/releases/download/${VERSION}"
275+
276+
curl -sL "${BASE_URL}/shortlinker_${VERSION}_macos_aarch64" -o macos-arm64
277+
curl -sL "${BASE_URL}/shortlinker_${VERSION}_macos_x86_64" -o macos-amd64
278+
curl -sL "${BASE_URL}/shortlinker_${VERSION}_linux_aarch64" -o linux-arm64
279+
curl -sL "${BASE_URL}/shortlinker_${VERSION}_linux_x86_64" -o linux-amd64
280+
281+
echo "macos_arm64=$(sha256sum macos-arm64 | cut -d' ' -f1)" >> $GITHUB_OUTPUT
282+
echo "macos_amd64=$(sha256sum macos-amd64 | cut -d' ' -f1)" >> $GITHUB_OUTPUT
283+
echo "linux_arm64=$(sha256sum linux-arm64 | cut -d' ' -f1)" >> $GITHUB_OUTPUT
284+
echo "linux_amd64=$(sha256sum linux-amd64 | cut -d' ' -f1)" >> $GITHUB_OUTPUT
285+
286+
- name: Update Homebrew Formula
287+
uses: actions/github-script@v7
288+
with:
289+
github-token: ${{ secrets.HOMEBREW_TAP_TOKEN }}
290+
script: |
291+
const version = '${{ github.ref_name }}'.replace(/^v/, '');
292+
const tagVersion = '${{ github.ref_name }}';
293+
const sha256 = {
294+
macos_arm64: '${{ steps.sha256.outputs.macos_arm64 }}',
295+
macos_amd64: '${{ steps.sha256.outputs.macos_amd64 }}',
296+
linux_arm64: '${{ steps.sha256.outputs.linux_arm64 }}',
297+
linux_amd64: '${{ steps.sha256.outputs.linux_amd64 }}'
298+
};
299+
300+
const formula = `# typed: false
301+
# frozen_string_literal: true
302+
303+
class Shortlinker < Formula
304+
desc "A minimalist URL shortener service supporting HTTP 307 redirection"
305+
homepage "https://github.com/AptS-1547/shortlinker"
306+
version "${version}"
307+
license "MIT"
308+
309+
on_macos do
310+
on_arm do
311+
url "https://github.com/AptS-1547/shortlinker/releases/download/${tagVersion}/shortlinker_${tagVersion}_macos_aarch64"
312+
sha256 "${sha256.macos_arm64}"
313+
314+
def install
315+
bin.install "shortlinker_${tagVersion}_macos_aarch64" => "shortlinker"
316+
end
317+
end
318+
319+
on_intel do
320+
url "https://github.com/AptS-1547/shortlinker/releases/download/${tagVersion}/shortlinker_${tagVersion}_macos_x86_64"
321+
sha256 "${sha256.macos_amd64}"
322+
323+
def install
324+
bin.install "shortlinker_${tagVersion}_macos_x86_64" => "shortlinker"
325+
end
326+
end
327+
end
328+
329+
on_linux do
330+
on_arm do
331+
url "https://github.com/AptS-1547/shortlinker/releases/download/${tagVersion}/shortlinker_${tagVersion}_linux_aarch64"
332+
sha256 "${sha256.linux_arm64}"
333+
334+
def install
335+
bin.install "shortlinker_${tagVersion}_linux_aarch64" => "shortlinker"
336+
end
337+
end
338+
339+
on_intel do
340+
url "https://github.com/AptS-1547/shortlinker/releases/download/${tagVersion}/shortlinker_${tagVersion}_linux_x86_64"
341+
sha256 "${sha256.linux_amd64}"
342+
343+
def install
344+
bin.install "shortlinker_${tagVersion}_linux_x86_64" => "shortlinker"
345+
end
346+
end
347+
end
348+
349+
test do
350+
assert_match version.to_s, shell_output("#{bin}/shortlinker --version")
351+
end
352+
end
353+
`.split('\n').map(line => line.replace(/^ /, '')).join('\n');
354+
355+
// Get current file (if exists) to get its SHA
356+
let fileSha;
357+
try {
358+
const { data } = await github.rest.repos.getContent({
359+
owner: 'AptS-1547',
360+
repo: 'homebrew-tap',
361+
path: 'Formula/shortlinker.rb'
362+
});
363+
fileSha = data.sha;
364+
} catch (e) {
365+
// File doesn't exist yet
366+
fileSha = undefined;
367+
}
368+
369+
// Create or update the formula file
370+
await github.rest.repos.createOrUpdateFileContents({
371+
owner: 'AptS-1547',
372+
repo: 'homebrew-tap',
373+
path: 'Formula/shortlinker.rb',
374+
message: `chore: bump shortlinker to ${tagVersion}`,
375+
content: Buffer.from(formula).toString('base64'),
376+
sha: fileSha
377+
});

CHANGELOG.md

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,34 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [v0.3.0-beta.3] - 2026-01-18
9+
10+
### Added
11+
- **ClickManager 性能基准测试** - 新增 criterion 基准测试套件
12+
- 包括单线程/多线程 increment、不同 key 场景和 drain 操作的性能测试
13+
- 添加并发 increment 和 increment+drain 场景的单元测试,验证数据一致性
14+
- **cargo-binstall 支持** - 用户可通过 `cargo binstall shortlinker` 直接安装预编译二进制
15+
- **Homebrew 发布支持** - 用户可通过 `brew install AptS-1547/tap/shortlinker` 安装
16+
- **macOS x86_64 (Intel Mac) 构建** - Release 现已支持 Intel Mac 平台
17+
18+
### Fixed
19+
- **ClickBuffer 数据竞争修复** - 重构 `drain` 方法,通过先快照 key 再逐个删除的方式避免数据竞争 (#40, #41)
20+
- **刷盘失败恢复机制** - 新增 `restore` 方法,刷盘失败时自动将数据写回缓冲区,避免数据丢失
21+
- **ClickBuffer 竞态条件修复** - 使用 `entry` API 重构 `increment` 方法,消除检查后插入(TOCTOU)的竞态条件
22+
- **点击计数下溢防护** - 将 `fetch_sub` 替换为 `fetch_update`,确保总点击数减法操作不会下溢
23+
24+
### Docs
25+
- 更新健康检查 API 鉴权逻辑文档
26+
- 更新短链接路径格式约束说明
27+
- 更新配置项说明:CORS 默认禁用、Cookie 配置热更新说明
28+
- 更新存储配置文档:移除 `DATABASE_BACKEND` 说明,明确从 `DATABASE_URL` 自动推断
29+
- 更新部署要求:Rust 版本提升至 1.85+ (Edition 2024)
30+
- 同步更新英文文档
31+
32+
### Dependencies
33+
- 添加 `criterion` 依赖用于基准测试
34+
- 升级 `colored` 至 3.1.1
35+
836
## [v0.3.0-beta.2] - 2026-01-16
937

1038
### Added
@@ -722,7 +750,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
722750
- Update README.md
723751
- Initial commit
724752

725-
[Unreleased]: https://github.com/AptS-1547/shortlinker/compare/v0.3.0-beta.2...HEAD
753+
[Unreleased]: https://github.com/AptS-1547/shortlinker/compare/v0.3.0-beta.3...HEAD
754+
[v0.3.0-beta.3]: https://github.com/AptS-1547/shortlinker/compare/v0.3.0-beta.2...v0.3.0-beta.3
726755
[v0.3.0-beta.2]: https://github.com/AptS-1547/shortlinker/compare/v0.3.0-beta.1...v0.3.0-beta.2
727756
[v0.3.0-beta.1]: https://github.com/AptS-1547/shortlinker/compare/v0.3.0-alpha.7...v0.3.0-beta.1
728757
[v0.3.0-alpha.7]: https://github.com/AptS-1547/shortlinker/compare/v0.3.0-alpha.6...v0.3.0-alpha.7

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
[package]
22
name = "shortlinker"
3-
version = "0.3.0-beta.2"
3+
version = "0.3.0-beta.3"
44
description = "A minimalist URL shortener service supporting HTTP 307 redirection, built with Rust. Easy to deploy and lightning fast."
55
authors = ["AptS-1547 <apts-1547@esaps.net>"]
6+
repository = "https://github.com/AptS-1547/shortlinker"
67
edition = "2024"
78

89
[features]
@@ -111,3 +112,30 @@ criterion = { version = "0.5", features = ["async_tokio"] }
111112
[[bench]]
112113
name = "click_manager"
113114
harness = false
115+
116+
# cargo-binstall 配置
117+
[package.metadata.binstall]
118+
pkg-url = "{ repo }/releases/download/{ version }/shortlinker_{ version }_{ target }{ binary-ext }"
119+
bin-dir = "shortlinker_{ version }_{ target }{ binary-ext }"
120+
pkg-fmt = "bin"
121+
122+
[package.metadata.binstall.overrides.x86_64-apple-darwin]
123+
pkg-url = "{ repo }/releases/download/{ version }/shortlinker_{ version }_macos_x86_64"
124+
125+
[package.metadata.binstall.overrides.aarch64-apple-darwin]
126+
pkg-url = "{ repo }/releases/download/{ version }/shortlinker_{ version }_macos_aarch64"
127+
128+
[package.metadata.binstall.overrides.x86_64-unknown-linux-gnu]
129+
pkg-url = "{ repo }/releases/download/{ version }/shortlinker_{ version }_linux_x86_64"
130+
131+
[package.metadata.binstall.overrides.x86_64-unknown-linux-musl]
132+
pkg-url = "{ repo }/releases/download/{ version }/shortlinker_{ version }_linux_x86_64"
133+
134+
[package.metadata.binstall.overrides.aarch64-unknown-linux-gnu]
135+
pkg-url = "{ repo }/releases/download/{ version }/shortlinker_{ version }_linux_aarch64"
136+
137+
[package.metadata.binstall.overrides.x86_64-pc-windows-gnu]
138+
pkg-url = "{ repo }/releases/download/{ version }/shortlinker_{ version }_windows_x86_64.exe"
139+
140+
[package.metadata.binstall.overrides.x86_64-pc-windows-msvc]
141+
pkg-url = "{ repo }/releases/download/{ version }/shortlinker_{ version }_windows_x86_64.exe"

0 commit comments

Comments
 (0)