1- name : " publish"
1+ name : " build"
2+
3+ # Single workflow for both CI builds and releases so the two can't diverge.
4+ #
5+ # - `build` job runs on every push that ISN'T a release: build + test the
6+ # universal macOS app and upload the artifacts to the workflow run. Unsigned,
7+ # and runs with a read-only token (no signing secrets).
8+ # - `release` job runs ONLY on the `release` branch (created by `make release`):
9+ # it gets a `contents: write` token, imports the Apple Developer certificate,
10+ # notarizes, and creates a draft GitHub release.
11+ #
12+ # The two jobs are mutually exclusive (one runs per push) and share the same
13+ # setup steps so they stay in sync while keeping least-privilege separation.
214
315on :
416 push :
517
18+ # Least privilege by default; only the release job opts up to contents: write.
19+ permissions :
20+ contents : read
21+
622jobs :
723 build :
24+ if : github.ref != 'refs/heads/release'
25+ runs-on : macos-latest
26+ steps :
27+ - uses : actions/checkout@v6
28+ with :
29+ persist-credentials : false
30+
31+ - uses : oven-sh/setup-bun@v2
32+ with :
33+ bun-version : latest
34+
35+ - name : install Rust stable
36+ uses : dtolnay/rust-toolchain@stable
37+ with :
38+ targets : aarch64-apple-darwin,x86_64-apple-darwin
39+
40+ - name : Rust cache
41+ uses : swatinem/rust-cache@v2
42+ with :
43+ workspaces : " ./src-tauri -> target"
44+ cache-on-failure : true
45+
46+ - name : install frontend dependencies
47+ run : bun install --frozen-lockfile
48+
49+ - name : test cargo build
50+ run : cd src-tauri && cargo test
51+
52+ - name : build universal app (unsigned)
53+ uses : tauri-apps/tauri-action@v0.6.2
54+ env :
55+ # CI=false so tauri's DMG bundler renders the background image correctly
56+ # (CI=true causes hdiutil to skip the background/icon layout stage)
57+ # See: https://github.com/tauri-apps/tauri-action/issues/740
58+ CI : false
59+ with :
60+ args : --target universal-apple-darwin
61+ uploadWorkflowArtifacts : true
62+
63+ release :
64+ if : github.ref == 'refs/heads/release'
865 permissions :
966 contents : write
10-
1167 runs-on : macos-latest
1268 steps :
1369 - uses : actions/checkout@v6
70+ with :
71+ persist-credentials : false
1472
1573 - uses : oven-sh/setup-bun@v2
1674 with :
1977 - name : install Rust stable
2078 uses : dtolnay/rust-toolchain@stable
2179 with :
22- targets : aarch64-apple-darwin
80+ targets : aarch64-apple-darwin,x86_64-apple-darwin
2381
2482 - name : Rust cache
2583 uses : swatinem/rust-cache@v2
@@ -33,14 +91,56 @@ jobs:
3391 - name : test cargo build
3492 run : cd src-tauri && cargo test
3593
36- - uses : tauri-apps/tauri-action@v0
94+ - name : import Apple Developer Certificate
95+ # Prevents keychain from locking automatically for 3600 seconds.
3796 env :
97+ APPLE_CERTIFICATE : ${{ secrets.APPLE_CERTIFICATE }}
98+ APPLE_CERTIFICATE_PASSWORD : ${{ secrets.APPLE_CERTIFICATE_PASSWORD }}
99+ KEYCHAIN_PASSWORD : ${{ secrets.KEYCHAIN_PASSWORD }}
100+ run : |
101+ echo $APPLE_CERTIFICATE | base64 --decode > certificate.p12
102+ security create-keychain -p "$KEYCHAIN_PASSWORD" build.keychain
103+ security default-keychain -s build.keychain
104+ security unlock-keychain -p "$KEYCHAIN_PASSWORD" build.keychain
105+ security set-keychain-settings -t 3600 -u build.keychain
106+ security import certificate.p12 -k build.keychain -P "$APPLE_CERTIFICATE_PASSWORD" -T /usr/bin/codesign
107+ security set-key-partition-list -S apple-tool:,apple:,codesign: -s -k "$KEYCHAIN_PASSWORD" build.keychain
108+ security find-identity -v -p codesigning build.keychain
109+
110+ - name : verify certificate
111+ run : |
112+ CERT_INFO=$(security find-identity -v -p codesigning build.keychain | grep "Developer ID Application")
113+ CERT_ID=$(echo "$CERT_INFO" | awk -F'"' '{print $2}')
114+ echo "CERT_ID=$CERT_ID" >> $GITHUB_ENV
115+ echo "Certificate imported."
116+
117+ - name : build and publish a draft release
118+ uses : tauri-apps/tauri-action@v0.6.2
119+ env :
120+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
121+ APPLE_ID : ${{ secrets.APPLE_ID }}
122+ APPLE_ID_PASSWORD : ${{ secrets.APPLE_ID_PASSWORD }}
123+ APPLE_PASSWORD : ${{ secrets.APPLE_PASSWORD }}
124+ APPLE_TEAM_ID : ${{ secrets.APPLE_TEAM_ID }}
125+ APPLE_CERTIFICATE : ${{ secrets.APPLE_CERTIFICATE }}
126+ APPLE_CERTIFICATE_PASSWORD : ${{ secrets.APPLE_CERTIFICATE_PASSWORD }}
127+ APPLE_SIGNING_IDENTITY : ${{ env.CERT_ID }}
38128 TAURI_SIGNING_PRIVATE_KEY : ${{ secrets.TAURI_SIGNING_PRIVATE_KEY }}
39129 TAURI_SIGNING_PRIVATE_KEY_PASSWORD : ${{ secrets.TAURI_SIGNING_PRIVATE_KEY_PASSWORD }}
40130 # CI=false so tauri's DMG bundler renders the background image correctly
41131 # (CI=true causes hdiutil to skip the background/icon layout stage)
42132 # See: https://github.com/tauri-apps/tauri-action/issues/740
43133 CI : false
44134 with :
45- args : --target universal-apple-darwin
135+ tagName : app-v__VERSION__ # the action automatically replaces __VERSION__ with the app version.
136+ releaseName : " App v__VERSION__"
137+ releaseBody : |
138+ See the assets to download this version and install.
139+
140+ Use `Alic.Image.Compressor___VERSION___universal.dmg` for both Apple Silicon and Intel Macs.
141+
142+ [Changelog](https://github.com/blopker/alic/blob/main/CHANGELOG.md)
143+ releaseDraft : true
144+ prerelease : false
46145 uploadWorkflowArtifacts : true
146+ args : --target universal-apple-darwin
0 commit comments