Skip to content

Commit b4493d5

Browse files
committed
ci: 重写 Build & Release 覆盖全部 OS/arch 平台
- 使用 bin/cross-compile.go 匹配原版构建能力 - Linux 主机构建: linux(全部)/freebsd/netbsd/openbsd/plan9/solaris/aix - macOS 主机构建: darwin(amd64+arm64) 含 cgo+FUSE - Windows 主机构建: windows(386+amd64+arm64) 含 cgo+WinFsp - 共计 30+ 平台,与原版一致
1 parent 6ca2a35 commit b4493d5

1 file changed

Lines changed: 170 additions & 61 deletions

File tree

‎.github/workflows/build-release.yml‎

Lines changed: 170 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -18,115 +18,224 @@ permissions:
1818
contents: write
1919

2020
jobs:
21-
build:
22-
runs-on: ${{ matrix.os }}
21+
# ── Linux (all non-macOS/non-Windows platforms) ──
22+
build-linux:
23+
runs-on: ubuntu-latest
24+
timeout-minutes: 60
25+
steps:
26+
- uses: actions/checkout@v6
27+
with:
28+
fetch-depth: 0
29+
30+
- uses: actions/setup-go@v6
31+
with:
32+
go-version: '~1.26.3'
33+
check-latest: true
34+
35+
- name: Install libraries
36+
run: |
37+
sudo apt-get update
38+
sudo apt-get install -y fuse3 libfuse-dev rpm
39+
40+
- name: Set version
41+
id: ver
42+
run: |
43+
UPSTREAM=$(cat VERSION)
44+
HASH=$(git rev-parse --short=8 HEAD)
45+
echo "full=${UPSTREAM}-${HASH}" >> $GITHUB_OUTPUT
46+
47+
- name: Build Linux platforms
48+
run: |
49+
go run bin/cross-compile.go \
50+
-release "${{ steps.ver.outputs.full }}" \
51+
-include '^linux/' \
52+
-exclude '^(linux/386|linux/arm|linux/mips|linux/mipsle|linux/arm-v6|linux/arm-v7)$' \
53+
-tags cmount \
54+
-no-clean \
55+
"${{ steps.ver.outputs.full }}"
56+
57+
- name: Build Linux 386
58+
run: |
59+
GOARCH=386 go run bin/cross-compile.go \
60+
-release "${{ steps.ver.outputs.full }}" \
61+
-include '^linux/386$' \
62+
-tags cmount \
63+
-no-clean \
64+
"${{ steps.ver.outputs.full }}"
65+
66+
- name: Build Linux ARM variants
67+
run: |
68+
go run bin/cross-compile.go \
69+
-release "${{ steps.ver.outputs.full }}" \
70+
-include '^linux/(arm|mips|mipsle)' \
71+
-no-clean \
72+
"${{ steps.ver.outputs.full }}"
73+
74+
- name: Build FreeBSD / NetBSD / OpenBSD / Plan9 / Solaris / AIX
75+
run: |
76+
go run bin/cross-compile.go \
77+
-release "${{ steps.ver.outputs.full }}" \
78+
-exclude '^(windows/|darwin/|linux/)' \
79+
-compile-only \
80+
-no-clean \
81+
"${{ steps.ver.outputs.full }}"
82+
83+
- name: Upload Linux artifacts
84+
uses: actions/upload-artifact@v7
85+
with:
86+
name: binaries-linux
87+
path: build/*
88+
retention-days: 7
89+
90+
# ── macOS (needs native cgo + macFUSE) ──
91+
build-macos:
92+
runs-on: macos-latest
93+
timeout-minutes: 60
2394
strategy:
2495
fail-fast: false
2596
matrix:
2697
include:
27-
- os: ubuntu-latest
28-
goos: linux
98+
- job: amd64
2999
goarch: amd64
30-
asset_name: rclone-linux-amd64
100+
build_flags: '-include "^darwin/amd64" -cgo'
101+
- job: arm64
102+
goarch: arm64
103+
build_flags: '-include "^darwin/arm64" -cgo -macos-arch arm64'
31104

32-
- os: macos-latest
33-
goos: darwin
34-
goarch: amd64
35-
asset_name: rclone-macos-amd64
105+
name: macOS ${{ matrix.job }}
106+
steps:
107+
- uses: actions/checkout@v6
108+
with:
109+
fetch-depth: 0
36110

37-
- os: macos-latest
38-
goos: darwin
39-
goarch: arm64
40-
asset_name: rclone-macos-arm64
111+
- uses: actions/setup-go@v6
112+
with:
113+
go-version: '~1.26.3'
114+
check-latest: true
41115

42-
- os: windows-latest
43-
goos: windows
44-
goarch: amd64
45-
ext: .exe
46-
asset_name: rclone-windows-amd64
116+
- name: Install macFUSE
117+
run: |
118+
unset HOMEBREW_NO_INSTALL_FROM_API
119+
brew untap --force homebrew/core
120+
brew untap --force homebrew/cask
121+
brew update
122+
brew install --cask macfuse
123+
124+
- name: Set version
125+
id: ver
126+
run: |
127+
UPSTREAM=$(cat VERSION)
128+
HASH=$(git rev-parse --short=8 HEAD)
129+
echo "full=${UPSTREAM}-${HASH}" >> $GITHUB_OUTPUT
47130
48-
name: Build ${{ matrix.goos }}/${{ matrix.goarch }}
131+
- name: Build
132+
run: |
133+
go run bin/cross-compile.go \
134+
-release "${{ steps.ver.outputs.full }}" \
135+
${{ matrix.build_flags }} \
136+
-tags cmount \
137+
-no-clean \
138+
"${{ steps.ver.outputs.full }}"
139+
140+
- name: Upload macOS artifacts
141+
uses: actions/upload-artifact@v7
142+
with:
143+
name: binaries-macos-${{ matrix.job }}
144+
path: build/*
145+
retention-days: 7
49146

147+
# ── Windows (needs native cgo + WinFsp) ──
148+
build-windows:
149+
runs-on: windows-latest
150+
timeout-minutes: 60
50151
steps:
51-
- name: Checkout
52-
uses: actions/checkout@v6
152+
- uses: actions/checkout@v6
53153
with:
54154
fetch-depth: 0
55155

56-
- name: Setup Go
57-
uses: actions/setup-go@v6
156+
- uses: actions/setup-go@v6
58157
with:
59158
go-version: '~1.26.3'
60159
check-latest: true
61160

62-
- name: Set version
63-
id: version
64-
shell: bash
161+
- name: Install WinFsp and zip
162+
shell: powershell
65163
run: |
66-
UPSTREAM_VER=$(cat VERSION)
67-
COMMIT_HASH=$(git rev-parse --short=8 HEAD)
68-
FULL_VER="${UPSTREAM_VER}-${COMMIT_HASH}"
69-
echo "full_version=${FULL_VER}" >> $GITHUB_OUTPUT
70-
echo "upstream_version=${UPSTREAM_VER}" >> $GITHUB_OUTPUT
164+
$ProgressPreference = 'SilentlyContinue'
165+
choco install -y winfsp zip
166+
echo "CPATH=C:\Program Files\WinFsp\inc\fuse;C:\Program Files (x86)\WinFsp\inc\fuse" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
71167
72-
- name: Build
73-
shell: bash
168+
- name: Set version
169+
id: ver
74170
run: |
75-
GOOS=${{ matrix.goos }} GOARCH=${{ matrix.goarch }} \
76-
go build -trimpath -ldflags="-s -w -X github.com/rclone/rclone/fs.Version=${{ steps.version.outputs.full_version }}" \
77-
-o ${{ matrix.asset_name }}${{ matrix.ext }} .
171+
UPSTREAM=$(cat VERSION)
172+
HASH=$(git rev-parse --short=8 HEAD)
173+
echo "full=${UPSTREAM}-${HASH}" >> $GITHUB_ENV
78174
79-
- name: Upload artifact
175+
- name: Build Windows
176+
run: |
177+
go run bin/cross-compile.go `
178+
-release "${{ steps.ver.outputs.full }}" `
179+
-include '^windows/' `
180+
-tags cmount `
181+
-no-clean `
182+
"${{ steps.ver.outputs.full }}"
183+
184+
- name: Upload Windows artifacts
80185
uses: actions/upload-artifact@v7
81186
with:
82-
name: ${{ matrix.asset_name }}
83-
path: ${{ matrix.asset_name }}${{ matrix.ext }}
84-
if-no-files-found: error
187+
name: binaries-windows
188+
path: build/*
85189
retention-days: 7
86190

191+
# ── Release ──
87192
release:
88-
needs: build
193+
needs: [build-linux, build-macos, build-windows]
89194
runs-on: ubuntu-latest
90195
if: github.ref == 'refs/heads/master'
91196

92197
steps:
93-
- name: Checkout
94-
uses: actions/checkout@v6
198+
- uses: actions/checkout@v6
95199

96200
- name: Set version
97-
id: version
201+
id: ver
98202
run: |
99-
UPSTREAM_VER=$(cat VERSION)
100-
COMMIT_HASH=$(git rev-parse --short=8 HEAD)
101-
FULL_VER="${UPSTREAM_VER}-${COMMIT_HASH}"
102-
echo "full_version=${FULL_VER}" >> $GITHUB_OUTPUT
103-
echo "upstream_version=${UPSTREAM_VER}" >> $GITHUB_OUTPUT
203+
UPSTREAM=$(cat VERSION)
204+
HASH=$(git rev-parse --short=8 HEAD)
205+
echo "full=${UPSTREAM}-${HASH}" >> $GITHUB_OUTPUT
206+
echo "upstream=${UPSTREAM}" >> $GITHUB_OUTPUT
104207
105208
- name: Download all artifacts
106209
uses: actions/download-artifact@v7
107210
with:
108-
path: artifacts
211+
path: release-artifacts
212+
merge-multiple: true
213+
214+
- name: List release files
215+
run: |
216+
echo "Files to release:"
217+
find release-artifacts -type f | sort
109218
110219
- name: Create Release
111220
uses: softprops/action-gh-release@v2
112221
with:
113-
tag_name: ${{ steps.version.outputs.full_version }}
114-
name: ${{ steps.version.outputs.full_version }}
222+
tag_name: ${{ steps.ver.outputs.full }}
223+
name: ${{ steps.ver.outputs.full }}
115224
body: |
116-
## Rclone with 123Pan ${{ steps.version.outputs.full_version }}
225+
## Rclone with 123Pan ${{ steps.ver.outputs.full }}
117226
118-
基于上游版本 `${{ steps.version.outputs.upstream_version }}`,包含以下增强:
227+
**上游版本**: `${{ steps.ver.outputs.upstream }}`
228+
**构建 commit**: `${{ github.sha }}`
119229
120-
- **123pan**: Web/浏览器 API 后端(用户名密码登录)
121-
- **123open**: 官方 Open API 后端(开发者凭证)
230+
### 新增功能
231+
- **123pan**: Web/浏览器 API 后端(用户名密码登录,无需开发者凭证)
232+
- **123open**: 官方 Open API 后端(OAuth2 Client Credentials)
122233
123-
构建自 commit: `${{ github.sha }}`
234+
### 支持的平台
235+
Linux (amd64/386/arm/arm64/mips/mipsle) · macOS (amd64/arm64) · Windows (386/amd64/arm64) · FreeBSD · NetBSD · OpenBSD · Plan9 · Solaris · AIX
124236
draft: false
125237
prerelease: false
126238
files: |
127-
artifacts/rclone-linux-amd64/rclone-linux-amd64
128-
artifacts/rclone-macos-amd64/rclone-macos-amd64
129-
artifacts/rclone-macos-arm64/rclone-macos-arm64
130-
artifacts/rclone-windows-amd64/rclone-windows-amd64.exe
239+
release-artifacts/*
131240
env:
132241
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)