diff --git a/.github/workflows/mac-build.yml b/.github/workflows/mac-build.yml index 3df00ef..5da74af 100644 --- a/.github/workflows/mac-build.yml +++ b/.github/workflows/mac-build.yml @@ -24,6 +24,7 @@ jobs: mac-build: name: Build and upload macOS DMG runs-on: macos-latest + timeout-minutes: 60 permissions: contents: write @@ -37,7 +38,18 @@ jobs: node-version: '20.x' cache: 'npm' + - name: Cache Electron binaries + uses: actions/cache@v4 + with: + path: | + ~/Library/Caches/electron + ~/Library/Caches/electron-builder + key: ${{ runner.os }}-electron-${{ hashFiles('**/package.json', '**/package-lock.json') }} + restore-keys: | + ${{ runner.os }}-electron- + - name: Install dependencies + timeout-minutes: 15 run: npm install --legacy-peer-deps - name: Pin version in package.json @@ -55,10 +67,23 @@ jobs: VRSRC_API_KEY: ${{ secrets.VRSRC_API_KEY }} VRSRC_CLIENT_ID: ${{ secrets.VRSRC_CLIENT_ID }} VRSRC_BUILD_SECRET: ${{ secrets.VRSRC_BUILD_SECRET }} + ELECTRON_BUILDER_DOWNLOAD_TIMEOUT: 120000 + npm_config_fetch_timeout: 120000 + npm_config_fetch_retries: 5 + timeout-minutes: 25 run: | - npx electron-vite build - npx electron-builder --mac --dir --x64 --publish never - npx electron-builder --mac --dir --arm64 --publish never + # Retry: the usual failure is a hung electron/electron-builder download. + for i in 1 2 3; do + if npx electron-vite build \ + && npx electron-builder --mac --dir --x64 --publish never \ + && npx electron-builder --mac --dir --arm64 --publish never; then + exit 0 + fi + echo "Build attempt $i failed, retrying in 30s..." + sleep 30 + done + echo "Build failed after 3 attempts" + exit 1 - name: Apply ad-hoc code signature to both app bundles shell: bash diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index c104400..19c3acb 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -8,6 +8,11 @@ on: default: 'auto' type: choice options: [auto, patch, minor, major] + rebuild: + description: 'Redo the CURRENT version (e.g. after a failed build) instead of bumping. A published release stays published; assets are re-uploaded.' + required: false + default: false + type: boolean version: description: 'Optional explicit version (e.g. 2.1.1). Leave empty for automatic. Must still follow VERSIONING.md.' required: false @@ -39,11 +44,13 @@ jobs: env: INPUT_VERSION: ${{ github.event.inputs.version }} INPUT_BUMP: ${{ github.event.inputs.bump }} + INPUT_REBUILD: ${{ github.event.inputs.rebuild }} run: | set -euo pipefail # All versioning rules live in scripts/next_version.py (see VERSIONING.md). ARGS=(--bump "${INPUT_BUMP:-auto}" --explain) if [ -n "${INPUT_VERSION:-}" ]; then ARGS+=(--version "$INPUT_VERSION"); fi + if [ "${INPUT_REBUILD:-false}" = "true" ]; then ARGS+=(--rebuild); fi VERSION="$(python3 scripts/next_version.py "${ARGS[@]}")" if [ -z "$VERSION" ]; then echo "::error::Could not resolve a version" @@ -90,7 +97,11 @@ jobs: strategy: fail-fast: false matrix: - os: [macos-latest, ubuntu-latest, windows-latest] + # macOS is NOT built here: the separate `mac` job (mac-build.yml) builds and + # uploads the DMGs. Keeping a mac leg in this matrix meant a mac timeout + # failed a leg of `build`, and "Re-run failed jobs" then re-ran + # create_release and everything after it. + os: [ubuntu-latest, windows-latest] outputs: package_version: ${{ steps.build_details.outputs.package_version }} @@ -255,26 +266,34 @@ jobs: TAG="v${VERSION}" echo "Creating draft release $TAG in $REPO at commit $TARGET_SHA" - # Best-effort cleanup of any stale release / tag from a previous failed run. - # Failure here must NOT abort the job, so wrap each call in `|| true`. - if gh release view "$TAG" --repo "$REPO" >/dev/null 2>&1; then - echo "Found existing release $TAG, deleting before recreate..." - gh release delete "$TAG" --repo "$REPO" --yes || true + # A release that is already PUBLISHED (e.g. re-running to add a missing + # platform) must stay published: do not delete/recreate it as a draft, + # just re-upload the assets below with --clobber. + IS_DRAFT="$(gh release view "$TAG" --repo "$REPO" --json isDraft -q .isDraft 2>/dev/null || echo none)" + if [ "$IS_DRAFT" = "false" ]; then + echo "Release $TAG is already published: leaving it as is and only uploading assets." + else + # Best-effort cleanup of any stale release / tag from a previous failed run. + # Failure here must NOT abort the job, so wrap each call in `|| true`. + if gh release view "$TAG" --repo "$REPO" >/dev/null 2>&1; then + echo "Found existing release $TAG, deleting before recreate..." + gh release delete "$TAG" --repo "$REPO" --yes || true + fi + # Tag may exist independently of the release; delete if present. + gh api -X DELETE "repos/$REPO/git/refs/tags/$TAG" >/dev/null 2>&1 || true + + # Generate release notes from .github/release-name.txt and .github/release-changelog.md + RELEASE_NAME="$(head -1 .github/release-name.txt | tr -d '\r\n')" + NOTES="$(node .github/scripts/generate-release-notes.js "$VERSION")" + + gh release create "$TAG" \ + --repo "$REPO" \ + --title "Release v${VERSION} — ${RELEASE_NAME}" \ + --draft \ + --target "$TARGET_SHA" \ + --notes "$NOTES" + echo "Created draft release $TAG." fi - # Tag may exist independently of the release; delete if present. - gh api -X DELETE "repos/$REPO/git/refs/tags/$TAG" >/dev/null 2>&1 || true - - # Generate release notes from .github/release-name.txt and .github/release-changelog.md - RELEASE_NAME="$(head -1 .github/release-name.txt | tr -d '\r\n')" - NOTES="$(node .github/scripts/generate-release-notes.js "$VERSION")" - - gh release create "$TAG" \ - --repo "$REPO" \ - --title "Release v${VERSION} — ${RELEASE_NAME}" \ - --draft \ - --target "$TARGET_SHA" \ - --notes "$NOTES" - echo "Created draft release $TAG." # Upload artifacts. Each missing/empty dir is logged but not fatal. for DIR in \ diff --git a/VERSIONING.md b/VERSIONING.md index 25855f8..9dee51c 100644 --- a/VERSIONING.md +++ b/VERSIONING.md @@ -7,7 +7,8 @@ automatically from the commit messages since the last release, using `scripts/ne 1. Format is exactly three numbers, e.g. `2.1.1`. No `v` in the version (the git tag is `v2.1.1`), no leading zeros, no suffixes. -2. Versions only go up. A release must be newer than the last one. +2. Versions only go up. A release must be newer than the last one. The one exception is **rebuild** + (below), which redoes the current version without bumping it. 3. The bump is decided by the highest-impact commit since the last release: | Bump | When | Commit examples | @@ -37,6 +38,15 @@ The workflow writes the version into `package.json`, commits `chore: bump versio and tags `vX.Y.Z`. The last release is found from the highest `v*` tag, or from the latest bump commit if there are no tags. +## Redoing a release (failed build, missing platform) + +Tick `rebuild` when running **Create Release**. It reuses the current version (the higher of the latest +tag and `package.json`) and never bumps. If that release is already published it stays published and +the assets are re-uploaded; a draft is recreated as a draft. + +To retry only the macOS build, run the **Mac Build** workflow with that version instead. It only uploads +the two DMGs and touches nothing else. + ## Check before releasing ```bash diff --git a/scripts/next_version.py b/scripts/next_version.py index 45b0cfd..dea753b 100644 --- a/scripts/next_version.py +++ b/scripts/next_version.py @@ -6,6 +6,7 @@ python scripts/next_version.py --bump minor # force a bump level python scripts/next_version.py --version 2.1.1 # explicit version (validated) python scripts/next_version.py --explain # also print the commits behind the decision + python scripts/next_version.py --rebuild # redo the CURRENT version (failed build), no bump Prints only the version on stdout (so CI can capture it); reasoning goes to stderr. Exit code 1 means "no valid version" (nothing releasable, or an override broke the rules). @@ -122,11 +123,27 @@ def main(): ap.add_argument("--bump", choices=["auto", "major", "minor", "patch"], default="auto") ap.add_argument("--version", default="", help="explicit version; must be valid and >= what the rules compute") ap.add_argument("--explain", action="store_true") + ap.add_argument("--rebuild", action="store_true", + help="re-release the current version (latest tag or package.json, whichever is higher) without bumping") a = ap.parse_args() base, ref = last_release() print(f"Last release: {fmt(base)} ({ref or 'package.json'})", file=sys.stderr) + if a.rebuild: + pkg = parse(json.loads((REPO / "package.json").read_text(encoding="utf-8"))["version"]) + current = max(base, pkg) + if a.version: + try: + wanted = parse(a.version.lstrip("v")) + except ValueError as e: + die(str(e)) + if wanted != current: + die(f"--rebuild redoes the current version {fmt(current)}, not {fmt(wanted)}") + print(f"Rebuild: keeping current version {fmt(current)}", file=sys.stderr) + print(fmt(current)) + return + level, reasons = "none", [] for subject, body in commits_since(ref): lv, why = classify(subject, body)