-
Notifications
You must be signed in to change notification settings - Fork 199
254 lines (214 loc) · 8.28 KB
/
Copy pathnightly.yml
File metadata and controls
254 lines (214 loc) · 8.28 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
name: Nightly Build
on:
schedule:
# Weekdays at 02:00 UTC
- cron: "0 2 * * 1-5"
workflow_dispatch:
permissions:
contents: write
concurrency:
group: nightly
cancel-in-progress: true
env:
NIGHTLY_TAG: nightly
jobs:
# ── Check if there are new commits since last nightly ──────────────
check-changes:
name: Check for Changes
runs-on: ubuntu-latest
outputs:
should_build: ${{ steps.check.outputs.should_build }}
nightly_version: ${{ steps.check.outputs.nightly_version }}
steps:
- uses: actions/checkout@v5
with:
fetch-depth: 0
- name: Check for recent changes
id: check
shell: bash
run: |
set -euo pipefail
BASE_VERSION="$(jq -r '.version' package.json)"
DATE_SUFFIX="$(date -u '+%Y%m%d')"
SHORT_SHA="$(git rev-parse --short HEAD)"
NIGHTLY_VERSION="${BASE_VERSION}-nightly.${DATE_SUFFIX}+${SHORT_SHA}"
echo "nightly_version=$NIGHTLY_VERSION" >> "$GITHUB_OUTPUT"
if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
echo "should_build=true" >> "$GITHUB_OUTPUT"
exit 0
fi
# Check if any commits landed in the last 25 hours
LAST_COMMIT_TIME="$(git log -1 --format='%ct')"
NOW="$(date -u '+%s')"
HOURS_AGO=$(( (NOW - LAST_COMMIT_TIME) / 3600 ))
if [[ "$HOURS_AGO" -lt 25 ]]; then
echo "should_build=true" >> "$GITHUB_OUTPUT"
else
echo "No new commits in the last 25 hours, skipping nightly build."
echo "should_build=false" >> "$GITHUB_OUTPUT"
fi
# ── Patch version for nightly ──────────────────────────────────────
package:
name: Package (${{ matrix.platform.name }})
runs-on: ${{ matrix.platform.os }}
needs: check-changes
if: needs.check-changes.outputs.should_build == 'true'
env:
NODE_OPTIONS: --max-old-space-size=6144
strategy:
fail-fast: false
matrix:
platform:
- os: ubuntu-latest
name: linux-x64
target: x86_64-unknown-linux-gnu
build_command: pnpm run desktop:build:linux -- --target x86_64-unknown-linux-gnu --bundles deb,rpm,appimage
- os: ubuntu-24.04-arm
name: linux-arm64
target: aarch64-unknown-linux-gnu
# Fat LTO exhausts the hosted ARM runner while linking bitfun-desktop.
build_command: CARGO_PROFILE_RELEASE_LTO=thin pnpm run desktop:build:linux -- --target aarch64-unknown-linux-gnu --bundles deb,rpm,appimage
- os: macos-15
name: macos-arm64
target: aarch64-apple-darwin
build_command: pnpm run desktop:build:arm64
- os: macos-15-intel
name: macos-x64
target: x86_64-apple-darwin
build_command: pnpm run desktop:build:x86_64
- os: windows-latest
name: windows-x64
target: x86_64-pc-windows-msvc
build_command: pnpm run installer:build
steps:
- uses: actions/checkout@v5
- name: Setup OpenSSL (Windows, prebuilt)
if: runner.os == 'Windows'
shell: pwsh
run: ./scripts/ci/setup-openssl-windows.ps1
- name: Install Linux system dependencies (Tauri bundler)
if: runner.os == 'Linux'
shell: bash
run: |
sudo apt-get update
if apt-cache show libwebkit2gtk-4.1-dev >/dev/null 2>&1; then
WEBKIT_PKG=libwebkit2gtk-4.1-dev
else
WEBKIT_PKG=libwebkit2gtk-4.0-dev
fi
if apt-cache show libappindicator3-dev >/dev/null 2>&1; then
APPINDICATOR_PKG=libappindicator3-dev
else
APPINDICATOR_PKG=libayatana-appindicator3-dev
fi
sudo apt-get install -y --no-install-recommends \
pkg-config \
xdg-utils \
libglib2.0-dev \
libgtk-3-dev \
libxdo-dev \
"$WEBKIT_PKG" \
"$APPINDICATOR_PKG" \
librsvg2-dev \
patchelf \
fakeroot \
rpm \
libleptonica-dev \
libtesseract-dev \
tesseract-ocr \
tesseract-ocr-eng
- name: Setup pnpm
uses: pnpm/action-setup@v5
- name: Setup Node.js
uses: actions/setup-node@v5
with:
node-version: 22
cache: pnpm
- name: Setup Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.platform.target }}
- name: Cache Rust build
uses: swatinem/rust-cache@v2
with:
shared-key: "nightly-v2-${{ matrix.platform.name }}"
cache-bin: false
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Type-check web UI
run: pnpm run type-check:web
- name: Patch nightly version
shell: bash
env:
NIGHTLY_VERSION: ${{ needs.check-changes.outputs.nightly_version }}
run: |
set -euo pipefail
echo "Patching version to $NIGHTLY_VERSION"
# Patch package.json
node -e "
const fs = require('fs');
const pkg = JSON.parse(fs.readFileSync('package.json', 'utf-8'));
pkg.version = process.env.NIGHTLY_VERSION.split('+')[0];
fs.writeFileSync('package.json', JSON.stringify(pkg, null, 2) + '\n');
"
# Patch Cargo workspace version (semver: nightly suffix uses hyphen)
# Cargo.toml only accepts: MAJOR.MINOR.PATCH or MAJOR.MINOR.PATCH-PRE
CARGO_VERSION="$(echo "$NIGHTLY_VERSION" | sed 's/+.*//')"
sed -i.bak "s/^version = \".*\" # x-release-please-version/version = \"${CARGO_VERSION}\" # x-release-please-version/" Cargo.toml
rm -f Cargo.toml.bak
echo "package.json version: $(jq -r '.version' package.json)"
echo "Cargo.toml version: $(grep 'x-release-please-version' Cargo.toml)"
- name: Build desktop app
run: ${{ matrix.platform.build_command }}
- name: Upload bundles
uses: actions/upload-artifact@v6
with:
name: bitfun-nightly-${{ matrix.platform.name }}-bundle
if-no-files-found: error
retention-days: 7
path: |
target/*/release/bundle
target/release/bundle
src/apps/desktop/target/release/bundle
BitFun-Installer/src-tauri/target/release/bitfun-installer.exe
# ── Publish nightly pre-release ────────────────────────────────────
publish-nightly:
name: Publish Nightly
needs: [check-changes, package]
if: needs.check-changes.outputs.should_build == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- name: Download bundled artifacts
uses: actions/download-artifact@v7
with:
pattern: bitfun-nightly-*-bundle
path: release-assets
merge-multiple: true
- name: List release assets
run: |
echo "Nightly assets:"
find release-assets -type f | sort
- name: Delete previous nightly release
env:
GH_TOKEN: ${{ github.token }}
run: |
gh release delete "${{ env.NIGHTLY_TAG }}" --yes --cleanup-tag 2>/dev/null || true
- name: Create nightly release
uses: softprops/action-gh-release@v3
with:
tag_name: ${{ env.NIGHTLY_TAG }}
name: "Nightly Build (${{ needs.check-changes.outputs.nightly_version }})"
body: |
Automated nightly build from `main` branch.
**Version**: `${{ needs.check-changes.outputs.nightly_version }}`
**Commit**: ${{ github.sha }}
**Date**: ${{ github.event.head_commit.timestamp || github.event.repository.updated_at }}
> **Warning**: Nightly builds are untested and may be unstable.
prerelease: true
files: |
release-assets/**/*.AppImage
release-assets/**/*.deb
release-assets/**/*.dmg
release-assets/**/*.rpm
release-assets/**/*bitfun-installer.exe