|
| 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 |
0 commit comments