Skip to content

Commit 29b6299

Browse files
committed
ci: unify build + data-snapshot into single rolling latest release
Merge build.yml (v* releases) and data-snapshot.yml (3-day snapshots) into one release.yml. Both v* tag pushes and the 3-day cron now fetch fresh upstream data (gfwlist, Country.mmdb), compile the latest code, and publish to a fixed 'latest' release marked as GitHub Latest -- so the latest download is always newest program + newest data. Tag pushes additionally publish a permanent vX.Y.Z archive (make_latest false). Bump go-version to stable.
1 parent 3151dd5 commit 29b6299

3 files changed

Lines changed: 165 additions & 207 deletions

File tree

.github/workflows/build.yml

Lines changed: 0 additions & 133 deletions
This file was deleted.

.github/workflows/data-snapshot.yml

Lines changed: 0 additions & 74 deletions
This file was deleted.

.github/workflows/release.yml

Lines changed: 165 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,165 @@
1+
name: Release
2+
3+
# 统一发布(单一滚动 Latest):
4+
# - push v* tag → 发版:拉最新数据 + 编译最新代码,刷新滚动 latest(GitHub Latest),并额外存一份 vX.Y.Z 永久归档
5+
# - 每 3 天 cron / 手动 → 仅刷新滚动 latest 的数据与构建(程序版本沿用最近的 tag)
6+
# 数据在 CI(可自由访问 GitHub)构建时拉取,运行环境(常为墙内 VPS)下载即用、无需联网。
7+
on:
8+
push:
9+
tags:
10+
- 'v*'
11+
schedule:
12+
# 约每 3 天 UTC 02:00。GitHub cron 无法精确锚定固定间隔,月末(如 31→1)会略有偏移。
13+
- cron: '0 2 */3 * *'
14+
workflow_dispatch:
15+
16+
permissions:
17+
contents: write
18+
19+
jobs:
20+
release:
21+
runs-on: ubuntu-latest
22+
23+
steps:
24+
- name: Checkout code
25+
uses: actions/checkout@v4
26+
with:
27+
fetch-depth: 0 # 需要完整历史与 tag,cron/手动触发时 git describe 才能取到最近版本号
28+
29+
- name: Set up Go
30+
uses: actions/setup-go@v5
31+
with:
32+
go-version: 'stable'
33+
34+
- name: Refresh data files from upstream
35+
run: |
36+
mkdir -p data
37+
# gfwlist(Loyalsoldier/clash-rules,近乎每日更新)
38+
curl -fsSL -o data/gfwlist.conf https://raw.githubusercontent.com/Loyalsoldier/clash-rules/release/gfw.txt
39+
# Country.mmdb(Loyalsoldier/geoip 最新 release)
40+
curl -fsSL -o data/Country.mmdb https://github.com/Loyalsoldier/geoip/releases/latest/download/Country.mmdb
41+
# cdn_keywords.txt / hot_websites.txt 跟随本仓库(checkout 已带),无需额外拉取
42+
ls -la data/
43+
44+
- name: Determine version
45+
id: version
46+
run: |
47+
if [[ "${{ github.ref }}" == refs/tags/v* ]]; then
48+
VERSION="${GITHUB_REF#refs/tags/}" # 发版:版本号取 tag
49+
IS_TAG="true"
50+
else
51+
VERSION="$(git describe --tags --abbrev=0 2>/dev/null || echo v0.0.0)" # 定时/手动:取最近 tag
52+
IS_TAG="false"
53+
fi
54+
DATA_DATE="$(date -u +%Y.%m.%d)"
55+
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
56+
echo "is_tag=$IS_TAG" >> "$GITHUB_OUTPUT"
57+
echo "data_date=$DATA_DATE" >> "$GITHUB_OUTPUT"
58+
echo "Building version=$VERSION (tag=$IS_TAG), data=$DATA_DATE"
59+
60+
- name: Build for multiple platforms
61+
run: |
62+
mkdir -p dist
63+
VERSION="${{ steps.version.outputs.version }}"
64+
COMMIT="$(git rev-parse --short HEAD)"
65+
BUILD_TIME="$(date -u +"%Y-%m-%dT%H:%M:%SZ")"
66+
LDFLAGS="-X RealityChecker/internal/version.Version=$VERSION -X RealityChecker/internal/version.Commit=$COMMIT -X RealityChecker/internal/version.BuildTime=$BUILD_TIME -s -w"
67+
68+
# Linux AMD64 - 静态编译(CGO_ENABLED=0 + netgo,规避 GLIBC 兼容问题)
69+
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags "$LDFLAGS" -tags netgo -installsuffix netgo -o reality-checker .
70+
chmod +x reality-checker
71+
zip -r dist/reality-checker-linux-amd64.zip reality-checker data/
72+
rm reality-checker
73+
74+
# Linux ARM64 - 静态编译
75+
CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -ldflags "$LDFLAGS" -tags netgo -installsuffix netgo -o reality-checker .
76+
chmod +x reality-checker
77+
zip -r dist/reality-checker-linux-arm64.zip reality-checker data/
78+
rm reality-checker
79+
80+
ls -la dist/
81+
82+
# 1) 始终刷新滚动 latest —— 这是 GitHub Latest 入口:最新程序 + 最新数据
83+
- name: Publish rolling latest release
84+
uses: softprops/action-gh-release@v2
85+
with:
86+
tag_name: latest
87+
name: 最新版 ${{ steps.version.outputs.version }}(数据 ${{ steps.version.outputs.data_date }})
88+
body: |
89+
**始终保持最新**:程序为最近发布版本的代码,数据每 3 天自动刷新(gfwlist、Country.mmdb)。
90+
解压即用,运行时无需联网下载数据。
91+
92+
- 程序版本:`${{ steps.version.outputs.version }}`
93+
- 数据快照:`${{ steps.version.outputs.data_date }}`
94+
95+
**下载(地址固定,始终指向最新):**
96+
```bash
97+
# x86_64
98+
wget https://github.com/GEMILUXVII/RealityChecker/releases/latest/download/reality-checker-linux-amd64.zip
99+
# ARM64
100+
wget https://github.com/GEMILUXVII/RealityChecker/releases/latest/download/reality-checker-linux-arm64.zip
101+
102+
unzip reality-checker-linux-amd64.zip
103+
chmod +x reality-checker
104+
./reality-checker check example.com
105+
./reality-checker csv file.csv
106+
```
107+
files: dist/*
108+
make_latest: true
109+
env:
110+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
111+
112+
# 2) 仅在打 v* tag 时,额外发布该版本的永久归档(不抢 Latest 标记)
113+
- name: Publish version archive release
114+
if: steps.version.outputs.is_tag == 'true'
115+
uses: softprops/action-gh-release@v2
116+
with:
117+
# 不指定 tag_name:沿用本次 push 的 v* tag
118+
name: Reality 协议目标网站检测工具 ${{ steps.version.outputs.version }}
119+
body: |
120+
## Reality 协议目标网站检测工具 ${{ steps.version.outputs.version }}
121+
122+
> 想始终获取“最新程序 + 最新数据”,请到 [**latest**](https://github.com/GEMILUXVII/RealityChecker/releases/latest) 下载。
123+
> 本页为 `${{ steps.version.outputs.version }}` 的永久归档(数据为发版当时 ${{ steps.version.outputs.data_date }})。
124+
125+
**下载说明:**(已内置 data/ 数据文件,解压即用)
126+
- `reality-checker-linux-amd64.zip` - Linux x86_64
127+
- `reality-checker-linux-arm64.zip` - Linux ARM64
128+
129+
**基本命令:**
130+
```bash
131+
# 单域名检测
132+
./reality-checker check example.com
133+
134+
# 批量检测
135+
./reality-checker batch domain1 domain2 domain3
136+
137+
# CSV 文件检测
138+
./reality-checker csv domains.csv
139+
```
140+
141+
**推荐工作流程:**
142+
1. 使用 [RealiTLScanner](https://github.com/XTLS/RealiTLScanner) 在本地扫描 VPS IP:
143+
```bash
144+
./RealiTLScanner -addr <VPS IP> -port 443 -thread 100 -timeout 5 -out file.csv
145+
```
146+
2. 使用本工具检测生成的 CSV 文件:
147+
```bash
148+
./reality-checker csv file.csv
149+
```
150+
151+
**重要提示:**
152+
- RealiTLScanner 尽量在本地运行,不要在远端
153+
- 多次运行 RealiTLScanner 时请更改输出文件名(file1.csv、file2.csv …),避免覆盖之前的扫描结果
154+
155+
### 版本信息
156+
- **版本**: ${{ steps.version.outputs.version }}
157+
- **提交**: ${{ github.sha }}
158+
159+
---
160+
**注意**:本工具仅用于技术研究和学习目的,请遵守当地法律法规。
161+
make_latest: false
162+
draft: false
163+
prerelease: false
164+
env:
165+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)