Skip to content

Commit 1bea708

Browse files
MarkHersheyclaude
andcommitted
Release a DMG on GitHub for every push to main
A GitHub Actions workflow on macos-26 runs the tests, builds a universal (Apple silicon + Intel) app, packs it into a drag-to-Applications disk image and publishes it as release v<Info.plist version>.<run number>. If Developer ID and notary secrets are set it also signs and notarizes; otherwise the app is signed ad hoc and the notes explain Open Anyway. build.sh gains ARCHS, VERSION, BUILD_NUMBER and SIGN_IDENTITY settings; scripts/make-dmg.sh makes the disk image. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 7638408 commit 1bea708

4 files changed

Lines changed: 196 additions & 9 deletions

File tree

‎.github/workflows/release.yml‎

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
name: Release
2+
3+
# Every push to main runs the tests, builds a universal app, packs it into a disk image and publishes
4+
# it as a GitHub release tagged v<version in Info.plist>.<run number>, e.g. v1.0.12.
5+
on:
6+
push:
7+
branches: [main]
8+
workflow_dispatch:
9+
10+
permissions:
11+
contents: write # create tags and releases
12+
13+
concurrency:
14+
group: release
15+
cancel-in-progress: false
16+
17+
jobs:
18+
release:
19+
runs-on: macos-26
20+
env:
21+
# Optional repository secrets for signing with a Developer ID and notarizing (see README).
22+
# Without them the app is signed ad hoc, and macOS asks people to allow it once.
23+
MACOS_CERTIFICATE_P12: ${{ secrets.MACOS_CERTIFICATE_P12 }}
24+
MACOS_CERTIFICATE_PASSWORD: ${{ secrets.MACOS_CERTIFICATE_PASSWORD }}
25+
NOTARY_APPLE_ID: ${{ secrets.NOTARY_APPLE_ID }}
26+
NOTARY_PASSWORD: ${{ secrets.NOTARY_PASSWORD }}
27+
NOTARY_TEAM_ID: ${{ secrets.NOTARY_TEAM_ID }}
28+
steps:
29+
- uses: actions/checkout@v5
30+
with:
31+
fetch-depth: 0 # full history and tags, for the release notes
32+
33+
- name: Show toolchain
34+
run: |
35+
xcodebuild -version
36+
swiftc --version
37+
38+
- name: Pick version
39+
id: version
40+
run: |
41+
base=$(/usr/libexec/PlistBuddy -c "Print :CFBundleShortVersionString" Resources/Info.plist)
42+
echo "version=$base.$GITHUB_RUN_NUMBER" >> "$GITHUB_OUTPUT"
43+
44+
- name: Run tests
45+
run: ./build.sh --test
46+
47+
- name: Import signing certificate
48+
if: env.MACOS_CERTIFICATE_P12 != ''
49+
run: |
50+
keychain="$RUNNER_TEMP/signing.keychain-db"
51+
keychain_password="$(uuidgen)"
52+
security create-keychain -p "$keychain_password" "$keychain"
53+
security set-keychain-settings -lut 21600 "$keychain"
54+
security unlock-keychain -p "$keychain_password" "$keychain"
55+
echo "$MACOS_CERTIFICATE_P12" | base64 --decode > "$RUNNER_TEMP/certificate.p12"
56+
security import "$RUNNER_TEMP/certificate.p12" -k "$keychain" -P "$MACOS_CERTIFICATE_PASSWORD" -T /usr/bin/codesign
57+
rm "$RUNNER_TEMP/certificate.p12"
58+
security set-key-partition-list -S apple-tool:,apple: -s -k "$keychain_password" "$keychain" > /dev/null
59+
security list-keychains -d user -s "$keychain" $(security list-keychains -d user | xargs)
60+
identity=$(security find-identity -v -p codesigning "$keychain" | grep -o '"Developer ID Application: [^"]*"' | head -1 | tr -d '"')
61+
if [ -z "$identity" ]; then echo "::warning::No Developer ID Application identity in the certificate; signing ad hoc."; fi
62+
echo "SIGN_IDENTITY=$identity" >> "$GITHUB_ENV"
63+
64+
- name: Build universal app
65+
env:
66+
ARCHS: arm64 x86_64
67+
VERSION: ${{ steps.version.outputs.version }}
68+
BUILD_NUMBER: ${{ github.run_number }}
69+
run: ./build.sh
70+
71+
- name: Make disk image
72+
run: scripts/make-dmg.sh "build/World Clocks.app" "build/WorldClocks-${{ steps.version.outputs.version }}.dmg"
73+
74+
- name: Notarize
75+
if: env.SIGN_IDENTITY != '' && env.NOTARY_APPLE_ID != ''
76+
run: |
77+
dmg="build/WorldClocks-${{ steps.version.outputs.version }}.dmg"
78+
xcrun notarytool submit "$dmg" --apple-id "$NOTARY_APPLE_ID" --password "$NOTARY_PASSWORD" \
79+
--team-id "$NOTARY_TEAM_ID" --wait
80+
xcrun stapler staple "$dmg"
81+
echo "NOTARIZED=1" >> "$GITHUB_ENV"
82+
83+
- name: Publish release
84+
env:
85+
GH_TOKEN: ${{ github.token }}
86+
VERSION: ${{ steps.version.outputs.version }}
87+
run: |
88+
dmg="build/WorldClocks-$VERSION.dmg"
89+
previous=$(git describe --tags --abbrev=0 --match 'v*' HEAD^ 2> /dev/null || true)
90+
{
91+
echo "## Install"
92+
echo
93+
echo "1. Download **WorldClocks-$VERSION.dmg** below and open it."
94+
echo "2. Drag **World Clocks** onto **Applications**."
95+
echo "3. Open World Clocks from Applications. It shows up as **TIME** in the menu bar and as a widget on your desktop."
96+
echo
97+
if [ -z "${NOTARIZED:-}" ]; then
98+
echo "> This build isn't notarized by Apple, so the first time you open it macOS says it can't verify the app."
99+
echo "> Click **Done**, open **System Settings › Privacy & Security**, scroll down and click **Open Anyway**."
100+
echo "> You only need to do this once."
101+
echo
102+
fi
103+
echo "Needs macOS 26 or later, on Apple silicon or Intel."
104+
echo
105+
echo "## Changes"
106+
echo
107+
git log --format='- %s' ${previous:+"$previous"..}HEAD
108+
} > "$RUNNER_TEMP/notes.md"
109+
110+
if gh release view "v$VERSION" > /dev/null 2>&1; then
111+
# A re-run of the same workflow run: replace the disk image.
112+
gh release upload "v$VERSION" "$dmg" --clobber
113+
else
114+
gh release create "v$VERSION" "$dmg" --target "$GITHUB_SHA" \
115+
--title "World Clocks $VERSION" --notes-file "$RUNNER_TEMP/notes.md"
116+
fi

‎README.md‎

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,20 +20,23 @@ A world clock for the macOS desktop and menu bar, for keeping track of several t
2020
- Two places to see it: a Liquid Glass **desktop widget** that sits behind your windows on every Space, and a dotted **TIME** in the menu bar that drops down the same panel. The widget can be turned off.
2121
- Starts at login.
2222

23-
## Requirements
23+
## Download
2424

25-
- macOS 26 or later
26-
- The Xcode Command Line Tools (`xcode-select --install`). Xcode itself isn't needed.
25+
Get the latest **WorldClocks-….dmg** from [Releases](https://github.com/mxshell/BetterWorldClock/releases/latest), open it and drag **World Clocks** onto **Applications**. It needs macOS 26 or later, on Apple silicon or Intel.
2726

28-
## Build and install
27+
Unless a release says it's notarized, macOS can't verify the app the first time you open it. Click **Done**, then open **System Settings › Privacy & Security**, scroll down and click **Open Anyway**. You only need to do this once.
28+
29+
## Build from source
30+
31+
You need macOS 26 or later and the Xcode Command Line Tools (`xcode-select --install`). Xcode itself isn't needed.
2932

3033
```bash
3134
./build.sh # builds build/World Clocks.app
3235
./build.sh --install # also copies it to /Applications and launches it
3336
./build.sh --test # runs the unit tests (swift test)
3437
```
3538

36-
The app is signed ad hoc, which is enough to run it on the Mac that built it. To hand it to someone else, sign it with a Developer ID and notarize it.
39+
The app is signed ad hoc, which is enough to run it on the Mac that built it.
3740

3841
`Package.swift` also lets you open the project in Xcode or any editor with SwiftPM support.
3942

@@ -54,12 +57,28 @@ The app is signed ad hoc, which is enough to run it on the Mac that built it. To
5457
| SwiftUI views | `Sources/WorldClocks/Views` |
5558
| Unit tests (Swift Testing) | `Tests/WorldClocksTests` |
5659
| `Info.plist` and the script that draws the app icon | `Resources` |
60+
| Disk image packaging | `scripts` |
61+
| Release workflow | `.github/workflows` |
5762

5863
- The desktop widget is a borderless window one level above the desktop icons, so app windows always cover it.
5964
- Weather for all cities comes from a single Open-Meteo request every 15 minutes, and again after the Mac wakes.
6065
- Sunrise and sunset come from the standard sunrise equation, accurate to a minute or two.
6166
- Foundation often has no abbreviation for a time zone (it says "GMT+8"), so common ones come from a small built-in table.
6267

68+
## Releases
69+
70+
Every push to `main` runs [the release workflow](.github/workflows/release.yml) on GitHub Actions. It runs the tests, builds a universal app for Apple silicon and Intel, packs it into a disk image with `scripts/make-dmg.sh`, and publishes a release. Releases are numbered from the version in `Resources/Info.plist` plus the workflow run number, such as v1.0.12. To start a new series, change the version there.
71+
72+
Out of the box, releases are signed ad hoc. To sign them with a Developer ID and have Apple notarize them, so they open without the extra step, add these repository secrets (Settings › Secrets and variables › Actions):
73+
74+
| Secret | What it is |
75+
|---|---|
76+
| `MACOS_CERTIFICATE_P12` | Your **Developer ID Application** certificate and its private key, exported from Keychain Access as a .p12 file, then base64-encoded: `base64 -i certificate.p12 \| pbcopy` |
77+
| `MACOS_CERTIFICATE_PASSWORD` | The password you gave the .p12 file |
78+
| `NOTARY_APPLE_ID` | The Apple Account email of your developer account |
79+
| `NOTARY_PASSWORD` | An app-specific password for it, from [account.apple.com](https://account.apple.com) |
80+
| `NOTARY_TEAM_ID` | Your 10-character Team ID, from the Apple Developer website |
81+
6382
## Privacy
6483

6584
World Clocks has no accounts, analytics or tracking. It contacts two [Open-Meteo](https://open-meteo.com) services:

‎build.sh‎

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,19 @@
44
# ./build.sh build the app
55
# ./build.sh --install build, copy to /Applications and (re)launch it
66
# ./build.sh --test run the unit tests
7+
#
8+
# Optional settings (the release workflow uses them):
9+
# ARCHS="arm64 x86_64" architectures to build; more than one makes a universal app (default: this Mac's)
10+
# VERSION=1.0.7 version shown in Finder (default: the one in Resources/Info.plist)
11+
# BUILD_NUMBER=7 build number (default: the one in Resources/Info.plist)
12+
# SIGN_IDENTITY="Developer ID Application: …" sign for distribution (default: ad-hoc, for this Mac only)
713
set -euo pipefail
814
cd "$(dirname "$0")"
915

1016
DEVELOPER_DIR="$(xcode-select -p)"
11-
SWIFT_FLAGS=(-swift-version 5 -parse-as-library -target "$(uname -m)-apple-macos26.0")
17+
ARCHS="${ARCHS:-$(uname -m)}"
18+
SIGN_IDENTITY="${SIGN_IDENTITY:--}"
19+
SWIFT_FLAGS=(-swift-version 5 -parse-as-library)
1220
SOURCES=()
1321
while IFS= read -r file; do SOURCES+=("$file"); done < <(find Sources/WorldClocks -name '*.swift' | sort)
1422

@@ -34,7 +42,15 @@ APP="build/World Clocks.app"
3442
rm -rf "$APP"
3543
mkdir -p "$APP/Contents/MacOS" "$APP/Contents/Resources"
3644

37-
swiftc -O "${SWIFT_FLAGS[@]}" -module-name WorldClocks -o "$APP/Contents/MacOS/WorldClocks" "${SOURCES[@]}"
45+
# One compile per architecture, then lipo them into a single (universal) executable.
46+
slices=()
47+
for arch in $ARCHS; do
48+
swiftc -O "${SWIFT_FLAGS[@]}" -target "$arch-apple-macos26.0" -module-name WorldClocks \
49+
-o "build/WorldClocks-$arch" "${SOURCES[@]}"
50+
slices+=("build/WorldClocks-$arch")
51+
done
52+
lipo -create -output "$APP/Contents/MacOS/WorldClocks" "${slices[@]}"
53+
rm -f "${slices[@]}"
3854

3955
# The icon is drawn by a small Swift script, again whenever the script changes.
4056
if [ ! -f build/AppIcon.icns ] || [ Resources/make_icon.swift -nt build/AppIcon.icns ]; then
@@ -46,8 +62,20 @@ fi
4662

4763
cp Resources/Info.plist "$APP/Contents/"
4864
cp build/AppIcon.icns "$APP/Contents/Resources/"
49-
codesign --force --sign - "$APP" # ad-hoc signature: enough to run on the Mac that built it
50-
echo "Built $APP"
65+
if [ -n "${VERSION:-}" ]; then
66+
/usr/libexec/PlistBuddy -c "Set :CFBundleShortVersionString $VERSION" "$APP/Contents/Info.plist"
67+
fi
68+
if [ -n "${BUILD_NUMBER:-}" ]; then
69+
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion $BUILD_NUMBER" "$APP/Contents/Info.plist"
70+
fi
71+
72+
if [ "$SIGN_IDENTITY" = "-" ]; then
73+
codesign --force --sign - "$APP" # ad-hoc: enough to run on the Mac that built it
74+
else
75+
# Hardened runtime and a secure timestamp are what notarization requires.
76+
codesign --force --options runtime --timestamp --sign "$SIGN_IDENTITY" "$APP"
77+
fi
78+
echo "Built $APP ($(lipo -archs "$APP/Contents/MacOS/WorldClocks"))"
5179

5280
if [ "${1:-}" = "--install" ]; then
5381
pkill -x WorldClocks && sleep 1 || true

‎scripts/make-dmg.sh‎

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/bin/bash
2+
# Packs an app into a drag-to-install disk image: the app next to a shortcut to /Applications.
3+
#
4+
# scripts/make-dmg.sh "build/World Clocks.app" build/WorldClocks.dmg
5+
#
6+
# With SIGN_IDENTITY set (a Developer ID Application identity), the disk image is signed too.
7+
set -euo pipefail
8+
9+
APP="$1"
10+
DMG="$2"
11+
NAME="$(basename "$APP" .app)"
12+
13+
staging="$(mktemp -d)"
14+
trap 'rm -rf "$staging"' EXIT
15+
cp -R "$APP" "$staging/"
16+
ln -s /Applications "$staging/Applications"
17+
18+
rm -f "$DMG"
19+
hdiutil create -volname "$NAME" -srcfolder "$staging" -fs HFS+ -format UDZO -imagekey zlib-level=9 -ov "$DMG" >/dev/null
20+
21+
if [ -n "${SIGN_IDENTITY:-}" ] && [ "$SIGN_IDENTITY" != "-" ]; then
22+
codesign --force --timestamp --sign "$SIGN_IDENTITY" "$DMG"
23+
fi
24+
echo "Made $DMG"

0 commit comments

Comments
 (0)