Skip to content

Commit

Permalink
Travis notarized build and deploy
Browse files Browse the repository at this point in the history
  • Loading branch information
mckenfra committed Feb 12, 2020
1 parent 0e65bc7 commit 7bb0d1e
Show file tree
Hide file tree
Showing 3 changed files with 103 additions and 8 deletions.
27 changes: 24 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,29 @@
language: objective-c
osx_image: xcode11.3
language: objective-c

branches:
only:
- master

before_script:
- ./scripts/add-key.sh
- scripts/add-key.sh

script:
- xcodebuild -project PostgreSQL.xcodeproj -scheme PostgreSQL -configuration Release -derivedDataPath ./build -archivePath ./build/Products/PostgreSQL.xcarchive
- xcodebuild -project PostgreSQL.xcodeproj -scheme PostgreSQL -configuration Release -derivedDataPath ./build OTHER_CODE_SIGN_FLAGS='--timestamp' build

before_deploy:
- export POSTGRES_PREFS_NAME="PostgresPrefs-${TRAVIS_TAG}"
- scripts/notarize.sh

deploy:
provider: releases
api_key: $GITHUB_TOKEN
email: info@macca.tech
file: build/${POSTGRES_PREFS_NAME}.dmg
skip_cleanup: true
overwrite: true
draft: true
on:
repo: MaccaTech/PostgresPrefs
branch: master
tags: true
22 changes: 17 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ Features include:
## Install Instructions

1. Download the latest release version [here](https://github.com/MaccaTech/PostgresPrefs/releases)
2. Once downloaded, unzip it and then either double-click the `PostgreSQL.prefPane` file, or drag it to System Preferences to install it.
2. Once downloaded, open the `.dmg` file by double-clicking it, and then either double-click the contained `PostgreSQL.prefPane` file, or drag it to System Preferences to install it.
3. When installing, you will be asked if you want to install it for this user only, or for all users. Choose this user only (either option is fine however).

![alt text](https://raw.github.com/mckenfra/postgresql-mac-preferences/master/PostgreSQL/Images/screenshot_install.png "Install Screen")
Expand Down Expand Up @@ -106,6 +106,18 @@ However, from version 2.1 onwards, Postgre Preferences automatically detects and
</tr>
</thead>
<tbody>
<tr>
<td>v2.5</td>
<td>12-Feb 2020</td>
<td>Bugfix release
<ul>
<li>Fix start/stop errors on Catalina</li>
<li>Improve detection of existing PostgreSQL installations</li>
<li>Support dark mode</li>
<li>Automate releases using Github & Travis</li>
</ul>
</td>
</tr>
<tr>
<td>v2.4.3</td>
<td>20-Jan 2020</td>
Expand Down Expand Up @@ -196,11 +208,11 @@ However, from version 2.1 onwards, Postgre Preferences automatically detects and
<td>Major release
<ul>
<li>Control multiple servers from a single window</li>
<li>Start servers at computer bootup (previously only at login)</li>
<li>Start servers at computer bootup (previously only at login)</li>
<li>Easily debug problems using default server logs</li>
<li>See running status of servers without entering a password</li>
<li>Starting/stopping still password-protected</li>
<li>More code is pure Objective-C, less reliance on shell scripts</li>
<li>See running status of servers without entering a password</li>
<li>Starting/stopping still password-protected</li>
<li>More code is pure Objective-C, less reliance on shell scripts</li>
</ul>
</td>
</tr>
Expand Down
62 changes: 62 additions & 0 deletions scripts/notarize.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
#!/usr/bin/env bash

DMG_DIR="./build/$POSTGRES_PREFS_NAME"
DMG="$DMG_DIR.dmg"

# Reset
rm -rf "$DMG_DIR"
rm -f "$DMG"

# Code sign
mkdir -p "$DMG_DIR"
cp -R ./build/Build/Products/Release/PostgreSQL.prefPane "$DMG_DIR"
echo
echo "Creating $DMG ..."
hdiutil create -srcfolder "$DMG_DIR" "$DMG"
codesign --sign "Developer ID Application: Macca Tech Ltd" "$DMG"

# Notarize
echo
echo "Notarizing $DMG ..."
response=`xcrun altool --notarize-app --primary-bundle-id "com.maccatech.PostgresPrefs" --username "info@maccatech.com" --password "$NOTARIZE_PASSWORD" --file "$DMG"`
echo $response

# Extract UUID
uuid=`echo "$response" | sed -nE 's/RequestUUID[[:space:]]*\=[[:space:]]*([[:alnum:]_]*)/\1/p'`
if [ -z "$uuid" ]; then
echo "ERROR: RequestUUID not found"
exit 1
fi

# Poll until finished
interval=20
((start_time=${SECONDS}))
((end_time=${SECONDS}+3600))

while ((${SECONDS} < ${end_time}))
do
elapsed=`printf '%0.1f\n' $(bc <<<"scale=1; (${SECONDS}-$start_time)/60")`
echo
echo "Checking $uuid ($elapsed minutes) ..."
if response=`xcrun altool -u "info@maccatech.com" -p "$NOTARIZE_PASSWORD" --notarization-info "$uuid"`; then
statusCode=`echo "$response" | sed -nE 's/.*Status[[:space:]]*Code[[:space:]]*\:[[:space:]]*([[:digit:]]+).*/\1/p'`
echo "$response" | grep -i "tatus"
if [ -n "$statusCode" ]; then
break
fi
else
break
fi
sleep ${interval}
done

if [[ statusCode -ne "0" ]]; then
echo "Notarization failed"
echo "$response"
exit 1
fi

# Print out notarization check
echo
echo "Checking $DMG ..."
spctl -a -t install --context context:primary-signature -v "$DMG"

0 comments on commit 7bb0d1e

Please sign in to comment.