From 5a8d77c4948ee5f57bd0a589a18bcad89d035e0a Mon Sep 17 00:00:00 2001 From: bigjakk Date: Thu, 16 Apr 2026 08:26:26 -0700 Subject: [PATCH] ci: auto-detect patch vs full, control asar upload accordingly --- .github/workflows/build-release.yml | 69 +++++++++++++---------------- 1 file changed, 30 insertions(+), 39 deletions(-) diff --git a/.github/workflows/build-release.yml b/.github/workflows/build-release.yml index ae2eaa1..a09732e 100644 --- a/.github/workflows/build-release.yml +++ b/.github/workflows/build-release.yml @@ -75,7 +75,7 @@ jobs: CHANGED=$(git diff --name-only "$PREV_TAG"..HEAD) echo "$CHANGED" - # Files that require a full (installer) build + # Files that require a full (installer-only) release FULL_TRIGGERS="electron-builder.yml|scripts/download-electron.js" if echo "$CHANGED" | grep -qE "^($FULL_TRIGGERS)$"; then @@ -105,9 +105,8 @@ jobs: with: node-version: '22' - # Full build needs wine + system deps for electron-builder - name: Install system dependencies - if: steps.version-check.outputs.SKIP == 'false' && steps.release-type.outputs.TYPE == 'full' + if: steps.version-check.outputs.SKIP == 'false' run: | sudo dpkg --add-architecture i386 sudo apt-get update -qq @@ -123,39 +122,29 @@ jobs: if: steps.version-check.outputs.SKIP == 'false' run: npm ci --legacy-peer-deps - # ── Patch release: asar only ── - - - name: Build asar - if: steps.version-check.outputs.SKIP == 'false' && steps.release-type.outputs.TYPE == 'patch' - run: npm run build:asar - - # ── Full release: installer + asar ── - - name: Build source - if: steps.version-check.outputs.SKIP == 'false' && steps.release-type.outputs.TYPE == 'full' + if: steps.version-check.outputs.SKIP == 'false' run: npm run build - name: Build Windows distributables - if: steps.version-check.outputs.SKIP == 'false' && steps.release-type.outputs.TYPE == 'full' + if: steps.version-check.outputs.SKIP == 'false' env: WINEDEBUG: "-all" run: npx electron-builder --win -c.electronDist=node_modules/electron/dist-win --publish never - name: Build Linux distributables - if: steps.version-check.outputs.SKIP == 'false' && steps.release-type.outputs.TYPE == 'full' + if: steps.version-check.outputs.SKIP == 'false' run: npx electron-builder --linux -c.electronDist=node_modules/electron/dist-linux --publish never - - name: Build asar for full release - if: steps.version-check.outputs.SKIP == 'false' && steps.release-type.outputs.TYPE == 'full' + - name: Build asar for patch updates + if: steps.version-check.outputs.SKIP == 'false' && steps.release-type.outputs.TYPE == 'patch' run: npm run build:asar - name: Report build sizes if: steps.version-check.outputs.SKIP == 'false' run: | echo "=== Release type: ${{ steps.release-type.outputs.TYPE }} ===" - if [ "${{ steps.release-type.outputs.TYPE }}" = "full" ]; then - ls -lh out/*.exe out/*.AppImage out/*.deb 2>/dev/null || true - fi + ls -lh out/*.exe out/*.AppImage out/*.deb 2>/dev/null || true ls -lh out/asar/* 2>/dev/null || true - name: Generate release notes @@ -215,34 +204,36 @@ jobs: exit 1 fi - # Upload asar + checksums (both patch and full releases) - for file in out/asar/app.asar out/asar/checksums.sha256; do + # Upload asar + checksums (patch releases only — signals client to use fast path) + if [ "$RELEASE_TYPE" = "patch" ]; then + for file in out/asar/app.asar out/asar/checksums.sha256; do + [ -f "$file" ] || continue + FILENAME=$(basename "$file") + echo "Uploading: $FILENAME ($(du -h "$file" | cut -f1))" + curl -s -X POST \ + "$GITEA_BASE/api/v1/repos/$REPO/releases/$RELEASE_ID/assets?name=$FILENAME" \ + -H "Authorization: token $GITEA_TOKEN" \ + -F "attachment=@$file" \ + | jq -r '" -> \(.name) (\(.size) bytes)"' + done + else + echo "Full release — skipping asar upload (forces installer update)" + fi + + # Upload installers (always — for new users and major updates) + for file in out/*.exe out/*.AppImage out/*.deb; do [ -f "$file" ] || continue FILENAME=$(basename "$file") - echo "Uploading: $FILENAME ($(du -h "$file" | cut -f1))" + SAFE_NAME=$(echo "$FILENAME" | tr ' ' '_') + echo "Uploading: $SAFE_NAME ($(du -h "$file" | cut -f1))" curl -s -X POST \ - "$GITEA_BASE/api/v1/repos/$REPO/releases/$RELEASE_ID/assets?name=$FILENAME" \ + "$GITEA_BASE/api/v1/repos/$REPO/releases/$RELEASE_ID/assets?name=$SAFE_NAME" \ -H "Authorization: token $GITEA_TOKEN" \ -F "attachment=@$file" \ | jq -r '" -> \(.name) (\(.size) bytes)"' done - # Upload installer artifacts (full release only) - if [ "$RELEASE_TYPE" = "full" ]; then - for file in out/*.exe out/*.AppImage out/*.deb; do - [ -f "$file" ] || continue - FILENAME=$(basename "$file") - SAFE_NAME=$(echo "$FILENAME" | tr ' ' '_') - echo "Uploading: $SAFE_NAME ($(du -h "$file" | cut -f1))" - curl -s -X POST \ - "$GITEA_BASE/api/v1/repos/$REPO/releases/$RELEASE_ID/assets?name=$SAFE_NAME" \ - -H "Authorization: token $GITEA_TOKEN" \ - -F "attachment=@$file" \ - | jq -r '" -> \(.name) (\(.size) bytes)"' - done - fi - - echo "All assets uploaded (release type: $RELEASE_TYPE)" + echo "All assets uploaded" - name: Prune old releases if: steps.version-check.outputs.SKIP == 'false'