@@ -77,12 +77,22 @@ jobs:
7777 shell : pwsh
7878 env :
7979 SUBSCRIPTION_ENCRYPT_KEY : ${{ secrets.SUBSCRIPTION_ENCRYPT_KEY }}
80+ # For pre-release tags (containing '-') point the updater at the dev branch
81+ # so test builds don't check the production manifest.
82+ MANIFEST_URL_OVERRIDE : ${{ contains(github.ref_name, '-') && 'https://raw.githubusercontent.com/AandStep/ResultV/dev/update.json' || '' }}
8083 run : |
8184 $key = $env:SUBSCRIPTION_ENCRYPT_KEY
85+ $ldflags = ""
8286 if ($key) {
83- wails build -clean -nsis -platform windows/amd64 -ldflags "-X resultproxy-wails/internal/proxy.subscriptionEncryptKey=$key"
87+ $ldflags = "-X resultproxy-wails/internal/proxy.subscriptionEncryptKey=$key"
88+ }
89+ $manifestOverride = $env:MANIFEST_URL_OVERRIDE
90+ if ($manifestOverride) {
91+ $ldflags = "$ldflags -X resultproxy-wails/internal/updater.ManifestURLOverride=$manifestOverride".Trim()
92+ }
93+ if ($ldflags) {
94+ wails build -clean -nsis -platform windows/amd64 -ldflags $ldflags
8495 } else {
85- Write-Warning "Secret SUBSCRIPTION_ENCRYPT_KEY not set — building without decryption key"
8696 wails build -clean -nsis -platform windows/amd64
8797 }
8898
@@ -157,6 +167,7 @@ jobs:
157167 APPLE_NOTARY_APPLE_ID : ${{ secrets.APPLE_NOTARY_APPLE_ID }}
158168 APPLE_NOTARY_TEAM_ID : ${{ secrets.APPLE_NOTARY_TEAM_ID }}
159169 APPLE_NOTARY_PASSWORD : ${{ secrets.APPLE_NOTARY_PASSWORD }}
170+ MANIFEST_URL_OVERRIDE : ${{ contains(github.ref_name, '-') && 'https://raw.githubusercontent.com/AandStep/ResultV/dev/update.json' || '' }}
160171 run : |
161172 chmod +x build-macos.sh
162173 ./build-macos.sh
@@ -215,6 +226,7 @@ jobs:
215226 - name : Build Linux artifacts
216227 env :
217228 SUBSCRIPTION_ENCRYPT_KEY : ${{ secrets.SUBSCRIPTION_ENCRYPT_KEY }}
229+ MANIFEST_URL_OVERRIDE : ${{ contains(github.ref_name, '-') && 'https://raw.githubusercontent.com/AandStep/ResultV/dev/update.json' || '' }}
218230 run : |
219231 chmod +x build-linux.sh
220232 ./build-linux.sh
@@ -301,6 +313,84 @@ jobs:
301313 body_path : RELEASE_BODY.txt
302314 files : release-assets/*
303315 draft : false
304- prerelease : false
316+ # Tags with a hyphen (e.g. v3.2.0-dev.1) are pre-releases.
317+ # Pre-releases are visible on GitHub but not shown as "Latest release",
318+ # so production auto-update is unaffected.
319+ prerelease : ${{ contains(github.ref_name, '-') }}
320+ env :
321+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
322+
323+ - name : Compute sha256 and update update.json platforms
324+ run : |
325+ cat > update_manifest.cjs <<'NODE_EOF'
326+ const fs = require('fs');
327+ const path = require('path');
328+ const crypto = require('crypto');
329+
330+ const tag = process.env.GITHUB_REF_NAME; // e.g. "v3.2.0"
331+ const version = tag.replace(/^v/, '');
332+ const repo = process.env.GITHUB_REPOSITORY; // "AandStep/ResultV"
333+ const baseURL = `https://github.com/${repo}/releases/download/${tag}`;
334+ const dir = 'release-assets';
335+
336+ function sha256File(p) {
337+ return crypto.createHash('sha256').update(fs.readFileSync(p)).digest('hex');
338+ }
339+
340+ const files = fs.readdirSync(dir);
341+
342+ const portableFile = files.find(f => /^ResultV.*\.exe$/i.test(f) && !/installer/i.test(f) && !/setup/i.test(f));
343+ const installerFile = files.find(f => /installer.*\.exe$/i.test(f) || /setup.*\.exe$/i.test(f));
344+ const dmgFile = files.find(f => /\.dmg$/i.test(f));
345+ const appimageFile = files.find(f => /\.AppImage$/i.test(f));
346+ const debFile = files.find(f => /\.deb$/i.test(f));
347+
348+ const update = JSON.parse(fs.readFileSync('update.json', 'utf8'));
349+ update.version = version;
350+ update.platforms = {};
351+
352+ function addPlatform(key, filename) {
353+ if (!filename) return;
354+ const p = path.join(dir, filename);
355+ if (!fs.existsSync(p)) return;
356+ const stat = fs.statSync(p);
357+ update.platforms[key] = {
358+ url: `${baseURL}/${filename}`,
359+ sha256: sha256File(p),
360+ size: stat.size,
361+ };
362+ console.log(`[${key}] ${filename} sha256=${update.platforms[key].sha256} size=${stat.size}`);
363+ }
364+
365+ addPlatform('windows-amd64-portable', portableFile);
366+ addPlatform('windows-amd64-installer', installerFile);
367+ addPlatform('darwin-universal', dmgFile);
368+ addPlatform('linux-amd64-appimage', appimageFile);
369+ addPlatform('linux-amd64-deb', debFile);
370+
371+ fs.writeFileSync('update.json', JSON.stringify(update, null, 2) + '\n');
372+ console.log('update.json written with platforms:', Object.keys(update.platforms).join(', ') || '(none)');
373+ NODE_EOF
374+ node update_manifest.cjs
375+
376+ # For stable releases (no hyphen): commit update.json to main so all users
377+ # receive the update notification. For pre-releases (e.g. v3.2.0-dev.1):
378+ # commit to dev branch only — production users are unaffected.
379+ - name : Commit updated update.json
380+ run : |
381+ # Choose target branch based on whether this is a pre-release tag.
382+ if [[ "${{ github.ref_name }}" == *"-"* ]]; then
383+ TARGET_BRANCH="dev"
384+ else
385+ TARGET_BRANCH="main"
386+ fi
387+ git config user.name "github-actions[bot]"
388+ git config user.email "github-actions[bot]@users.noreply.github.com"
389+ git fetch origin "$TARGET_BRANCH"
390+ git checkout "$TARGET_BRANCH"
391+ git add update.json
392+ git diff --cached --quiet || \
393+ git commit -m "chore: update update.json platforms for ${{ github.ref_name }} [skip ci]"
394+ git push origin "$TARGET_BRANCH"
305395 env :
306396 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
0 commit comments