Skip to content

A native macOS / windows / Linux database IDE built with Swift and AppKit. Connect to PostgreSQL, MySQL, SQLite, and Redis from a single app with a fast, keyboard-driven interface.

C++

build(publish): cut GitHub release with DMG asset after R2 upload

Tobi316de5c5be4f
diff --git a/scripts/publish.sh b/scripts/publish.sh
index 9cc3994..62ad0a5 100755
--- a/scripts/publish.sh
+++ b/scripts/publish.sh
@@ -1,29 +1,33 @@
#!/bin/bash
-# publish.sh — Generate Sparkle appcast and upload release artifacts to Cloudflare R2.
+# publish.sh — Generate Sparkle appcast, upload to Cloudflare R2, and cut a GitHub release.
#
# Usage:
-# ./scripts/publish.sh # Upload only the current version's DMG + appcast
+# ./scripts/publish.sh # Upload current version's DMG + appcast, tag GH release
# UPLOAD_ALL=1 ./scripts/publish.sh # Re-upload every DMG in dist/ (bucket resync)
-# DRY_RUN=1 ./scripts/publish.sh # Generate appcast locally, skip upload
+# DRY_RUN=1 ./scripts/publish.sh # Generate appcast locally, skip upload + release
# SKIP_APPCAST=1 ./scripts/publish.sh # Upload existing artifacts, no appcast regen
+# SKIP_GH_RELEASE=1 ./scripts/publish.sh # Skip GitHub release creation
#
# Env:
# R2_BUCKET Cloudflare R2 bucket name (default: gridex-downloads)
# R2_PREFIX Path prefix in bucket (default: macos)
# FEED_BASE_URL Public URL where the DMGs are served (default: https://cdn.gridex.app/macos)
-# DRY_RUN 1 = generate appcast locally, skip R2 upload
+# DRY_RUN 1 = generate appcast locally, skip R2 upload + GH release
# SKIP_APPCAST 1 = skip appcast regeneration (re-upload only)
# UPLOAD_ALL 1 = upload every dist/*.dmg, not just the current version
+# SKIP_GH_RELEASE 1 = skip `gh release create` / asset upload
#
# Requirements:
# • generate_appcast from Sparkle (found automatically under .build/artifacts)
# • wrangler CLI (npm i -g wrangler) with `wrangler login` completed
# • EdDSA private key previously generated via `generate_keys` (stored in Keychain)
+# • gh CLI (brew install gh) authenticated via `gh auth login` — for GitHub releases
#
# Flow:
# 1. Find generate_appcast in SPM artifacts
# 2. Run generate_appcast against dist/ → signs each DMG with EdDSA, emits appcast.xml
-# 3. Upload the current version's DMG (or everything if UPLOAD_ALL=1) + appcast.xml
+# 3. Upload the current version's DMG (or everything if UPLOAD_ALL=1) + appcast.xml to R2
+# 4. Create / update GitHub release v$VERSION with the DMG(s) attached
set -euo pipefail
@@ -37,6 +41,7 @@ FEED_BASE_URL="${FEED_BASE_URL:-https://cdn.gridex.app/macos}"
DRY_RUN="${DRY_RUN:-0}"
SKIP_APPCAST="${SKIP_APPCAST:-0}"
UPLOAD_ALL="${UPLOAD_ALL:-0}"
+SKIP_GH_RELEASE="${SKIP_GH_RELEASE:-0}"
# Current version drives the default "new DMG only" upload path.
CURRENT_VERSION=$(/usr/libexec/PlistBuddy -c "Print :CFBundleShortVersionString" "$PROJECT_DIR/macos/Resources/Info.plist" 2>/dev/null || true)
@@ -131,8 +136,35 @@ if [ -f "$DIST_DIR/appcast.xml" ]; then
--remote
fi
+# 5. GitHub release — always for the current version only (never historical
+# rebuilds), so UPLOAD_ALL=1 doesn't accidentally cut a dozen releases.
+if [ "$SKIP_GH_RELEASE" != "1" ]; then
+ tag="v$CURRENT_VERSION"
+ release_dmgs=()
+ for dmg in "${dmgs_to_upload[@]}"; do
+ [[ "$(basename "$dmg")" == Gridex-"$CURRENT_VERSION"-*.dmg ]] && release_dmgs+=("$dmg")
+ done
+
+ echo ""
+ echo "→ GitHub release $tag..."
+ if ! command -v gh >/dev/null 2>&1; then
+ echo " ⚠ gh CLI not found — install with 'brew install gh' or set SKIP_GH_RELEASE=1"
+ elif [ ${#release_dmgs[@]} -eq 0 ]; then
+ echo " ⚠ No DMG matched Gridex-$CURRENT_VERSION-*.dmg; skipping release"
+ elif gh release view "$tag" >/dev/null 2>&1; then
+ echo " ↑ Attaching assets to existing $tag (--clobber overwrites same-named files)"
+ gh release upload "$tag" "${release_dmgs[@]}" --clobber
+ else
+ echo " + Creating release $tag on current HEAD with auto-generated notes"
+ gh release create "$tag" "${release_dmgs[@]}" \
+ --title "$tag" \
+ --generate-notes
+ fi
+fi
+
echo ""
echo "═══════════════════════════════════════════"
-echo " ✓ Published to R2"
+echo " ✓ Published"
echo " Appcast: $FEED_BASE_URL/appcast.xml"
+[ "$SKIP_GH_RELEASE" != "1" ] && echo " Release: https://github.com/$(gh repo view --json nameWithOwner --jq .nameWithOwner 2>/dev/null)/releases/tag/v$CURRENT_VERSION"
echo "═══════════════════════════════════════════"