Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
test:
runs-on: macos-latest
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v5

- name: Run tests
run: make test
Expand All @@ -24,7 +24,7 @@ jobs:
runs-on: macos-latest
needs: test
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v5

- name: Build (unsigned)
run: make build-unsigned
Expand All @@ -33,12 +33,12 @@ jobs:
run: npm install --global create-dmg@8.1.0 && make dmg

- name: Upload build artifact
uses: actions/upload-artifact@v4
uses: actions/upload-artifact@v5
with:
name: Palium.dmg
path: Palium.dmg

- name: Generate artifact attestation
uses: actions/attest@v4
uses: actions/attest-build-provenance@v2
with:
subject-path: palium.dmg
subject-path: Palium.dmg
185 changes: 185 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,185 @@
name: Release

on:
push:
tags: ["v*"]

permissions:
contents: write
id-token: write
attestations: write

env:
SPARKLE_VERSION: "2.9.4"
PAGES_BASE: https://mgruszkiewicz.github.io/palium

jobs:
release:
runs-on: macos-latest
steps:
- uses: actions/checkout@v5
with:
# Full history: the build number is the commit count, and it has to
# keep increasing or Sparkle will not treat the release as newer.
fetch-depth: 0

- name: Derive version
id: version
run: |
TAG="${GITHUB_REF_NAME}"
VERSION="${TAG#v}"
BUILD="$(git rev-list --count HEAD)"
echo "tag=$TAG" >> "$GITHUB_OUTPUT"
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
echo "build=$BUILD" >> "$GITHUB_OUTPUT"
echo "Releasing $VERSION (build $BUILD) from $TAG"

- name: Run tests
run: make test

- name: Build release artifacts
env:
VERSION: ${{ steps.version.outputs.version }}
BUILD: ${{ steps.version.outputs.build }}
run: |
npm install --global create-dmg@8.1.0
make release-artifacts
mv Palium.zip "Palium-${VERSION}.zip"
mv Palium.dmg "Palium-${VERSION}.dmg"

- name: Verify built version matches the tag
env:
VERSION: ${{ steps.version.outputs.version }}
BUILD: ${{ steps.version.outputs.build }}
run: |
PLIST=build/DerivedData/Build/Products/Release/palium.app/Contents/Info.plist
SHORT=$(/usr/libexec/PlistBuddy -c "Print CFBundleShortVersionString" "$PLIST")
BUNDLE=$(/usr/libexec/PlistBuddy -c "Print CFBundleVersion" "$PLIST")
FEED=$(/usr/libexec/PlistBuddy -c "Print SUFeedURL" "$PLIST")
KEY=$(/usr/libexec/PlistBuddy -c "Print SUPublicEDKey" "$PLIST")
echo "built: $SHORT ($BUNDLE) feed: $FEED"
[ "$SHORT" = "$VERSION" ] || { echo "::error::CFBundleShortVersionString $SHORT != $VERSION"; exit 1; }
[ "$BUNDLE" = "$BUILD" ] || { echo "::error::CFBundleVersion $BUNDLE != $BUILD"; exit 1; }
[ -n "$FEED" ] && [ -n "$KEY" ] || { echo "::error::SUFeedURL/SUPublicEDKey missing from the built app"; exit 1; }

- name: Install Sparkle tools
run: |
curl -sSL -o sparkle.tar.xz \
"https://github.com/sparkle-project/Sparkle/releases/download/${SPARKLE_VERSION}/Sparkle-${SPARKLE_VERSION}.tar.xz"
mkdir -p sparkle && tar -xJf sparkle.tar.xz -C sparkle

- name: Sign update with EdDSA key
id: sign
env:
SPARKLE_PRIVATE_KEY: ${{ secrets.SPARKLE_PRIVATE_KEY }}
VERSION: ${{ steps.version.outputs.version }}
run: |
if [ -z "$SPARKLE_PRIVATE_KEY" ]; then
echo "::error::SPARKLE_PRIVATE_KEY secret is not set"; exit 1
fi
ARCHIVE="Palium-${VERSION}.zip"
# Piped via stdin so the key never touches the runner's disk.
SIGNATURE=$(printf '%s' "$SPARKLE_PRIVATE_KEY" \
| ./sparkle/bin/sign_update "$ARCHIVE" --ed-key-file - -p)
printf '%s' "$SPARKLE_PRIVATE_KEY" \
| ./sparkle/bin/sign_update "$ARCHIVE" --verify "$SIGNATURE" --ed-key-file -
echo "::add-mask::$SIGNATURE"
echo "signature=$SIGNATURE" >> "$GITHUB_OUTPUT"
echo "length=$(stat -f%z "$ARCHIVE")" >> "$GITHUB_OUTPUT"

- name: Generate artifact attestation
uses: actions/attest-build-provenance@v2
with:
subject-path: |
Palium-${{ steps.version.outputs.version }}.zip
Palium-${{ steps.version.outputs.version }}.dmg

# The appcast points at these assets, so they must exist before it is published.
- name: Create GitHub release
env:
GH_TOKEN: ${{ github.token }}
TAG: ${{ steps.version.outputs.tag }}
VERSION: ${{ steps.version.outputs.version }}
run: |
gh release create "$TAG" \
--title "Palium $VERSION" \
--generate-notes \
"Palium-${VERSION}.dmg" \
"Palium-${VERSION}.zip"

- name: Publish appcast to GitHub Pages
env:
GH_TOKEN: ${{ github.token }}
TAG: ${{ steps.version.outputs.tag }}
VERSION: ${{ steps.version.outputs.version }}
BUILD: ${{ steps.version.outputs.build }}
SIGNATURE: ${{ steps.sign.outputs.signature }}
LENGTH: ${{ steps.sign.outputs.length }}
run: |
MIN_OS=$(xcodebuild -project palium.xcodeproj -scheme palium -configuration Release \
-showBuildSettings 2>/dev/null \
| awk -F' = ' '/ MACOSX_DEPLOYMENT_TARGET =/ {print $2; exit}')

REPO_URL="https://x-access-token:${GH_TOKEN}@github.com/${GITHUB_REPOSITORY}.git"
if ! git clone --branch gh-pages --depth 1 "$REPO_URL" site 2>/dev/null; then
echo "gh-pages does not exist yet — creating it"
rm -rf site
git clone --depth 1 "$REPO_URL" site
git -C site checkout --orphan gh-pages
git -C site rm -rf . >/dev/null 2>&1 || true
fi

# Sparkle renders these notes in the update prompt.
mkdir -p site/notes
gh release view "$TAG" --json body --jq .body > notes.md
[ -s notes.md ] || echo "See the release page for details." > notes.md
gh api -X POST /markdown \
-f mode=gfm \
-f context="$GITHUB_REPOSITORY" \
-f text="$(cat notes.md)" > notes-body.html
{
echo '<!DOCTYPE html><html><head><meta charset="utf-8">'
echo '<style>body{font:13px -apple-system,sans-serif;margin:0;padding:8px;color:#111}'
echo '@media (prefers-color-scheme:dark){body{background:#1e1e1e;color:#eee}}'
echo 'h1,h2,h3{font-size:1.05em;margin:.8em 0 .3em}code,pre{font-family:ui-monospace,monospace}</style>'
echo "</head><body><h1>Palium ${VERSION}</h1>"
cat notes-body.html
echo '</body></html>'
} > "site/notes/${VERSION}.html"

python3 scripts/appcast.py site/appcast.xml \
--version "$BUILD" \
--short-version "$VERSION" \
--url "https://github.com/${GITHUB_REPOSITORY}/releases/download/${TAG}/Palium-${VERSION}.zip" \
--length "$LENGTH" \
--signature "$SIGNATURE" \
--minimum-system-version "$MIN_OS" \
--release-notes-url "${PAGES_BASE}/notes/${VERSION}.html" \
--full-release-notes-url "https://github.com/${GITHUB_REPOSITORY}/releases" \
--channel-link "${PAGES_BASE}/appcast.xml"

# Stops Pages from running the output through Jekyll.
touch site/.nojekyll

cd site
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add -A
if git diff --cached --quiet; then
echo "appcast unchanged — nothing to publish"
else
git commit -m "release: Palium ${VERSION} (build ${BUILD})"
git push origin gh-pages
fi

- name: Summary
env:
VERSION: ${{ steps.version.outputs.version }}
BUILD: ${{ steps.version.outputs.build }}
run: |
{
echo "### Palium $VERSION (build $BUILD) published"
echo ""
echo "- Appcast: ${PAGES_BASE}/appcast.xml"
echo "- Existing installs pick it up within 24h, or immediately via *Check for Updates…*"
} >> "$GITHUB_STEP_SUMMARY"
7 changes: 6 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
*.mode2v3
*.perspectivev3
*.xcuserstate
project.xcworkspace/
# project.xcworkspace/ is deliberately not ignored: it holds Package.resolved,
# which pins Sparkle to an exact revision for release builds. The xcuserdata/
# rule below still covers the per-user noise inside it.
xcuserdata/

# Generated files
Expand All @@ -29,3 +31,6 @@ Carthage/
*.lock

*.dmg

# Sparkle update archive built by `make zip-app`
/Palium.zip
40 changes: 37 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,35 @@ ARCHIVE := $(BUILD_DIR)/palium.xcarchive
APP := $(ARCHIVE)/Products/Applications/palium.app
ZIP := $(BUILD_DIR)/palium.zip

.PHONY: archive zip clean test build-unsigned
PRODUCTS := $(BUILD_DIR)/DerivedData/Build/Products/Release
RELEASE_APP := $(PRODUCTS)/palium.app

# Version stamped into the built app. Sparkle compares CFBundleVersion (BUILD)
# to decide whether an update is newer, so it must increase monotonically;
# commit count does that for free. Override either from CI.
VERSION ?= $(patsubst v%,%,$(shell git describe --tags --abbrev=0 2>/dev/null))
BUILD ?= $(shell git rev-list --count HEAD 2>/dev/null)

VERSION_FLAGS := $(if $(VERSION),MARKETING_VERSION=$(VERSION)) \
$(if $(BUILD),CURRENT_PROJECT_VERSION=$(BUILD))

# Shippable builds use exactly the Sparkle revision in Package.resolved. Without
# this, the upToNextMajorVersion requirement lets a release silently pick up a
# newer Sparkle than the one that was tested. Bump it via Xcode, not by drifting.
PIN_PACKAGES := -onlyUsePackageVersionsFromResolvedFile

.PHONY: archive zip clean test test-all build-unsigned dmg zip-app release-artifacts version

version:
@echo "MARKETING_VERSION=$(VERSION) CURRENT_PROJECT_VERSION=$(BUILD)"

archive:
xcodebuild -project $(PROJECT) \
-scheme $(SCHEME) \
-configuration $(CONFIG) \
-archivePath $(ARCHIVE) \
$(PIN_PACKAGES) \
$(VERSION_FLAGS) \
archive

zip: archive
Expand All @@ -25,6 +47,8 @@ build-unsigned:
-configuration $(CONFIG) \
-derivedDataPath $(BUILD_DIR)/DerivedData \
CODE_SIGN_IDENTITY=- \
$(PIN_PACKAGES) \
$(VERSION_FLAGS) \
build

test:
Expand All @@ -43,8 +67,18 @@ test-all:
test

dmg:
create-dmg $(BUILD_DIR)/DerivedData/Build/Products/Release/palium.app --dmg-title=Palium --no-version-in-filename $(if $(CI),--no-code-sign)
create-dmg $(RELEASE_APP) --dmg-title=Palium --no-version-in-filename $(if $(CI),--no-code-sign)
@mv -f palium.dmg Palium.dmg 2>/dev/null || true

# Sparkle's update enclosure. ditto (not zip) so symlinks inside
# Sparkle.framework and the code signature survive the round trip.
zip-app:
@rm -f Palium.zip
ditto -c -k --sequesterRsrc --keepParent $(RELEASE_APP) Palium.zip
@echo "Ready for Sparkle: Palium.zip"

release-artifacts: build-unsigned zip-app dmg

clean:
rm -rf $(BUILD_DIR)
rm -rf $(BUILD_DIR) Palium.zip Palium.dmg
xcodebuild -project $(PROJECT) -scheme $(SCHEME) clean
Loading
Loading