Skip to content

Commit 5d1cb7a

Browse files
committed
perf: using cert to sign
1 parent c88d035 commit 5d1cb7a

1 file changed

Lines changed: 26 additions & 5 deletions

File tree

.github/workflows/build.yml

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -154,24 +154,44 @@ jobs:
154154
# List all code signing identities
155155
security find-identity -v -p codesigning build.keychain
156156
157-
# Try to find Apple Distribution certificate first (for DMG signing)
158-
CERT_INFO=$(security find-identity -v -p codesigning build.keychain | grep -E "Apple Distribution|Apple Development" | head -n 1)
157+
# Try to find valid code signing certificate (Developer ID, Apple Distribution, or Apple Development)
158+
# Priority: Developer ID Application > Apple Distribution > Apple Development
159+
CERT_INFO=$(security find-identity -v -p codesigning build.keychain | grep -E "Developer ID Application|Apple Distribution|Apple Development" | head -n 1)
159160
160161
if [ -z "$CERT_INFO" ]; then
161-
echo "Error: No Apple certificate found in keychain"
162+
echo "Error: No valid Apple certificate found in keychain"
163+
echo "Available certificates:"
162164
security find-identity -v -p codesigning build.keychain
163165
exit 1
164166
fi
165167
166-
CERT_ID=$(echo "$CERT_INFO" | awk -F'"' '{print $2}')
168+
CERT_ID=$(echo "$CERT_INFO" | awk '{print $2}')
167169
168170
if [ -z "$CERT_ID" ]; then
169-
echo "Error: Failed to extract certificate ID"
171+
echo "Error: Failed to extract certificate ID from: $CERT_INFO"
170172
exit 1
171173
fi
172174
175+
# Extract Team ID from certificate name (format: "Developer ID Application: Name (TEAM_ID)")
176+
# Use sed to extract content between parentheses
177+
TEAM_ID=$(echo "$CERT_INFO" | sed -n 's/.*(\([A-Z0-9]*\)).*/\1/p' | head -n 1)
178+
179+
if [ -z "$TEAM_ID" ]; then
180+
echo "Warning: Failed to extract Team ID from certificate name, trying alternative method"
181+
# Alternative: try to get from certificate directly using openssl
182+
CERT_SUBJECT=$(security find-certificate -c "$CERT_ID" -p build.keychain 2>/dev/null | openssl x509 -noout -subject 2>/dev/null || echo "")
183+
if [ -n "$CERT_SUBJECT" ]; then
184+
TEAM_ID=$(echo "$CERT_SUBJECT" | sed -n 's/.*OU=\([^/]*\).*/\1/p' | head -n 1)
185+
fi
186+
fi
187+
173188
echo "CERT_ID=$CERT_ID" >> $GITHUB_ENV
189+
if [ -n "$TEAM_ID" ]; then
190+
echo "APPLE_TEAM_ID=$TEAM_ID" >> $GITHUB_ENV
191+
echo "Team ID: $TEAM_ID"
192+
fi
174193
echo "Certificate ID: $CERT_ID"
194+
echo "Certificate info: $CERT_INFO"
175195
echo "Certificate imported and verified."
176196
177197
- name: Install Go client for current platform
@@ -215,6 +235,7 @@ jobs:
215235
APPLE_CERTIFICATE: ${{ secrets.APPLE_CERTIFICATE }}
216236
APPLE_CERTIFICATE_PASSWORD: ${{ secrets.APPLE_CERTIFICATE_PASSWORD }}
217237
APPLE_SIGNING_IDENTITY: ${{ env.CERT_ID }}
238+
APPLE_TEAM_ID: ${{ env.APPLE_TEAM_ID }}
218239

219240
with:
220241
tagName: ${{ env.VERSION }}

0 commit comments

Comments
 (0)