-
Notifications
You must be signed in to change notification settings - Fork 0
400 lines (343 loc) · 15.8 KB
/
Copy pathmanual-build.yml
File metadata and controls
400 lines (343 loc) · 15.8 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
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
name: Manual Build & Release
on:
workflow_dispatch:
inputs:
commit_sha:
description: 'Upstream commit SHA to build (leave empty for latest)'
required: false
default: ''
type: string
version_suffix:
description: 'Custom version suffix (e.g., "hotfix", "test")'
required: false
default: ''
type: string
prerelease:
description: 'Mark as pre-release'
required: false
default: false
type: boolean
build_platforms:
description: 'Platforms to build'
required: false
default: 'all'
type: choice
options:
- 'all'
- 'windows-only'
- 'linux-only'
- 'macos-only'
- 'windows-linux'
permissions:
contents: write
actions: read
env:
UPSTREAM_REPO: 'nilaoda/BBDown'
DOTNET_SDK_VERSION: '9.0.*'
ACTIONS_ALLOW_USE_UNSECURE_NODE_VERSION: true
jobs:
prepare-build:
runs-on: ubuntu-latest
outputs:
target-commit: ${{ steps.setup.outputs.target_commit }}
commit-message: ${{ steps.setup.outputs.commit_message }}
commit-date: ${{ steps.setup.outputs.commit_date }}
build-version: ${{ steps.setup.outputs.build_version }}
build-time: ${{ steps.setup.outputs.build_time }}
build-windows: ${{ steps.platforms.outputs.build_windows }}
build-linux: ${{ steps.platforms.outputs.build_linux }}
build-macos: ${{ steps.platforms.outputs.build_macos }}
steps:
- name: Setup build parameters
id: setup
run: |
echo "=== Manual Build Setup ==="
# Determine target commit
if [ -n "${{ github.event.inputs.commit_sha }}" ]; then
TARGET_COMMIT="${{ github.event.inputs.commit_sha }}"
echo "🎯 Using specified commit: $TARGET_COMMIT"
else
echo "🔍 Fetching latest upstream commit..."
UPSTREAM_RESPONSE=$(curl -s "https://api.github.com/repos/${{ env.UPSTREAM_REPO }}/commits/master")
TARGET_COMMIT=$(echo "$UPSTREAM_RESPONSE" | jq -r '.sha')
echo "📥 Using latest upstream commit: $TARGET_COMMIT"
fi
# Get commit information
echo "📋 Fetching commit details..."
COMMIT_RESPONSE=$(curl -s "https://api.github.com/repos/${{ env.UPSTREAM_REPO }}/commits/$TARGET_COMMIT")
if [ "$(echo "$COMMIT_RESPONSE" | jq -r '.sha')" = "null" ]; then
echo "❌ Invalid commit SHA: $TARGET_COMMIT"
exit 1
fi
COMMIT_MESSAGE=$(echo "$COMMIT_RESPONSE" | jq -r '.commit.message' | head -1)
COMMIT_DATE=$(echo "$COMMIT_RESPONSE" | jq -r '.commit.committer.date')
echo "✅ Target commit: $TARGET_COMMIT"
echo "📝 Commit message: $COMMIT_MESSAGE"
echo "📅 Commit date: $COMMIT_DATE"
# Generate version
SHORT_COMMIT=$(echo "$TARGET_COMMIT" | cut -c1-7)
BUILD_DATE=$(date -u +'%Y%m%d')
BUILD_TIME=$(date -u +'%Y-%m-%d %H:%M:%S UTC')
if [ -n "${{ github.event.inputs.version_suffix }}" ]; then
VERSION="v${BUILD_DATE}-${SHORT_COMMIT}-${{ github.event.inputs.version_suffix }}"
else
VERSION="v${BUILD_DATE}-${SHORT_COMMIT}-manual"
fi
echo "🏷️ Generated version: $VERSION"
echo "🕐 Build time: $BUILD_TIME"
# Set outputs
echo "target_commit=$TARGET_COMMIT" >> $GITHUB_OUTPUT
echo "commit_message=$COMMIT_MESSAGE" >> $GITHUB_OUTPUT
echo "commit_date=$COMMIT_DATE" >> $GITHUB_OUTPUT
echo "build_version=$VERSION" >> $GITHUB_OUTPUT
echo "build_time=$BUILD_TIME" >> $GITHUB_OUTPUT
- name: Determine build platforms
id: platforms
run: |
case "${{ github.event.inputs.build_platforms }}" in
"all")
echo "build_windows=true" >> $GITHUB_OUTPUT
echo "build_linux=true" >> $GITHUB_OUTPUT
echo "build_macos=true" >> $GITHUB_OUTPUT
echo "🏗️ Building for all platforms"
;;
"windows-only")
echo "build_windows=true" >> $GITHUB_OUTPUT
echo "build_linux=false" >> $GITHUB_OUTPUT
echo "build_macos=false" >> $GITHUB_OUTPUT
echo "🏗️ Building for Windows only"
;;
"linux-only")
echo "build_windows=false" >> $GITHUB_OUTPUT
echo "build_linux=true" >> $GITHUB_OUTPUT
echo "build_macos=false" >> $GITHUB_OUTPUT
echo "🏗️ Building for Linux only"
;;
"macos-only")
echo "build_windows=false" >> $GITHUB_OUTPUT
echo "build_linux=false" >> $GITHUB_OUTPUT
echo "build_macos=true" >> $GITHUB_OUTPUT
echo "🏗️ Building for macOS only"
;;
"windows-linux")
echo "build_windows=true" >> $GITHUB_OUTPUT
echo "build_linux=true" >> $GITHUB_OUTPUT
echo "build_macos=false" >> $GITHUB_OUTPUT
echo "🏗️ Building for Windows and Linux"
;;
esac
build-windows:
needs: prepare-build
if: needs.prepare-build.outputs.build-windows == 'true'
runs-on: windows-latest
steps:
- name: Clone upstream repository
run: |
git clone https://github.com/${{ env.UPSTREAM_REPO }}.git .
git checkout ${{ needs.prepare-build.outputs.target-commit }}
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{ env.DOTNET_SDK_VERSION }}
- name: Install zip
run: choco install zip --no-progress --yes
- name: Build Windows x64
run: dotnet publish BBDown -r win-x64 -c Release --self-contained -o ./build/win-x64
- name: Build Windows ARM64
run: dotnet publish BBDown -r win-arm64 -c Release --self-contained -o ./build/win-arm64
- name: Package Windows builds
run: |
cd ./build/win-x64
zip ../../BBDown-${{ needs.prepare-build.outputs.build-version }}-win-x64.zip BBDown.exe
cd ../win-arm64
zip ../../BBDown-${{ needs.prepare-build.outputs.build-version }}-win-arm64.zip BBDown.exe
- name: Upload Windows artifacts
uses: actions/upload-artifact@v4
with:
name: windows-builds
path: |
BBDown-${{ needs.prepare-build.outputs.build-version }}-win-x64.zip
BBDown-${{ needs.prepare-build.outputs.build-version }}-win-arm64.zip
build-linux:
needs: prepare-build
if: needs.prepare-build.outputs.build-linux == 'true'
runs-on: ubuntu-latest
steps:
- name: Clone upstream repository
run: |
git clone https://github.com/${{ env.UPSTREAM_REPO }}.git .
git checkout ${{ needs.prepare-build.outputs.target-commit }}
- name: Install cross-compilation tools for ARM64
run: |
if [[ $ImageOS == "ubuntu24" ]]; then
cat <<EOF > deb822sources
Types: deb
URIs: http://archive.ubuntu.com/ubuntu/
Suites: noble
Components: main restricted universe
Architectures: amd64
Types: deb
URIs: http://security.ubuntu.com/ubuntu/
Suites: noble-security
Components: main restricted universe
Architectures: amd64
Types: deb
URIs: http://archive.ubuntu.com/ubuntu/
Suites: noble-updates
Components: main restricted universe
Architectures: amd64
Types: deb
URIs: http://azure.ports.ubuntu.com/ubuntu-ports/
Suites: noble
Components: main restricted multiverse universe
Architectures: arm64
Types: deb
URIs: http://azure.ports.ubuntu.com/ubuntu-ports/
Suites: noble-updates
Components: main restricted multiverse universe
Architectures: arm64
EOF
sudo mv deb822sources /etc/apt/sources.list.d/ubuntu.sources
else
sudo mv config/crosscomp-sources.list /etc/apt/sources.list
fi
# https://learn.microsoft.com/zh-cn/dotnet/core/deploying/native-aot/cross-compile
- run: |
sudo dpkg --add-architecture arm64
sudo bash -c 'cat > /etc/apt/sources.list.d/arm64.list <<EOF
deb [arch=arm64] http://ports.ubuntu.com/ubuntu-ports/ jammy main restricted
deb [arch=arm64] http://ports.ubuntu.com/ubuntu-ports/ jammy-updates main restricted
deb [arch=arm64] http://ports.ubuntu.com/ubuntu-ports/ jammy-backports main restricted universe multiverse
EOF'
sudo sed -i -e 's/deb http/deb [arch=amd64] http/g' /etc/apt/sources.list
sudo sed -i -e 's/deb mirror/deb [arch=amd64] mirror/g' /etc/apt/sources.list
sudo apt-get update
sudo apt-get install -y curl wget libicu-dev libcurl4-openssl-dev zlib1g-dev libkrb5-dev clang llvm binutils-aarch64-linux-gnu gcc-aarch64-linux-gnu zlib1g-dev:arm64
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{ env.DOTNET_SDK_VERSION }}
- name: Build Linux x64
run: dotnet publish BBDown -r linux-x64 -c Release -o ./build/linux-x64
- name: Build Linux ARM64
run: |
# Set up environment for cross-compilation (This is now redundant for setting paths but harmless)
export CC=aarch64-linux-gnu-gcc
export CXX=aarch64-linux-gnu-g++
export AR=aarch64-linux-gnu-ar
export STRIP=aarch64-linux-gnu-strip
export OBJCOPY=aarch64-linux-gnu-objcopy
dotnet publish BBDown -r linux-arm64 -c Release -o ./build/linux-arm64
- name: Package Linux builds
run: |
cd ./build/linux-x64
zip ../../BBDown-${{ needs.prepare-build.outputs.build-version }}-linux-x64.zip BBDown
cd ../linux-arm64
zip ../../BBDown-${{ needs.prepare-build.outputs.build-version }}-linux-arm64.zip BBDown
- name: Upload Linux artifacts
uses: actions/upload-artifact@v4
with:
name: linux-builds
path: |
BBDown-${{ needs.prepare-build.outputs.build-version }}-linux-x64.zip
BBDown-${{ needs.prepare-build.outputs.build-version }}-linux-arm64.zip
build-macos:
needs: prepare-build
if: needs.prepare-build.outputs.build-macos == 'true'
runs-on: macos-latest
steps:
- name: Clone upstream repository
run: |
git clone https://github.com/${{ env.UPSTREAM_REPO }}.git .
git checkout ${{ needs.prepare-build.outputs.target-commit }}
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{ env.DOTNET_SDK_VERSION }}
- name: Build macOS x64
run: dotnet publish BBDown -r osx-x64 -c Release --self-contained -o ./build/osx-x64
- name: Build macOS ARM64
run: dotnet publish BBDown -r osx-arm64 -c Release --self-contained -o ./build/osx-arm64
- name: Package macOS builds
run: |
cd ./build/osx-x64
zip ../../BBDown-${{ needs.prepare-build.outputs.build-version }}-osx-x64.zip BBDown
cd ../osx-arm64
zip ../../BBDown-${{ needs.prepare-build.outputs.build-version }}-osx-arm64.zip BBDown
- name: Upload macOS artifacts
uses: actions/upload-artifact@v4
with:
name: macos-builds
path: |
BBDown-${{ needs.prepare-build.outputs.build-version }}-osx-x64.zip
BBDown-${{ needs.prepare-build.outputs.build-version }}-osx-arm64.zip
create-release:
needs: [prepare-build, build-windows, build-linux, build-macos]
if: always() && needs.prepare-build.result == 'success' && !cancelled()
runs-on: ubuntu-latest
steps:
- name: Download artifacts
uses: actions/download-artifact@v4
with:
path: ./artifacts
- name: Organize release files
run: |
mkdir -p ./release-files
find ./artifacts -name "*.zip" -exec cp {} ./release-files/ \; 2>/dev/null || true
ls -la ./release-files/ || echo "No build artifacts found"
- name: Create Release
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ needs.prepare-build.outputs.build-version }}
name: "BBDown ${{ needs.prepare-build.outputs.build-version }} (Manual Build)"
token: ${{ secrets.GITHUB_TOKEN }}
body: |
🔧 **Manual Build Release**
This release was manually triggered and built from the upstream [nilaoda/BBDown](https://github.com/${{ env.UPSTREAM_REPO }}) repository.
**Build Information:**
- 🆔 Source Commit: `${{ needs.prepare-build.outputs.target-commit }}`
- 📝 Commit Message: ${{ needs.prepare-build.outputs.commit-message }}
- 📅 Commit Date: ${{ needs.prepare-build.outputs.commit-date }}
- 🕐 Build Time: ${{ needs.prepare-build.outputs.build-time }}
- 🔧 Triggered by: @${{ github.actor }}
**Build Configuration:**
- Windows: ${{ needs.prepare-build.outputs.build-windows == 'true' && '✅' || '⏭️' }}
- Linux: ${{ needs.prepare-build.outputs.build-linux == 'true' && '✅' || '⏭️' }}
- macOS: ${{ needs.prepare-build.outputs.build-macos == 'true' && '✅' || '⏭️' }}
**Usage Instructions:**
1. Download the appropriate package for your platform
2. Extract the archive
3. Run the BBDown executable directly
4. For detailed usage, see [original project documentation](https://github.com/${{ env.UPSTREAM_REPO }})
---
> This is a manual build. For automatic builds tracking the latest upstream changes, see other releases.
files: ./release-files/*
draft: false
prerelease: ${{ github.event.inputs.prerelease == 'true' }}
# Build summary
build-summary:
needs: [prepare-build, build-windows, build-linux, build-macos, create-release]
if: always() && needs.prepare-build.result == 'success'
runs-on: ubuntu-latest
steps:
- name: Generate build summary
run: |
echo "## 🔧 Manual Build Completed" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "**Version**: ${{ needs.prepare-build.outputs.build-version }}" >> $GITHUB_STEP_SUMMARY
echo "**Source Commit**: ${{ needs.prepare-build.outputs.target-commit }}" >> $GITHUB_STEP_SUMMARY
echo "**Triggered By**: @${{ github.actor }}" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "### Build Results" >> $GITHUB_STEP_SUMMARY
echo "- Windows: ${{ needs.build-windows.result || '⏭️ Skipped' }}" >> $GITHUB_STEP_SUMMARY
echo "- Linux: ${{ needs.build-linux.result || '⏭️ Skipped' }}" >> $GITHUB_STEP_SUMMARY
echo "- macOS: ${{ needs.build-macos.result || '⏭️ Skipped' }}" >> $GITHUB_STEP_SUMMARY
echo "- Release: ${{ needs.create-release.result }}" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
if [ "${{ needs.create-release.result }}" = "success" ]; then
echo "🎉 **Release created successfully!**" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "[View Release](https://github.com/${{ github.repository }}/releases/tag/${{ needs.prepare-build.outputs.build-version }})" >> $GITHUB_STEP_SUMMARY
else
echo "❌ **Release creation failed**" >> $GITHUB_STEP_SUMMARY
fi