Skip to content

Commit 8ff77ff

Browse files
authored
feat: macOS release ci (#84)
1 parent 8eb7281 commit 8ff77ff

File tree

2 files changed

+124
-9
lines changed

2 files changed

+124
-9
lines changed

.github/workflows/macos.yml

Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
name: macos
2+
3+
on:
4+
push:
5+
tags:
6+
- '*'
7+
8+
permissions:
9+
contents: write
10+
11+
jobs:
12+
build:
13+
runs-on: macos-latest
14+
steps:
15+
- name: Checkout
16+
uses: actions/checkout@v4
17+
18+
- name: Install Rust
19+
uses: dsherret/rust-toolchain-file@v1
20+
21+
- name: Rust Cache
22+
uses: Swatinem/rust-cache@v2
23+
with:
24+
cache-all-crates: true
25+
cache-on-failure: true
26+
27+
- name: Install x86_64-apple-darwin
28+
run: rustup target add x86_64-apple-darwin
29+
30+
- name: Build macOS Rust
31+
run: ./scripts/macos_rust_build.sh
32+
33+
- name: Build Dosei.app
34+
run: |
35+
cd macos
36+
37+
sudo xcode-select -s /Applications/Xcode_16.2.app
38+
xcodebuild -target Dosei -configuration Release CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO
39+
40+
41+
- name: macOS Codesign
42+
env:
43+
MACOS_CERTIFICATE: ${{ secrets.MACOS_CERTIFICATE }}
44+
MACOS_CERTIFICATE_PWD: ${{ secrets.MACOS_CERTIFICATE_PWD }}
45+
MACOS_CERTIFICATE_NAME: ${{ vars.MACOS_CERTIFICATE_NAME }}
46+
MACOS_CI_KEYCHAIN_PWD: ${{ secrets.MACOS_CI_KEYCHAIN_PWD }}
47+
run: |
48+
# Turn our base64-encoded certificate back to a regular .p12 file
49+
echo $MACOS_CERTIFICATE | base64 --decode > certificate.p12
50+
51+
# Create keychain, default it and unlock
52+
security create-keychain -p "$MACOS_CI_KEYCHAIN_PWD" build.keychain
53+
security default-keychain -s build.keychain
54+
security unlock-keychain -p "$MACOS_CI_KEYCHAIN_PWD" build.keychain
55+
56+
# Import certificate
57+
security import certificate.p12 -k build.keychain -P "$MACOS_CERTIFICATE_PWD" -T /usr/bin/codesign
58+
59+
# Set partition list
60+
security set-key-partition-list -S apple-tool:,apple:,codesign: -s -k "$MACOS_CI_KEYCHAIN_PWD" build.keychain
61+
62+
RESOURCES_PATH="macos/Dosei/Contents/Resources"
63+
64+
APP_PATH="macos/build/Release/Dosei.app"
65+
RESOURCES_PATH="$APP_PATH/Contents/Resources"
66+
MACOS_PATH="$APP_PATH/Contents/MacOS"
67+
68+
# Sign all binaries with hardened runtime and timestamp
69+
echo "Signing individual binaries..."
70+
/usr/bin/codesign --verbose -f -s "$MACOS_CERTIFICATE_NAME" -o runtime --timestamp "$RESOURCES_PATH/dosei"
71+
/usr/bin/codesign --verbose -f -s "$MACOS_CERTIFICATE_NAME" -o runtime --timestamp "$RESOURCES_PATH/macos-rust"
72+
/usr/bin/codesign --verbose -f -s "$MACOS_CERTIFICATE_NAME" -o runtime --timestamp "$MACOS_PATH/Dosei"
73+
74+
# Sign the entire App Bundle last
75+
echo "Signing app bundle..."
76+
/usr/bin/codesign --verbose -f -s "$MACOS_CERTIFICATE_NAME" -o runtime --timestamp --entitlements "macos/Dosei/Dosei.entitlements" "$APP_PATH"
77+
78+
- name: Create DMG
79+
env:
80+
MACOS_CERTIFICATE_NAME: ${{ vars.MACOS_CERTIFICATE_NAME }}
81+
run: |
82+
npm install --global create-dmg
83+
create-dmg \
84+
--identity="$MACOS_CERTIFICATE_NAME" \
85+
./macos/build/Release/Dosei.app \
86+
./
87+
mv ./Dosei*.dmg ./Dosei.dmg
88+
89+
- name: Notarize app bundle
90+
env:
91+
MACOS_NOTARIZATION_APPLE_ID: ${{ secrets.MACOS_NOTARIZATION_APPLE_ID }}
92+
MACOS_NOTARIZATION_TEAM_ID: ${{ secrets.MACOS_NOTARIZATION_TEAM_ID }}
93+
MACOS_NOTARIZATION_PWD: ${{ secrets.MACOS_NOTARIZATION_PWD }}
94+
run: |
95+
xcrun notarytool store-credentials "notarytool-profile" --apple-id "$MACOS_NOTARIZATION_APPLE_ID" --team-id "$MACOS_NOTARIZATION_TEAM_ID" --password "$MACOS_NOTARIZATION_PWD"
96+
97+
xcrun notarytool submit "Dosei.dmg" --keychain-profile "notarytool-profile" --wait
98+
99+
xcrun stapler staple "Dosei.dmg"
100+
101+
102+
- name: Upload DMG
103+
uses: actions/upload-artifact@v4
104+
with:
105+
name: Dosei.dmg
106+
path: Dosei.dmg
107+
108+
release:
109+
name: Release
110+
runs-on: ubuntu-latest
111+
needs: [build]
112+
steps:
113+
- uses: actions/download-artifact@v4
114+
with:
115+
pattern: Dosei.dmg
116+
merge-multiple: true
117+
- name: Release
118+
uses: softprops/action-gh-release@v2
119+
with:
120+
files: |
121+
Dosei.dmg

scripts/macos_rust_build.sh

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ set -e
33

44
RESOURCES_PATH="macos/Dosei/Contents/Resources"
55

6-
mkdir -p "$RESOURCES_PATH/bin"
6+
mkdir -p "$RESOURCES_PATH"
77

88
echo "Building for Apple Silicon (aarch64)..."
99
cargo build --bin macos-rust --release --target aarch64-apple-darwin
@@ -21,15 +21,9 @@ lipo -create \
2121
lipo -create \
2222
"target/aarch64-apple-darwin/release/dosei" \
2323
"target/x86_64-apple-darwin/release/dosei" \
24-
-output "$RESOURCES_PATH/bin/dosei"
24+
-output "$RESOURCES_PATH/dosei"
2525

2626
chmod +x "$RESOURCES_PATH/macos-rust"
27-
chmod +x "$RESOURCES_PATH/bin/dosei"
27+
chmod +x "$RESOURCES_PATH/dosei"
2828

2929
cp ./scripts/post_install.sh "$RESOURCES_PATH/post_install.sh"
30-
31-
codesign --force --options runtime --sign "Apple Development: Alvaro Molina (BHFW3S86WS)" "$RESOURCES_PATH/macos-rust"
32-
echo "Universal binary created successfully at $RESOURCES_PATH/macos-rust"
33-
34-
codesign --force --options runtime --sign "Apple Development: Alvaro Molina (BHFW3S86WS)" "$RESOURCES_PATH/bin/dosei"
35-
echo "Universal binary created successfully at $RESOURCES_PATH/bin/dosei"

0 commit comments

Comments
 (0)