1+ name : Release
2+
3+ on :
4+ push :
5+ tags :
6+ - ' v*'
7+
8+ jobs :
9+ build-and-release :
10+ runs-on : macos-latest
11+
12+ permissions :
13+ contents : write
14+
15+ steps :
16+ - name : Checkout code
17+ uses : actions/checkout@v4
18+
19+ - name : Setup pnpm
20+ uses : pnpm/action-setup@v4
21+ with :
22+ version : 10.12.1
23+
24+ - name : Setup Node.js
25+ uses : actions/setup-node@v4
26+ with :
27+ node-version : ' 20'
28+ cache : ' pnpm'
29+
30+ - name : Install dependencies
31+ run : pnpm install --frozen-lockfile
32+
33+ - name : Build binaries
34+ run : pnpm build:binary
35+
36+ - name : Import signing certificate
37+ env :
38+ MACOS_CERTIFICATE : ${{ secrets.MACOS_CERTIFICATE }}
39+ MACOS_CERTIFICATE_PASSWORD : ${{ secrets.MACOS_CERTIFICATE_PASSWORD }}
40+ run : |
41+ # Create a temporary keychain
42+ KEYCHAIN_NAME="build.keychain"
43+ KEYCHAIN_PASSWORD="$(openssl rand -base64 32)"
44+
45+ # Create the keychain
46+ security create-keychain -p "$KEYCHAIN_PASSWORD" "$KEYCHAIN_NAME"
47+
48+ # Set the keychain as default
49+ security default-keychain -s "$KEYCHAIN_NAME"
50+
51+ # Unlock the keychain
52+ security unlock-keychain -p "$KEYCHAIN_PASSWORD" "$KEYCHAIN_NAME"
53+
54+ # Import certificate
55+ echo "$MACOS_CERTIFICATE" | base64 --decode > certificate.p12
56+ security import certificate.p12 -k "$KEYCHAIN_NAME" -P "$MACOS_CERTIFICATE_PASSWORD" -T /usr/bin/codesign
57+
58+ # Allow codesign to access the certificate without prompting
59+ security set-key-partition-list -S apple-tool:,apple: -s -k "$KEYCHAIN_PASSWORD" "$KEYCHAIN_NAME"
60+
61+ # Clean up
62+ rm certificate.p12
63+
64+ - name : Sign binaries
65+ env :
66+ DEVELOPER_ID : ${{ secrets.DEVELOPER_ID }}
67+ BUNDLE_ID : ${{ secrets.BUNDLE_ID }}
68+ run : |
69+ # Make binaries executable
70+ chmod +x bin/hello-lightdash-x64
71+ chmod +x bin/hello-lightdash-arm64
72+
73+ # Sign both binaries
74+ codesign -s "$DEVELOPER_ID" -f --timestamp -o runtime \
75+ -i "$BUNDLE_ID" --entitlements entitlements.plist \
76+ bin/hello-lightdash-x64
77+
78+ codesign -s "$DEVELOPER_ID" -f --timestamp -o runtime \
79+ -i "$BUNDLE_ID" --entitlements entitlements.plist \
80+ bin/hello-lightdash-arm64
81+
82+ # Verify signatures
83+ codesign --verify --verbose bin/hello-lightdash-x64
84+ codesign --verify --verbose bin/hello-lightdash-arm64
85+
86+ - name : Notarize binaries
87+ env :
88+ APPLE_ID : ${{ secrets.APPLE_ID }}
89+ APPLE_PASSWORD : ${{ secrets.APPLE_PASSWORD }}
90+ APPLE_TEAM_ID : ${{ secrets.APPLE_TEAM_ID }}
91+ run : |
92+ # Store notarization credentials
93+ xcrun notarytool store-credentials "CI_NOTARIZE" \
94+ --apple-id "$APPLE_ID" \
95+ --team-id "$APPLE_TEAM_ID" \
96+ --password "$APPLE_PASSWORD"
97+
98+ # Create temporary directory for zips
99+ mkdir -p notarize-temp
100+
101+ # Function to notarize a binary
102+ notarize_binary() {
103+ local BINARY_NAME=$1
104+ local ZIP_PATH="notarize-temp/${BINARY_NAME}.zip"
105+
106+ echo "Notarizing ${BINARY_NAME}..."
107+
108+ # Create zip for notarization
109+ ditto -c -k --keepParent "bin/${BINARY_NAME}" "$ZIP_PATH"
110+
111+ # Submit for notarization and wait
112+ xcrun notarytool submit "$ZIP_PATH" \
113+ --keychain-profile "CI_NOTARIZE" \
114+ --wait
115+
116+ # Check status
117+ if [ $? -eq 0 ]; then
118+ echo "✓ Notarization successful for ${BINARY_NAME}"
119+ else
120+ echo "✗ Notarization failed for ${BINARY_NAME}"
121+ exit 1
122+ fi
123+ }
124+
125+ # Notarize both binaries
126+ notarize_binary "hello-lightdash-x64"
127+ notarize_binary "hello-lightdash-arm64"
128+
129+ # Clean up
130+ rm -rf notarize-temp
131+
132+ - name : Create release archives
133+ run : |
134+ # Get version from tag
135+ VERSION=${GITHUB_REF#refs/tags/}
136+
137+ # Create archives for each architecture
138+ tar -czf "hello-lightdash-${VERSION}-macos-x64.tar.gz" -C bin hello-lightdash-x64
139+ tar -czf "hello-lightdash-${VERSION}-macos-arm64.tar.gz" -C bin hello-lightdash-arm64
140+
141+ # Create checksums
142+ shasum -a 256 hello-lightdash-*.tar.gz > checksums.txt
143+
144+ - name : Create GitHub Release
145+ uses : softprops/action-gh-release@v2
146+ with :
147+ draft : false
148+ prerelease : false
149+ generate_release_notes : true
150+ files : |
151+ hello-lightdash-*.tar.gz
152+ checksums.txt
153+ body : |
154+ ## Downloads
155+
156+ ### macOS
157+ - **Apple Silicon (M1/M2/M3):** `hello-lightdash-${{ github.ref_name }}-macos-arm64.tar.gz`
158+ - **Intel:** `hello-lightdash-${{ github.ref_name }}-macos-x64.tar.gz`
159+
160+ ### Installation
161+
162+ ```bash
163+ # Download and extract (replace with your architecture)
164+ tar -xzf hello-lightdash-${{ github.ref_name }}-macos-arm64.tar.gz
165+
166+ # Make executable (if needed)
167+ chmod +x hello-lightdash-arm64
168+
169+ # Run
170+ ./hello-lightdash-arm64
171+ ```
172+
173+ ### Verification
174+
175+ The binaries are signed and notarized by Apple. To verify:
176+ ```bash
177+ codesign --verify --verbose hello-lightdash-arm64
178+ ```
179+
180+ ### Checksums
181+
182+ Verify download integrity:
183+ ```bash
184+ shasum -a 256 -c checksums.txt
185+ ```
0 commit comments