Skip to content

Commit bd771f4

Browse files
committed
feat: add automated upstream version sync workflow
1 parent fa20e7e commit bd771f4

File tree

5 files changed

+229
-1
lines changed

5 files changed

+229
-1
lines changed
Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
name: Upstream Sync
2+
3+
# 当上游 rustfs/rustfs 发布新版本时,自动触发构建
4+
on:
5+
# 定时检查上游版本(每天UTC时间6点,北京时间14点)
6+
schedule:
7+
- cron: '0 6 * * *'
8+
9+
# 支持手动触发
10+
workflow_dispatch:
11+
inputs:
12+
force_build:
13+
description: '强制构建(即使版本未变化)'
14+
required: false
15+
type: boolean
16+
default: false
17+
18+
jobs:
19+
check-upstream:
20+
name: 检查上游版本
21+
runs-on: ubuntu-latest
22+
permissions:
23+
contents: write # 需要写权限来创建 tag
24+
outputs:
25+
has_new_version: ${{ steps.compare.outputs.has_new_version }}
26+
upstream_version: ${{ steps.upstream.outputs.version }}
27+
should_build: ${{ steps.compare.outputs.should_build }}
28+
29+
steps:
30+
- name: Checkout repository
31+
uses: actions/checkout@v4
32+
with:
33+
fetch-depth: 0
34+
35+
- name: 获取上游最新版本
36+
id: upstream
37+
run: |
38+
# 从 rustfs/rustfs GitHub Releases 获取最新版本(包括 pre-release)
39+
UPSTREAM_VERSION=$(curl -s https://api.github.com/repos/rustfs/rustfs/releases | jq -r '.[0].tag_name')
40+
41+
if [ -z "$UPSTREAM_VERSION" ] || [ "$UPSTREAM_VERSION" = "null" ]; then
42+
echo "❌ 无法获取上游版本"
43+
exit 1
44+
fi
45+
46+
echo "version=$UPSTREAM_VERSION" >> $GITHUB_OUTPUT
47+
echo "✅ 上游最新版本: $UPSTREAM_VERSION"
48+
49+
- name: 获取当前仓库版本
50+
id: current
51+
run: |
52+
# 从最新的 git tag 获取当前版本
53+
CURRENT_VERSION=$(git describe --tags --abbrev=0 2>/dev/null || echo "v0.0.0")
54+
echo "version=$CURRENT_VERSION" >> $GITHUB_OUTPUT
55+
echo "📦 当前版本: $CURRENT_VERSION"
56+
57+
- name: 比较版本
58+
id: compare
59+
run: |
60+
UPSTREAM="${{ steps.upstream.outputs.version }}"
61+
CURRENT="${{ steps.current.outputs.version }}"
62+
FORCE="${{ github.event.inputs.force_build }}"
63+
64+
echo "上游版本: $UPSTREAM"
65+
echo "当前版本: $CURRENT"
66+
67+
if [ "$FORCE" = "true" ]; then
68+
echo "🔨 强制构建模式"
69+
echo "has_new_version=true" >> $GITHUB_OUTPUT
70+
echo "should_build=true" >> $GITHUB_OUTPUT
71+
elif [ "$UPSTREAM" != "$CURRENT" ]; then
72+
echo "🆕 发现新版本: $UPSTREAM (当前: $CURRENT)"
73+
echo "has_new_version=true" >> $GITHUB_OUTPUT
74+
echo "should_build=true" >> $GITHUB_OUTPUT
75+
else
76+
echo "✅ 已是最新版本"
77+
echo "has_new_version=false" >> $GITHUB_OUTPUT
78+
echo "should_build=false" >> $GITHUB_OUTPUT
79+
fi
80+
81+
- name: 创建新版本标签
82+
if: steps.compare.outputs.has_new_version == 'true'
83+
env:
84+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
85+
run: |
86+
UPSTREAM_VERSION="${{ steps.upstream.outputs.version }}"
87+
88+
# 配置 git
89+
git config user.name "github-actions[bot]"
90+
git config user.email "github-actions[bot]@users.noreply.github.com"
91+
92+
# 检查标签是否已存在
93+
if git rev-parse "$UPSTREAM_VERSION" >/dev/null 2>&1; then
94+
echo "⚠️ 标签 $UPSTREAM_VERSION 已存在,跳过创建"
95+
else
96+
# 创建并推送标签
97+
git tag -a "$UPSTREAM_VERSION" -m "Sync with upstream rustfs/rustfs $UPSTREAM_VERSION"
98+
git push origin "$UPSTREAM_VERSION"
99+
echo "✅ 已创建并推送标签: $UPSTREAM_VERSION"
100+
fi
101+
102+
trigger-build:
103+
name: 触发构建
104+
needs: check-upstream
105+
if: needs.check-upstream.outputs.should_build == 'true'
106+
runs-on: ubuntu-latest
107+
permissions:
108+
contents: write
109+
actions: write
110+
111+
steps:
112+
- name: Checkout repository
113+
uses: actions/checkout@v4
114+
115+
- name: 触发构建工作流
116+
env:
117+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
118+
run: |
119+
UPSTREAM_VERSION="${{ needs.check-upstream.outputs.upstream_version }}"
120+
121+
echo "🚀 触发构建版本: $UPSTREAM_VERSION"
122+
123+
# 触发 build.yml workflow
124+
gh workflow run build.yml \
125+
--ref main \
126+
-f tag="$UPSTREAM_VERSION"
127+
128+
echo "✅ 构建工作流已触发"
129+
130+
- name: 发送通知
131+
if: always()
132+
run: |
133+
UPSTREAM_VERSION="${{ needs.check-upstream.outputs.upstream_version }}"
134+
echo "📢 构建通知:"
135+
echo " - 上游版本: $UPSTREAM_VERSION"
136+
echo " - 工作流状态: ${{ job.status }}"
137+
echo " - 仓库: ${{ github.repository }}"
138+
echo " - 运行ID: ${{ github.run_id }}"

AGENTS.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,24 @@ Use this guide when contributing to RustFS Launcher; it highlights the project l
1515
- `trunk serve --port 1421`: run the Leptos client in a browser-only workflow using the `Trunk.toml` settings.
1616
- `cargo tauri build`: produce distributable desktop bundles.
1717
- `cargo fmt --all` and `cargo clippy --workspace --all-targets`: enforce formatting and linting before pushing.
18+
- `./scripts/check-upstream-version.sh`: check for new versions from upstream rustfs/rustfs repository.
19+
20+
## Automated Build & Release
21+
The repository includes automated workflows to keep in sync with upstream rustfs/rustfs releases:
22+
23+
### Upstream Version Sync (`.github/workflows/upstream-sync.yml`)
24+
- **Scheduled Check**: Runs daily at UTC 6:00 (Beijing 14:00) to check for new rustfs/rustfs releases.
25+
- **Automatic Trigger**: When a new upstream version is detected, it automatically creates a corresponding git tag and triggers the build workflow.
26+
- **Manual Trigger**: Can be manually triggered via GitHub Actions with an optional `force_build` parameter.
27+
- **Version Tracking**: Compares upstream release tags with local repository tags to detect updates.
28+
29+
### Build Workflow (`.github/workflows/build.yml`)
30+
- Triggered automatically by new tags created by the upstream sync workflow.
31+
- Builds platform-specific installers for Windows (macOS support can be uncommented).
32+
- Downloads the latest RustFS binaries from `dl.rustfs.com` during the build process.
33+
- Produces distributable packages (DMG, MSI, AppImage, etc.) as GitHub release artifacts.
34+
35+
This automation ensures that whenever rustfs/rustfs publishes a new version, this launcher repository will automatically build and release updated installers within 24 hours.
1836

1937
## Coding Style & Naming Conventions
2038
Use idiomatic Rust formatting (4-space indentation, `snake_case` modules/functions, `PascalCase` types, `SCREAMING_SNAKE_CASE` constants) and guard changes with `cargo fmt`.

Makefile

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.PHONY: help install-act test-ci test-ci-full clean pre-commit check-fmt check-clippy check-test check-frontend
1+
.PHONY: help install-act test-ci test-ci-full clean pre-commit check-fmt check-clippy check-test check-frontend check-upstream
22

33
# Default target
44
help:
@@ -7,6 +7,7 @@ help:
77
@echo "Available targets:"
88
@echo " make help - Show this help message"
99
@echo " make pre-commit - Run all pre-commit checks (fmt, clippy, frontend, tests)"
10+
@echo " make check-upstream - Check for new upstream rustfs/rustfs versions"
1011
@echo ""
1112
@echo "Local checks:"
1213
@echo " make check-fmt - Check Rust code formatting"
@@ -180,6 +181,11 @@ clean:
180181
@rm -rf /tmp/act-*
181182
@echo "Cache cleaned!"
182183

184+
# Check for new upstream versions
185+
check-upstream:
186+
@echo "Checking upstream rustfs/rustfs for new versions..."
187+
@./scripts/check-upstream-version.sh
188+
183189
# Run specific job from CI workflow
184190
test-ci-job: check-act
185191
@echo "Available jobs in CI workflow:"

README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,20 @@ make check-clippy # Run Clippy linter
6767
make check-frontend # Build frontend
6868
make check-test # Run tests
6969
make fix-fmt # Auto-fix formatting
70+
make check-upstream # Check for new upstream rustfs/rustfs versions
7071
```
7172

73+
### Automated Upstream Sync
74+
75+
The project automatically syncs with upstream [rustfs/rustfs](https://github.com/rustfs/rustfs) releases:
76+
77+
- **Daily Check**: A scheduled GitHub Actions workflow runs daily at UTC 6:00 (Beijing 14:00) to check for new versions
78+
- **Automatic Build**: When a new version is detected, the workflow automatically creates a git tag and triggers the build process
79+
- **Manual Check**: Run `make check-upstream` locally to check for new versions
80+
- **Manual Trigger**: Can be manually triggered via GitHub Actions if needed
81+
82+
This ensures the launcher always stays up-to-date with the latest RustFS releases without manual intervention.
83+
7284
### CI/CD
7385

7486
The project uses GitHub Actions for continuous integration and automated releases. See [.github/ACTIONS.md](.github/ACTIONS.md) for details.

scripts/check-upstream-version.sh

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
#!/bin/bash
2+
3+
# 检查上游 rustfs/rustfs 版本脚本
4+
# 用于本地测试版本同步逻辑
5+
6+
set -e
7+
8+
UPSTREAM_REPO="rustfs/rustfs"
9+
GITHUB_API="https://api.github.com/repos/${UPSTREAM_REPO}/releases/latest"
10+
11+
echo "🔍 检查上游仓库版本..."
12+
echo "仓库: ${UPSTREAM_REPO}"
13+
echo ""
14+
15+
# 获取上游最新版本(包括 pre-release)
16+
echo "📡 获取上游最新版本..."
17+
GITHUB_API_RELEASES="https://api.github.com/repos/${UPSTREAM_REPO}/releases"
18+
UPSTREAM_VERSION=$(curl -s "$GITHUB_API_RELEASES" | jq -r '.[0].tag_name')
19+
20+
if [ -z "$UPSTREAM_VERSION" ] || [ "$UPSTREAM_VERSION" = "null" ]; then
21+
echo "❌ 无法获取上游版本"
22+
echo "请检查:"
23+
echo " 1. 网络连接"
24+
echo " 2. GitHub API 访问限制"
25+
echo " 3. 上游仓库是否有 releases"
26+
exit 1
27+
fi
28+
29+
echo "✅ 上游最新版本: $UPSTREAM_VERSION"
30+
echo ""
31+
32+
# 获取当前仓库版本
33+
echo "📦 检查当前仓库版本..."
34+
CURRENT_VERSION=$(git describe --tags --abbrev=0 2>/dev/null || echo "v0.0.0")
35+
echo "当前版本: $CURRENT_VERSION"
36+
echo ""
37+
38+
# 比较版本
39+
echo "🔄 版本比较..."
40+
if [ "$UPSTREAM_VERSION" != "$CURRENT_VERSION" ]; then
41+
echo "🆕 发现新版本!"
42+
echo " 上游: $UPSTREAM_VERSION"
43+
echo " 当前: $CURRENT_VERSION"
44+
echo ""
45+
echo "建议操作:"
46+
echo " 1. 运行 'git tag $UPSTREAM_VERSION' 创建新标签"
47+
echo " 2. 运行 'git push origin $UPSTREAM_VERSION' 推送标签"
48+
echo " 3. 或等待自动同步工作流执行(每天UTC 6点)"
49+
exit 0
50+
else
51+
echo "✅ 已是最新版本"
52+
echo "无需更新"
53+
exit 0
54+
fi

0 commit comments

Comments
 (0)