diff --git a/.github/workflows/build-desktop.yml b/.github/workflows/build-desktop.yml new file mode 100644 index 00000000000..c8b8ae9b645 --- /dev/null +++ b/.github/workflows/build-desktop.yml @@ -0,0 +1,128 @@ +name: Build Desktop App + +on: + workflow_call: + inputs: + channel: + description: "Release channel (stable or canary)" + required: true + type: string + version_suffix: + description: "Version suffix to append (e.g., -canary). Empty for stable." + required: false + type: string + default: "" + electron_builder_config: + description: "Electron builder config file" + required: false + type: string + default: "electron-builder.ts" + artifact_prefix: + description: "Prefix for artifact names" + required: false + type: string + default: "desktop" + artifact_retention_days: + description: "Number of days to retain artifacts" + required: false + type: number + default: 30 + +jobs: + build: + name: Build - macOS (${{ matrix.arch }}) + runs-on: macos-latest + environment: production + + strategy: + fail-fast: false + matrix: + arch: [arm64] + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Setup Bun + uses: oven-sh/setup-bun@v1 + with: + bun-version: "1.3.2" + + - name: Cache dependencies + uses: actions/cache@v4 + with: + path: | + ~/.bun/install/cache + key: ${{ runner.os }}-bun-${{ github.sha }} + restore-keys: | + ${{ runner.os }}-bun- + + - name: Install dependencies + run: bun install --frozen + + - name: Set version suffix + if: inputs.version_suffix != '' + working-directory: apps/desktop + run: | + # Read current version and append suffix + CURRENT_VERSION=$(node -p "require('./package.json').version") + NEW_VERSION="${CURRENT_VERSION}${{ inputs.version_suffix }}" + echo "Setting version to: $NEW_VERSION" + # Update package.json version using node + node -e " + const fs = require('fs'); + const pkg = require('./package.json'); + pkg.version = '$NEW_VERSION'; + fs.writeFileSync('./package.json', JSON.stringify(pkg, null, '\t') + '\n'); + " + echo "Updated package.json version to $NEW_VERSION" + + - name: Clean dev folder + working-directory: apps/desktop + run: bun run clean:dev + + - name: Compile app with electron-vite + working-directory: apps/desktop + env: + NEXT_PUBLIC_POSTHOG_KEY: ${{ secrets.NEXT_PUBLIC_POSTHOG_KEY }} + NEXT_PUBLIC_POSTHOG_HOST: ${{ secrets.NEXT_PUBLIC_POSTHOG_HOST }} + GOOGLE_CLIENT_ID: ${{ secrets.GOOGLE_CLIENT_ID }} + GH_CLIENT_ID: ${{ secrets.GH_CLIENT_ID }} + NEXT_PUBLIC_WEB_URL: ${{ secrets.NEXT_PUBLIC_WEB_URL }} + NEXT_PUBLIC_API_URL: ${{ secrets.NEXT_PUBLIC_API_URL }} + SENTRY_DSN_DESKTOP: ${{ secrets.SENTRY_DSN_DESKTOP }} + run: bun run compile:app + + - name: Build Electron app + working-directory: apps/desktop + env: + CSC_LINK: ${{ secrets.MAC_CERTIFICATE }} + CSC_KEY_PASSWORD: ${{ secrets.MAC_CERTIFICATE_PASSWORD }} + APPLE_ID: ${{ secrets.APPLE_ID }} + APPLE_APP_SPECIFIC_PASSWORD: ${{ secrets.APPLE_ID_PASSWORD }} + APPLE_TEAM_ID: ${{ secrets.APPLE_TEAM_ID }} + run: bun run package -- --publish never --config ${{ inputs.electron_builder_config }} + + - name: Upload DMG artifact + uses: actions/upload-artifact@v4 + with: + name: ${{ inputs.artifact_prefix }}-mac-${{ matrix.arch }}-dmg + path: apps/desktop/release/*.dmg + retention-days: ${{ inputs.artifact_retention_days }} + if-no-files-found: error + + - name: Upload ZIP artifact + uses: actions/upload-artifact@v4 + with: + name: ${{ inputs.artifact_prefix }}-mac-${{ matrix.arch }}-zip + path: apps/desktop/release/*.zip + retention-days: ${{ inputs.artifact_retention_days }} + if-no-files-found: error + + - name: Upload auto-update manifest + uses: actions/upload-artifact@v4 + with: + name: ${{ inputs.artifact_prefix }}-mac-update-manifest + path: apps/desktop/release/*-mac.yml + retention-days: ${{ inputs.artifact_retention_days }} + if-no-files-found: error diff --git a/.github/workflows/release-desktop-canary.yml b/.github/workflows/release-desktop-canary.yml new file mode 100644 index 00000000000..a7624cf94f8 --- /dev/null +++ b/.github/workflows/release-desktop-canary.yml @@ -0,0 +1,111 @@ +name: Release Desktop Canary + +on: + schedule: + # Every 12 hours at 12 AM and 12 PM UTC + - cron: "0 0,12 * * *" + workflow_dispatch: # Manual trigger for testing + +permissions: + contents: write + +jobs: + check-changes: + name: Check for changes + runs-on: ubuntu-latest + outputs: + should_build: ${{ steps.check.outputs.should_build }} + short_sha: ${{ steps.check.outputs.short_sha }} + build_time: ${{ steps.check.outputs.build_time }} + + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Check for changes since last canary + id: check + run: | + SHORT_SHA=$(git rev-parse --short HEAD) + echo "short_sha=$SHORT_SHA" >> $GITHUB_OUTPUT + + # Capture build timestamp (works for both scheduled and manual runs) + echo "build_time=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> $GITHUB_OUTPUT + + # Get the commit SHA of the last canary release + LAST_CANARY_SHA=$(git rev-parse desktop-canary 2>/dev/null || echo "") + + if [ -z "$LAST_CANARY_SHA" ]; then + echo "No previous canary release found, building..." + echo "should_build=true" >> $GITHUB_OUTPUT + elif [ "$LAST_CANARY_SHA" = "$(git rev-parse HEAD)" ]; then + echo "No changes since last canary release, skipping..." + echo "should_build=false" >> $GITHUB_OUTPUT + else + echo "Changes detected since last canary, building..." + echo "should_build=true" >> $GITHUB_OUTPUT + fi + + build: + needs: check-changes + if: needs.check-changes.outputs.should_build == 'true' + uses: ./.github/workflows/build-desktop.yml + with: + channel: canary + version_suffix: "-canary" + electron_builder_config: electron-builder.canary.ts + artifact_prefix: desktop-canary + artifact_retention_days: 7 + secrets: inherit + + release: + name: Update Canary Release + needs: [check-changes, build] + if: needs.check-changes.outputs.should_build == 'true' + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Download all artifacts + uses: actions/download-artifact@v4 + with: + path: release-artifacts + pattern: desktop-canary-* + merge-multiple: true + + - name: List artifacts + run: | + echo "Release artifacts:" + ls -la release-artifacts/ + + - name: Delete existing canary release + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + # Delete existing release if it exists + gh release delete desktop-canary --yes || true + # Delete the tag + git push origin :refs/tags/desktop-canary || true + + - name: Create Canary Release + uses: softprops/action-gh-release@v2 + with: + tag_name: desktop-canary + name: "Superset Desktop Canary" + body: | + **Internal Testing Build** + + This is an automated canary build from `main` branch. + + - Commit: ${{ github.sha }} + - Short SHA: ${{ needs.check-changes.outputs.short_sha }} + - Built: ${{ needs.check-changes.outputs.build_time }} + + ⚠️ This build is for internal testing only and may be unstable. + prerelease: true + files: release-artifacts/* + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/release-desktop.yml b/.github/workflows/release-desktop.yml index 3b5ca82a15c..41ea855d402 100644 --- a/.github/workflows/release-desktop.yml +++ b/.github/workflows/release-desktop.yml @@ -16,95 +16,14 @@ permissions: jobs: build: - name: Build - macOS (${{ matrix.arch }}) - runs-on: macos-latest - environment: production + uses: ./.github/workflows/build-desktop.yml + with: + channel: stable + electron_builder_config: electron-builder.ts + artifact_prefix: desktop + artifact_retention_days: 30 + secrets: inherit - strategy: - fail-fast: false - matrix: - arch: [arm64] - # To build for Intel Macs too, uncomment: - # arch: [arm64, x64] - - steps: - - name: Checkout code - uses: actions/checkout@v4 - - - name: Setup Bun - uses: oven-sh/setup-bun@v1 - with: - bun-version: '1.3.2' - - - name: Cache dependencies - uses: actions/cache@v4 - with: - path: | - ~/.bun/install/cache - key: ${{ runner.os }}-bun-${{ github.sha }} - restore-keys: | - ${{ runner.os }}-bun- - - - name: Install dependencies - run: bun install --frozen - - # Run prebuild and compile steps before electron-builder - - name: Clean dev folder - working-directory: apps/desktop - run: bun run clean:dev - - - name: Compile app with electron-vite - working-directory: apps/desktop - env: - NEXT_PUBLIC_POSTHOG_KEY: ${{ secrets.NEXT_PUBLIC_POSTHOG_KEY }} - NEXT_PUBLIC_POSTHOG_HOST: ${{ secrets.NEXT_PUBLIC_POSTHOG_HOST }} - GOOGLE_CLIENT_ID: ${{ secrets.GOOGLE_CLIENT_ID }} - GH_CLIENT_ID: ${{ secrets.GH_CLIENT_ID }} - NEXT_PUBLIC_WEB_URL: ${{ secrets.NEXT_PUBLIC_WEB_URL }} - NEXT_PUBLIC_API_URL: ${{ secrets.NEXT_PUBLIC_API_URL }} - SENTRY_DSN_DESKTOP: ${{ secrets.SENTRY_DSN_DESKTOP }} - run: bun run compile:app - - # Build the Electron app for macOS - # Uses --publish never to prevent electron-builder from creating its own release - # The release job handles GitHub release creation - - name: Build Electron app - working-directory: apps/desktop - env: - # macOS code signing and notarization - CSC_LINK: ${{ secrets.MAC_CERTIFICATE }} - CSC_KEY_PASSWORD: ${{ secrets.MAC_CERTIFICATE_PASSWORD }} - APPLE_ID: ${{ secrets.APPLE_ID }} - APPLE_APP_SPECIFIC_PASSWORD: ${{ secrets.APPLE_ID_PASSWORD }} - APPLE_TEAM_ID: ${{ secrets.APPLE_TEAM_ID }} - run: bun run package -- --publish never - - # Upload artifacts separately to avoid nested zips - - name: Upload DMG artifact - uses: actions/upload-artifact@v4 - with: - name: desktop-mac-${{ matrix.arch }}-dmg - path: apps/desktop/release/*.dmg - retention-days: 30 - if-no-files-found: error - - - name: Upload ZIP artifact - uses: actions/upload-artifact@v4 - with: - name: desktop-mac-${{ matrix.arch }}-zip - path: apps/desktop/release/*.zip - retention-days: 30 - if-no-files-found: error - - - name: Upload auto-update manifest - uses: actions/upload-artifact@v4 - with: - name: desktop-mac-update-manifest - path: apps/desktop/release/latest-mac.yml - retention-days: 30 - if-no-files-found: error - - # Create GitHub Release after builds complete release: name: Create GitHub Release needs: build @@ -119,6 +38,7 @@ jobs: uses: actions/download-artifact@v4 with: path: release-artifacts + pattern: desktop-* merge-multiple: true - name: Create stable-named copies for latest download URLs @@ -145,7 +65,7 @@ jobs: ls -la - name: Create Release - uses: softprops/action-gh-release@v1 + uses: softprops/action-gh-release@v2 with: files: release-artifacts/* draft: true diff --git a/apps/desktop/electron-builder.canary.ts b/apps/desktop/electron-builder.canary.ts new file mode 100644 index 00000000000..91b9914ada2 --- /dev/null +++ b/apps/desktop/electron-builder.canary.ts @@ -0,0 +1,58 @@ +/** + * Electron Builder Configuration - Canary Build + * + * Extends the base config with canary-specific overrides for internal testing. + * Can be installed side-by-side with the stable release. + * + * @see https://www.electron.build/configuration/configuration + */ + +import { join } from "node:path"; +import type { Configuration } from "electron-builder"; +import baseConfig from "./electron-builder"; +import pkg from "./package.json"; + +const productName = "Superset Canary"; + +const config: Configuration = { + ...baseConfig, + appId: "com.superset.desktop.canary", + productName, + + // Use GitHub provider for prerelease + // Note: We override with setFeedURL in auto-updater.ts using generic provider, + // so the actual update URL is determined at runtime based on version suffix + publish: { + provider: "github", + owner: "superset-sh", + repo: "superset", + releaseType: "prerelease", + }, + + // macOS overrides + mac: { + ...baseConfig.mac, + icon: join(pkg.resources, "build/icons/icon-canary.icns"), + extendInfo: { + CFBundleName: productName, + CFBundleDisplayName: productName, + }, + }, + + // Linux overrides + linux: { + ...baseConfig.linux, + icon: join(pkg.resources, "build/icons/icon-canary.png"), + synopsis: `${pkg.description} (Canary)`, + artifactName: `superset-canary-\${version}-\${arch}.\${ext}`, + }, + + // Windows overrides + win: { + ...baseConfig.win, + icon: join(pkg.resources, "build/icons/icon-canary.ico"), + artifactName: `${productName}-${pkg.version}-\${arch}.\${ext}`, + }, +}; + +export default config; diff --git a/apps/desktop/electron-builder.ts b/apps/desktop/electron-builder.ts index a58f1210b4c..39e8136c973 100644 --- a/apps/desktop/electron-builder.ts +++ b/apps/desktop/electron-builder.ts @@ -17,6 +17,10 @@ const config: Configuration = { copyright: `Copyright © ${currentYear} — ${author}`, electronVersion: pkg.devDependencies.electron.replace(/^\^/, ""), + // Generate update manifests for all channels (latest.yml, canary.yml, etc.) + // This enables proper channel-based auto-updates following electron-builder conventions + generateUpdatesFilesForAllChannels: true, + // Generate latest-mac.yml for auto-update (workflow handles actual upload) publish: { provider: "github", diff --git a/apps/desktop/src/main/lib/auto-updater.ts b/apps/desktop/src/main/lib/auto-updater.ts index 739846884b7..9052e839289 100644 --- a/apps/desktop/src/main/lib/auto-updater.ts +++ b/apps/desktop/src/main/lib/auto-updater.ts @@ -3,12 +3,31 @@ import { app, dialog } from "electron"; import { autoUpdater } from "electron-updater"; import { env } from "main/env.main"; import { setSkipQuitConfirmation } from "main/index"; +import { prerelease } from "semver"; import { AUTO_UPDATE_STATUS, type AutoUpdateStatus } from "shared/auto-update"; import { PLATFORM } from "shared/constants"; const UPDATE_CHECK_INTERVAL_MS = 1000 * 60 * 60 * 4; // 4 hours -const UPDATE_FEED_URL = - "https://github.com/superset-sh/superset/releases/latest/download"; + +/** + * Detect if this is a prerelease build from app version using semver. + * Versions like "0.0.53-canary" have prerelease component ["canary"]. + * Stable versions like "0.0.53" have no prerelease component. + */ +function isPrereleaseBuild(): boolean { + const version = app.getVersion(); + const prereleaseComponents = prerelease(version); + return prereleaseComponents !== null && prereleaseComponents.length > 0; +} + +const IS_PRERELEASE = isPrereleaseBuild(); + +// Use explicit feed URLs to ensure we always fetch latest-mac.yml from the correct release +// - Stable: fetches from /releases/latest/download/ (latest non-prerelease) +// - Canary: fetches from /releases/download/desktop-canary/ (rolling canary tag) +const UPDATE_FEED_URL = IS_PRERELEASE + ? "https://github.com/superset-sh/superset/releases/download/desktop-canary" + : "https://github.com/superset-sh/superset/releases/latest/download"; export interface AutoUpdateStatusEvent { status: AutoUpdateStatus; @@ -149,8 +168,12 @@ export function setupAutoUpdater(): void { autoUpdater.autoDownload = true; autoUpdater.autoInstallOnAppQuit = true; - autoUpdater.allowDowngrade = false; + // Allow downgrade for prerelease builds so users can switch back to stable + autoUpdater.allowDowngrade = IS_PRERELEASE; + + // Use generic provider with explicit feed URL + // This ensures we always fetch latest-mac.yml from the correct GitHub release autoUpdater.setFeedURL({ provider: "generic", url: UPDATE_FEED_URL, diff --git a/apps/desktop/src/resources/build/icons/icon-canary.icns b/apps/desktop/src/resources/build/icons/icon-canary.icns new file mode 100644 index 00000000000..9979c557092 Binary files /dev/null and b/apps/desktop/src/resources/build/icons/icon-canary.icns differ diff --git a/apps/desktop/src/resources/build/icons/icon-canary.ico b/apps/desktop/src/resources/build/icons/icon-canary.ico new file mode 100644 index 00000000000..70a4daa1ef9 Binary files /dev/null and b/apps/desktop/src/resources/build/icons/icon-canary.ico differ diff --git a/apps/desktop/src/resources/build/icons/icon-canary.png b/apps/desktop/src/resources/build/icons/icon-canary.png new file mode 100644 index 00000000000..b3f3337e44a Binary files /dev/null and b/apps/desktop/src/resources/build/icons/icon-canary.png differ