File: notarize.sh

package info (click to toggle)
sqlitebrowser 3.13.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 23,472 kB
  • sloc: cpp: 117,707; ansic: 2,143; yacc: 798; lex: 262; sh: 126; xml: 65; python: 27; makefile: 5
file content (87 lines) | stat: -rw-r--r-- 4,648 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#!/usr/bin/env bash
# Create a new keychain
CERTIFICATE_PATH=$RUNNER_TEMP/build_certificate.p12
KEYCHAIN_PATH=$RUNNER_TEMP/app-signing.keychain-db
echo -n "$P12" | base64 --decode -o $CERTIFICATE_PATH
security create-keychain -p "$KEYCHAIN_PW" $KEYCHAIN_PATH
security set-keychain-settings -lut 21600 $KEYCHAIN_PATH
security unlock-keychain -p "$KEYCHAIN_PW" $KEYCHAIN_PATH
security import $CERTIFICATE_PATH -P "$P12_PW" -A -t cert -f pkcs12 -k $KEYCHAIN_PATH
security list-keychain -d user -s $KEYCHAIN_PATH

# Run macdeployqt
find build -name "DB Browser for SQL*.app" -exec $(brew --prefix sqlb-qt@5)/bin/macdeployqt {} -sign-for-notarization=$DEV_ID \;

# Add the 'formats' and 'nalgeon/sqlean' extensions to the app bundle
gh auth login --with-token <<< "$GH_TOKEN"
gh release download --pattern "sqlean-macos-x86.zip" --repo "nalgeon/sqlean"
unzip sqlean-macos-x86.zip -d sqlean-macos-x86
gh release download --pattern "sqlean-macos-arm64.zip" --repo "nalgeon/sqlean"
unzip sqlean-macos-arm64.zip -d sqlean-macos-arm64
lipo -create sqlean-macos-x86/sqlean.dylib sqlean-macos-arm64/sqlean.dylib -output sqlean.dylib
for TARGET in $(find build -name "DB Browser for SQL*.app" | sed -e 's/ /_/g'); do
    TARGET=$(echo $TARGET | sed -e 's/_/ /g')
    mkdir "$TARGET/Contents/Extensions"

    clang -I /opt/homebrew/opt/sqlb-sqlite/include -L /opt/homebrew/opt/sqlb-sqlite/lib -fno-common -dynamiclib src/extensions/extension-formats.c -o "$TARGET/Contents/Extensions/formats.dylib"
    if [ -f "$TARGET/Contents/Extensions/formats.dylib" ]; then
        install_name_tool -id "@executable_path/../Extensions/formats.dylib" "$TARGET/Contents/Extensions/formats.dylib"
        ln -s formats.dylib "$TARGET/Contents/Extensions/formats.dylib.dylib"
    fi

    cp sqlean.dylib "$TARGET/Contents/Extensions/"
    if [ -f "$TARGET/Contents/Extensions/sqlean.dylib" ]; then
        install_name_tool -id "@executable_path/../Extensions/sqlean.dylib" "$TARGET/Contents/Extensions/sqlean.dylib"
        ln -s sqlean.dylib "$TARGET/Contents/Extensions/sqlean.dylib.dylib"
    fi
done

# Copy the license file to the app bundle
for TARGET in $(find build -name "DB Browser for SQL*.app" | sed -e 's/ /_/g'); do
    TARGET=$(echo $TARGET | sed -e 's/_/ /g')
    cp LICENSE* "$TARGET/Contents/Resources/"
done

# Copy the translation files to the app bundle
for TARGET in $(find build -name "DB Browser for SQL*.app" | sed -e 's/ /_/g'); do
    TARGET=$(echo $TARGET | sed -e 's/_/ /g')
    mkdir "$TARGET/Contents/translations"
    for i in ar cs de en es fr it ko pl pt pt_BR ru uk zh_CN zh_TW; do
    find $(brew --prefix sqlb-qt@5)/translations -name "qt_${i}.qm" 2> /dev/null -exec cp {} "$TARGET/Contents/translations/" \;
    find $(brew --prefix sqlb-qt@5)/translations -name "qtbase_${i}.qm" 2> /dev/null -exec cp {} "$TARGET/Contents/translations/" \;
    find $(brew --prefix sqlb-qt@5)/translations -name "qtmultimedia_${i}.qm" 2> /dev/null -exec cp {} "$TARGET/Contents/translations/" \;
    find $(brew --prefix sqlb-qt@5)/translations -name "qtscript_${i}.qm" 2> /dev/null -exec cp {} "$TARGET/Contents/translations/" \;
    find $(brew --prefix sqlb-qt@5)/translations -name "qtxmlpatterns_${i}.qm" 2> /dev/null -exec cp {} "$TARGET/Contents/translations/" \;
    done 
done

# Copy the icon file to the app bundle
for TARGET in $(find build -name "DB Browser for SQL*.app" | sed -e 's/ /_/g'); do
    TARGET=$(echo $TARGET | sed -e 's/_/ /g')
    cp installer/macos/macapp.icns "$TARGET/Contents/Resources/"
    /usr/libexec/PlistBuddy -c "Set :CFBundleIconFile macapp.icns" "$TARGET/Contents/Info.plist"
done

# Sign the manually added extensions
for TARGET in $(find build -name "DB Browser for SQL*.app" | sed -e 's/ /_/g'); do
    TARGET=$(echo $TARGET | sed -e 's/_/ /g')
    codesign --sign "$DEV_ID" --deep --force --options=runtime --strict --timestamp "$TARGET/Contents/Extensions/formats.dylib"
    codesign --sign "$DEV_ID" --deep --force --options=runtime --strict --timestamp "$TARGET/Contents/Extensions/sqlean.dylib"
    codesign --sign "$DEV_ID" --deep --force --options=runtime --strict --timestamp "$TARGET"
done

# Move app bundle to installer folder for DMG creation
mv build/*.app installer/macos

# Create the DMG
TARGET="DB.Browser.for.SQLite-v3.13.1.dmg"
appdmg --quiet installer/macos/nightly.json "$TARGET"

codesign --sign "$DEV_ID" --verbose --options=runtime --timestamp "$TARGET"
codesign -vvv --deep --strict --verbose=4 "$TARGET"

# Notarize the dmg
xcrun notarytool submit *.dmg --apple-id $APPLE_ID --password $APPLE_PW --team-id $TEAM_ID --wait

# Staple the notarization ticket
xcrun stapler staple *.dmg