fix(build): move mac tool signing to beforeSign (#86)

* fix(build): move tool signing to beforeSign

* ci(macos): verify signing and notarization

* fix(build): move signing hook to afterPack
This commit is contained in:
Nexmoe
2026-01-12 21:53:39 +08:00
committed by GitHub
parent ac183b4e3c
commit 66f2211d68
3 changed files with 38 additions and 5 deletions

View File

@@ -149,6 +149,7 @@ jobs:
APPLE_API_ISSUER: ${{ secrets.APPLE_API_ISSUER }} APPLE_API_ISSUER: ${{ secrets.APPLE_API_ISSUER }}
run: | run: |
set -euo pipefail set -euo pipefail
echo "SIGNING_AVAILABLE=false" >> "$GITHUB_ENV"
# Check if all required secrets are present # Check if all required secrets are present
if [[ -z "$MAC_CERT_P12_BASE64" ]] || [[ -z "$MAC_CERT_P12_PASSWORD" ]] || \ if [[ -z "$MAC_CERT_P12_BASE64" ]] || [[ -z "$MAC_CERT_P12_PASSWORD" ]] || \
@@ -177,10 +178,42 @@ jobs:
echo "APPLE_API_KEY=$API_KEY_PATH" >> "$GITHUB_ENV" echo "APPLE_API_KEY=$API_KEY_PATH" >> "$GITHUB_ENV"
echo "APPLE_API_KEY_ID=$APPLE_API_KEY_ID" >> "$GITHUB_ENV" echo "APPLE_API_KEY_ID=$APPLE_API_KEY_ID" >> "$GITHUB_ENV"
echo "APPLE_API_ISSUER=$APPLE_API_ISSUER" >> "$GITHUB_ENV" echo "APPLE_API_ISSUER=$APPLE_API_ISSUER" >> "$GITHUB_ENV"
echo "SIGNING_AVAILABLE=true" >> "$GITHUB_ENV"
- name: Build application - name: Build application
run: ${{ matrix.build_script }} run: ${{ matrix.build_script }}
- name: Verify macOS codesign and notarization
if: matrix.platform == 'macos' && env.SIGNING_AVAILABLE == 'true'
shell: bash
run: |
set -euo pipefail
apps_found=0
while IFS= read -r app; do
apps_found=1
echo "Verifying codesign for $app"
codesign --verify --deep --strict --verbose=2 "$app"
spctl -a -t exec -vv "$app"
echo "Validating notarization ticket for $app"
xcrun stapler validate "$app"
done < <(find dist -type d -name "*.app" -prune -print)
if [[ "$apps_found" -eq 0 ]]; then
echo "::error::No .app bundles found in dist"
exit 1
fi
dmgs_found=0
while IFS= read -r dmg; do
dmgs_found=1
echo "Validating notarization ticket for $dmg"
xcrun stapler validate "$dmg"
done < <(find dist -type f -name "*.dmg" -print)
if [[ "$dmgs_found" -eq 0 ]]; then
echo "::notice::No DMG artifacts found to validate"
fi
- name: Upload build artifacts - name: Upload build artifacts
if: inputs.upload_artifacts == true if: inputs.upload_artifacts == true
uses: actions/upload-artifact@v4 uses: actions/upload-artifact@v4

View File

@@ -25,14 +25,14 @@ const signBinary = (targetPath, entitlementsPath) => {
execFileSync('codesign', args, { stdio: 'inherit' }) execFileSync('codesign', args, { stdio: 'inherit' })
} }
exports.default = async function afterSign(context) { exports.default = async function afterPack(context) {
if (context.electronPlatformName !== 'darwin') { if (context.electronPlatformName !== 'darwin') {
return return
} }
const appBundle = findAppBundle(context.appOutDir) const appBundle = findAppBundle(context.appOutDir)
if (!appBundle) { if (!appBundle) {
console.warn('afterSign: No .app bundle found, skipping yt-dlp signing.') console.warn('afterPack: No .app bundle found, skipping tool signing.')
return return
} }
@@ -49,10 +49,10 @@ exports.default = async function afterSign(context) {
for (const binary of BINARIES) { for (const binary of BINARIES) {
const targetPath = path.join(resourcesPath, binary) const targetPath = path.join(resourcesPath, binary)
if (!fs.existsSync(targetPath)) { if (!fs.existsSync(targetPath)) {
console.warn(`afterSign: Missing ${binary}, skipping.`) console.warn(`afterPack: Missing ${binary}, skipping.`)
continue continue
} }
console.log(`afterSign: Signing ${binary} with entitlements.`) console.log(`afterPack: Signing ${binary} with entitlements.`)
signBinary(targetPath, entitlementsPath) signBinary(targetPath, entitlementsPath)
} }
} }

View File

@@ -2,7 +2,7 @@ appId: com.vidbee
productName: VidBee productName: VidBee
directories: directories:
buildResources: build buildResources: build
afterSign: build/after-sign.cjs afterPack: build/after-pack.cjs
protocols: protocols:
- name: VidBee - name: VidBee
schemes: schemes: