|
| 1 | +name: Notarize the app (macOS) |
| 2 | + |
| 3 | +inputs: |
| 4 | + APPLE_ID: |
| 5 | + required: true |
| 6 | + APPLE_PW: |
| 7 | + required: true |
| 8 | + DEV_ID: |
| 9 | + required: true |
| 10 | + GH_TOKEN: |
| 11 | + required: true |
| 12 | + KEYCHAIN_PATH: |
| 13 | + required: true |
| 14 | + KEYCHAIN_PW: |
| 15 | + required: true |
| 16 | + NIGHTLY: |
| 17 | + required: true |
| 18 | + SQLCIPHER: |
| 19 | + required: true |
| 20 | + TEAM_ID: |
| 21 | + required: true |
| 22 | + |
| 23 | +runs: |
| 24 | + using: "composite" |
| 25 | + |
| 26 | + steps: |
| 27 | + - name: Unlock keychain |
| 28 | + shell: bash |
| 29 | + run: | |
| 30 | + security unlock-keychain -p "${{ inputs.KEYCHAIN_PW }}" "${{ inputs.KEYCHAIN_PATH}}" |
| 31 | + security list-keychain -d user -s "${{ inputs.KEYCHAIN_PATH }}" |
| 32 | +
|
| 33 | + - name: Include the dependencies in the app bundle |
| 34 | + shell: bash |
| 35 | + run: find build -name "DB Browser for SQL*.app" -exec /opt/homebrew/opt/db4subqt@5/bin/macdeployqt {} -sign-for-notarization="${{ inputs.DEV_ID }}" \; |
| 36 | + |
| 37 | + - name: Add the 'nalgeon/sqlean' extension to the app bundle |
| 38 | + shell: bash |
| 39 | + run: | |
| 40 | + gh auth login --with-token <<< "${{ inputs.GH_TOKEN }}" |
| 41 | + gh release download --pattern "sqlean-macos-arm64.zip" --repo "nalgeon/sqlean" |
| 42 | + unzip sqlean-macos-arm64.zip |
| 43 | + for TARGET in $(find build -name "DB Browser for SQL*.app" | sed -e 's/ /_/g'); do |
| 44 | + TARGET=$(echo $TARGET | sed -e 's/_/ /g') |
| 45 | + mkdir "$TARGET/Contents/Extensions" |
| 46 | +
|
| 47 | + clang -I /opt/homebrew/opt/db4subsqlitefts@5/include -L /opt/homebrew/opt/db4subsqlitefts@5/lib -fno-common -dynamiclib src/extensions/extension-formats.c -o "$TARGET/Contents/Extensions/formats.dylib" |
| 48 | + if [ -f "$TARGET/Contents/Extensions/formats.dylib" ]; then |
| 49 | + install_name_tool -id "@executable_path/../Extensions/formats.dylib" "$TARGET/Contents/Extensions/formats.dylib" |
| 50 | + ln -s formats.dylib "$TARGET/Contents/Extensions/formats.dylib.dylib" |
| 51 | + fi |
| 52 | +
|
| 53 | + cp sqlean.dylib "$TARGET/Contents/Extensions/" |
| 54 | + if [ -f "$TARGET/Contents/Extensions/sqlean.dylib" ]; then |
| 55 | + install_name_tool -id "@executable_path/../Extensions/sqlean.dylib" "$TARGET/Contents/Extensions/sqlean.dylib" |
| 56 | + ln -s sqlean.dylib "$TARGET/Contents/Extensions/sqlean.dylib.dylib" |
| 57 | + fi |
| 58 | + done |
| 59 | +
|
| 60 | + - name: Copy the license file to the app bundle |
| 61 | + shell: bash |
| 62 | + run: | |
| 63 | + for TARGET in $(find build -name "DB Browser for SQL*.app" | sed -e 's/ /_/g'); do |
| 64 | + TARGET=$(echo $TARGET | sed -e 's/_/ /g') |
| 65 | + cp LICENSE "$TARGET/Contents/Resources/" |
| 66 | + cp LICENSE-EXTENSIONS "$TARGET/Contents/Resources/" |
| 67 | + cp LICENSE-PLUGINS "$TARGET/Contents/Resources/" |
| 68 | + done |
| 69 | +
|
| 70 | + - name: Copy the translation files to the app bundle |
| 71 | + shell: bash |
| 72 | + run: | |
| 73 | + for TARGET in $(find build -name "DB Browser for SQL*.app" | sed -e 's/ /_/g'); do |
| 74 | + TARGET=$(echo $TARGET | sed -e 's/_/ /g') |
| 75 | + mkdir "$TARGET/Contents/translations" |
| 76 | + for i in ar cs de en es fr it ko pl pt pt_BR ru uk zh_CN zh_TW; do |
| 77 | + find /opt/homebrew/opt/db4subqt@5/translations -name "qt_${i}.qm" 2> /dev/null -exec cp -v {} "$TARGET/Contents/translations/" \; |
| 78 | + find /opt/homebrew/opt/db4subqt@5/translations -name "qtbase_${i}.qm" 2> /dev/null -exec cp -v {} "$TARGET/Contents/translations/" \; |
| 79 | + find /opt/homebrew/opt/db4subqt@5/translations -name "qtmultimedia_${i}.qm" 2> /dev/null -exec cp -v {} "$TARGET/Contents/translations/" \; |
| 80 | + find /opt/homebrew/opt/db4subqt@5/translations -name "qtscript_${i}.qm" 2> /dev/null -exec cp -v {} "$TARGET/Contents/translations/" \; |
| 81 | + find /opt/homebrew/opt/db4subqt@5/translations -name "qtxmlpatterns_${i}.qm" 2> /dev/null -exec cp -v {} "$TARGET/Contents/translations/" \; |
| 82 | + done |
| 83 | + done |
| 84 | +
|
| 85 | + - name: Copy the icon file to the app bundle |
| 86 | + shell: bash |
| 87 | + run: | |
| 88 | + for TARGET in $(find build -name "DB Browser for SQL*.app" | sed -e 's/ /_/g'); do |
| 89 | + TARGET=$(echo $TARGET | sed -e 's/_/ /g') |
| 90 | + if [ "${{ inputs.NIGHTLY }}" = "false" ]; then |
| 91 | + cp installer/macos/macapp.icns "$TARGET/Contents/Resources/" |
| 92 | + /usr/libexec/PlistBuddy -c "Set :CFBundleIconFile macapp.icns" "$TARGET/Contents/Info.plist" |
| 93 | + else |
| 94 | + cp installer/macos/macapp-nightly.icns "$TARGET/Contents/Resources/" |
| 95 | + /usr/libexec/PlistBuddy -c "Set :CFBundleIconFile macapp-nightly.icns" "$TARGET/Contents/Info.plist" |
| 96 | + fi |
| 97 | + done |
| 98 | +
|
| 99 | + - name: Sign the manually added extensions. |
| 100 | + shell: bash |
| 101 | + run: | |
| 102 | + for TARGET in $(find build -name "DB Browser for SQL*.app" | sed -e 's/ /_/g'); do |
| 103 | + TARGET=$(echo $TARGET | sed -e 's/_/ /g') |
| 104 | + codesign --sign "${{ inputs.DEV_ID }}" --deep --force --options=runtime --strict --timestamp "$TARGET/Contents/Extensions/formats.dylib" |
| 105 | + codesign --sign "${{ inputs.DEV_ID }}" --deep --force --options=runtime --strict --timestamp "$TARGET/Contents/Extensions/sqlean.dylib" |
| 106 | + codesign --sign "${{ inputs.DEV_ID }}" --deep --force --options=runtime --strict --timestamp "$TARGET" |
| 107 | + done |
| 108 | +
|
| 109 | + - name: Move app bundle to installer folder for DMG creation |
| 110 | + shell: bash |
| 111 | + run: mv build/*.app installer/macos |
| 112 | + |
| 113 | + # TODO: I originally tried to break it into two steps to make it more readable, |
| 114 | + # but Composite Actions do not support if statements for steps. |
| 115 | + # For more information, see https://github.com/actions/runner/blob/main/docs/adrs/0549-composite-run-steps.md |
| 116 | + - name: Create the DMG |
| 117 | + shell: bash |
| 118 | + run: | |
| 119 | + export DATE=$(date +%Y%m%d) |
| 120 | +
|
| 121 | + if [ "${{ inputs.SQLCIPHER }}" = "1" ]; then |
| 122 | + if [ "${{ inputs.NIGHTLY }}" = "false" ]; then |
| 123 | + # Continuous with SQLCipher |
| 124 | + sed -i "" 's/"DB Browser for SQLCipher Nightly.app"/"DB Browser for SQLCipher-dev-'$(git rev-parse --short --verify HEAD)'.app"/' installer/macos/sqlcipher-nightly.json |
| 125 | + TARGET="DB.Browser.for.SQLCipher-dev-$(git rev-parse --short --verify HEAD).dmg" |
| 126 | + else |
| 127 | + # Nightly with SQLCipher |
| 128 | + TARGET="DB.Browser.for.SQLCipher-universal_$DATE.dmg" |
| 129 | + fi |
| 130 | + appdmg --quiet installer/macos/sqlcipher-nightly.json "$TARGET" |
| 131 | + else |
| 132 | + if [ "${{ inputs.NIGHTLY }}" = "false" ]; then |
| 133 | + # Continuous without SQLCipher |
| 134 | + sed -i "" 's/"DB Browser for SQLite Nightly.app"/"DB Browser for SQLite-dev-'$(git rev-parse --short --verify HEAD)'.app"/' installer/macos/nightly.json |
| 135 | + TARGET="DB.Browser.for.SQLite-dev-$(git rev-parse --short --verify HEAD).dmg" |
| 136 | + else |
| 137 | + # Nightly without SQLCipher |
| 138 | + TARGET="DB.Browser.for.SQLite-universal_$DATE.dmg" |
| 139 | + fi |
| 140 | + appdmg --quiet installer/macos/nightly.json "$TARGET" |
| 141 | + fi |
| 142 | +
|
| 143 | + codesign --sign "${{ inputs.DEV_ID }}" --verbose --options=runtime --timestamp "$TARGET" |
| 144 | + codesign -vvv --deep --strict --verbose=4 "$TARGET" |
| 145 | +
|
| 146 | + - name: Notarize the dmg |
| 147 | + shell: bash |
| 148 | + run: xcrun notarytool submit *.dmg --apple-id "${{ inputs.APPLE_ID }}" --password "${{ inputs.APPLE_PW }}" --team-id "${{ inputs.TEAM_ID }}" --wait |
| 149 | + |
| 150 | + - name: Staple the notarization ticket |
| 151 | + shell: bash |
| 152 | + run: xcrun stapler staple *.dmg |
0 commit comments