-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
394 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
name: build | ||
|
||
on: | ||
pull_request: | ||
branches: [ main ] | ||
push: | ||
branches: [ main ] | ||
schedule: | ||
- cron: '0 9 * * *' | ||
workflow_dispatch: | ||
|
||
jobs: | ||
|
||
macos-build: | ||
|
||
runs-on: inseven-macos-14 | ||
|
||
steps: | ||
|
||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
with: | ||
submodules: recursive | ||
fetch-depth: 0 | ||
|
||
- name: Install dependencies | ||
run: scripts/install-dependencies.sh | ||
|
||
- name: Build and test | ||
env: | ||
APPLE_DISTRIBUTION_CERTIFICATE_BASE64: ${{ secrets.PERSONAL_APPLE_DISTRIBUTION_CERTIFICATE_BASE64 }} | ||
APPLE_DISTRIBUTION_CERTIFICATE_PASSWORD: ${{ secrets.PERSONAL_APPLE_DISTRIBUTION_CERTIFICATE_PASSWORD }} | ||
MACOS_DEVELOPER_INSTALLER_CERTIFICATE_BASE64: ${{ secrets.PERSONAL_MACOS_DEVELOPER_INSTALLER_CERTIFICATE_BASE64 }} | ||
MACOS_DEVELOPER_INSTALLER_CERTIFICATE_PASSWORD: ${{ secrets.PERSONAL_MACOS_DEVELOPER_INSTALLER_CERTIFICATE_PASSWORD }} | ||
|
||
APPLE_API_KEY_BASE64: ${{ secrets.PERSONAL_APPLE_API_KEY_BASE64 }} | ||
APPLE_API_KEY_ISSUER_ID: ${{ secrets.PERSONAL_APPLE_API_KEY_ISSUER_ID }} | ||
APPLE_API_KEY_ID: ${{ secrets.PERSONAL_APPLE_API_KEY_ID }} | ||
|
||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
RELEASE: ${{ github.ref == 'refs/heads/main' }} | ||
|
||
run: | | ||
scripts/build.sh | ||
- name: Archive the binary | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
path: build/build-*.zip | ||
if-no-files-found: error |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,3 +4,9 @@ | |
[submodule "interact"] | ||
path = interact | ||
url = [email protected]:inseven/interact.git | ||
[submodule "scripts/changes"] | ||
path = scripts/changes | ||
url = https://github.com/jbmorley/changes.git | ||
[submodule "scripts/build-tools"] | ||
path = scripts/build-tools | ||
url = https://github.com/jbmorley/build-tools.git |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
<plist version="1.0"> | ||
<dict> | ||
<key>destination</key> | ||
<string>export</string> | ||
<key>installerSigningCertificate</key> | ||
<string>C44BC9291462AE6729496E2CAC18CE475688F8CD</string> | ||
<key>manageAppVersionAndBuildNumber</key> | ||
<false/> | ||
<key>method</key> | ||
<string>app-store</string> | ||
<key>provisioningProfiles</key> | ||
<dict> | ||
<key>uk.co.jbmorley.thoughts.apps.appstore</key> | ||
<string>Thoughts Mac App Store Profile</string> | ||
</dict> | ||
<key>signingCertificate</key> | ||
<string>91DADFE184A1526FA94D4513D5B4C75E1DB3B252</string> | ||
<key>signingStyle</key> | ||
<string>manual</string> | ||
<key>teamID</key> | ||
<string>QS82QFHKWB</string> | ||
<key>uploadSymbols</key> | ||
<true/> | ||
</dict> | ||
</plist> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,5 +15,7 @@ | |
</array> | ||
</dict> | ||
</array> | ||
<key>ITSAppUsesNonExemptEncryption</key> | ||
<false/> | ||
</dict> | ||
</plist> |
Binary file not shown.
Submodule build-tools
added at
c0f02d
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,173 @@ | ||
#!/bin/bash | ||
|
||
# Copyright (c) 2024 Jason Morley | ||
# | ||
# Permission is hereby granted, free of charge, to any person obtaining a copy | ||
# of this software and associated documentation files (the "Software"), to deal | ||
# in the Software without restriction, including without limitation the rights | ||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
# copies of the Software, and to permit persons to whom the Software is | ||
# furnished to do so, subject to the following conditions: | ||
# | ||
# The above copyright notice and this permission notice shall be included in all | ||
# copies or substantial portions of the Software. | ||
# | ||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
# SOFTWARE. | ||
|
||
set -e | ||
set -o pipefail | ||
set -x | ||
set -u | ||
|
||
SCRIPTS_DIRECTORY="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" | ||
|
||
ROOT_DIRECTORY="${SCRIPTS_DIRECTORY}/.." | ||
BUILD_DIRECTORY="${ROOT_DIRECTORY}/build" | ||
TEMPORARY_DIRECTORY="${ROOT_DIRECTORY}/temp" | ||
|
||
KEYCHAIN_PATH="${TEMPORARY_DIRECTORY}/temporary.keychain" | ||
ARCHIVE_PATH="${BUILD_DIRECTORY}/Thoughts.xcarchive" | ||
ENV_PATH="${ROOT_DIRECTORY}/.env" | ||
|
||
RELEASE_SCRIPT_PATH="${SCRIPTS_DIRECTORY}/release.sh" | ||
|
||
IOS_XCODE_PATH=${IOS_XCODE_PATH:-/Applications/Xcode.app} | ||
MACOS_XCODE_PATH=${MACOS_XCODE_PATH:-/Applications/Xcode.app} | ||
|
||
source "${SCRIPTS_DIRECTORY}/environment.sh" | ||
|
||
# Check that the GitHub command is available on the path. | ||
which gh || (echo "GitHub cli (gh) not available on the path." && exit 1) | ||
|
||
# Process the command line arguments. | ||
POSITIONAL=() | ||
RELEASE=${RELEASE:-false} | ||
while [[ $# -gt 0 ]] | ||
do | ||
key="$1" | ||
case $key in | ||
-r|--release) | ||
RELEASE=true | ||
shift | ||
;; | ||
*) | ||
POSITIONAL+=("$1") | ||
shift | ||
;; | ||
esac | ||
done | ||
|
||
# Generate a random string to secure the local keychain. | ||
export TEMPORARY_KEYCHAIN_PASSWORD=`openssl rand -base64 14` | ||
|
||
# Source the .env file if it exists to make local development easier. | ||
if [ -f "$ENV_PATH" ] ; then | ||
echo "Sourcing .env..." | ||
source "$ENV_PATH" | ||
fi | ||
|
||
function xcode_project { | ||
xcodebuild \ | ||
-project Thoughts.xcodeproj "$@" | ||
} | ||
|
||
function build_scheme { | ||
# Disable code signing for the build server. | ||
xcode_project \ | ||
-scheme "$1" \ | ||
CODE_SIGN_IDENTITY="" \ | ||
CODE_SIGNING_REQUIRED=NO \ | ||
CODE_SIGNING_ALLOWED=NO "${@:2}" | ||
} | ||
|
||
cd "$ROOT_DIRECTORY" | ||
|
||
# Select the correct Xcode. | ||
sudo xcode-select --switch "$MACOS_XCODE_PATH" | ||
|
||
# List the available schemes. | ||
xcode_project -list | ||
|
||
# Clean up the build directory. | ||
if [ -d "$BUILD_DIRECTORY" ] ; then | ||
rm -r "$BUILD_DIRECTORY" | ||
fi | ||
mkdir -p "$BUILD_DIRECTORY" | ||
|
||
# Create the a new keychain. | ||
if [ -d "$TEMPORARY_DIRECTORY" ] ; then | ||
rm -rf "$TEMPORARY_DIRECTORY" | ||
fi | ||
mkdir -p "$TEMPORARY_DIRECTORY" | ||
echo "$TEMPORARY_KEYCHAIN_PASSWORD" | build-tools create-keychain "$KEYCHAIN_PATH" --password | ||
|
||
function cleanup { | ||
|
||
# Cleanup the temporary files, keychain and keys. | ||
cd "$ROOT_DIRECTORY" | ||
build-tools delete-keychain "$KEYCHAIN_PATH" | ||
rm -rf "$TEMPORARY_DIRECTORY" | ||
rm -rf ~/.appstoreconnect/private_keys | ||
} | ||
|
||
trap cleanup EXIT | ||
|
||
# Determine the version and build number. | ||
VERSION_NUMBER=`changes version` | ||
BUILD_NUMBER=`build-number.swift` | ||
|
||
# Import the certificates into our dedicated keychain. | ||
echo "$APPLE_DISTRIBUTION_CERTIFICATE_PASSWORD" | build-tools import-base64-certificate --password "$KEYCHAIN_PATH" "$APPLE_DISTRIBUTION_CERTIFICATE_BASE64" | ||
echo "$MACOS_DEVELOPER_INSTALLER_CERTIFICATE_PASSWORD" | build-tools import-base64-certificate --password "$KEYCHAIN_PATH" "$MACOS_DEVELOPER_INSTALLER_CERTIFICATE_BASE64" | ||
|
||
# Install the provisioning profiles. | ||
build-tools install-provisioning-profile "Thoughts_Mac_App_Store_Profile.provisionprofile" | ||
|
||
# Build and archive the macOS project. | ||
sudo xcode-select --switch "$MACOS_XCODE_PATH" | ||
xcode_project \ | ||
-scheme "Thoughts" \ | ||
-config Release \ | ||
-archivePath "$ARCHIVE_PATH" \ | ||
OTHER_CODE_SIGN_FLAGS="--keychain=\"${KEYCHAIN_PATH}\"" \ | ||
CURRENT_PROJECT_VERSION=$BUILD_NUMBER \ | ||
MARKETING_VERSION=$VERSION_NUMBER \ | ||
clean archive | ||
xcodebuild \ | ||
-archivePath "$ARCHIVE_PATH" \ | ||
-exportArchive \ | ||
-exportPath "$BUILD_DIRECTORY" \ | ||
-exportOptionsPlist "ExportOptions.plist" | ||
|
||
APP_BASENAME="Thoughts.app" | ||
APP_PATH="$BUILD_DIRECTORY/$APP_BASENAME" | ||
PKG_PATH="$BUILD_DIRECTORY/Thoughts.pkg" | ||
|
||
# Install the private key. | ||
mkdir -p ~/.appstoreconnect/private_keys/ | ||
echo -n "$APPLE_API_KEY_BASE64" | base64 --decode -o ~/".appstoreconnect/private_keys/AuthKey_${APPLE_API_KEY_ID}.p8" | ||
|
||
# Archive the build directory. | ||
ZIP_BASENAME="build-${VERSION_NUMBER}-${BUILD_NUMBER}.zip" | ||
ZIP_PATH="${BUILD_DIRECTORY}/${ZIP_BASENAME}" | ||
pushd "${BUILD_DIRECTORY}" | ||
zip -r "${ZIP_BASENAME}" . | ||
popd | ||
|
||
if $RELEASE ; then | ||
|
||
changes \ | ||
release \ | ||
--skip-if-empty \ | ||
--pre-release \ | ||
--push \ | ||
--exec "${RELEASE_SCRIPT_PATH}" \ | ||
"${PKG_PATH}" "${ZIP_PATH}" | ||
|
||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#!/bin/bash | ||
|
||
# Copyright (c) 2024 Jason Morley | ||
# | ||
# Permission is hereby granted, free of charge, to any person obtaining a copy | ||
# of this software and associated documentation files (the "Software"), to deal | ||
# in the Software without restriction, including without limitation the rights | ||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
# copies of the Software, and to permit persons to whom the Software is | ||
# furnished to do so, subject to the following conditions: | ||
# | ||
# The above copyright notice and this permission notice shall be included in all | ||
# copies or substantial portions of the Software. | ||
# | ||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
# SOFTWARE. | ||
|
||
SCRIPTS_DIRECTORY="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" | ||
ROOT_DIRECTORY="${SCRIPTS_DIRECTORY}/.." | ||
|
||
export PYTHONUSERBASE="${ROOT_DIRECTORY}/.local/python" | ||
mkdir -p "$PYTHONUSERBASE" | ||
export PATH="${PYTHONUSERBASE}/bin":$PATH | ||
|
||
export PATH=$PATH:"${SCRIPTS_DIRECTORY}/changes" | ||
export PATH=$PATH:"${SCRIPTS_DIRECTORY}/build-tools" | ||
export PATH=$PATH:"${ROOT_DIRECTORY}/diligence/scripts" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
#!/bin/bash | ||
|
||
# Copyright (c) 2024 Jason Morley | ||
# | ||
# Permission is hereby granted, free of charge, to any person obtaining a copy | ||
# of this software and associated documentation files (the "Software"), to deal | ||
# in the Software without restriction, including without limitation the rights | ||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
# copies of the Software, and to permit persons to whom the Software is | ||
# furnished to do so, subject to the following conditions: | ||
# | ||
# The above copyright notice and this permission notice shall be included in all | ||
# copies or substantial portions of the Software. | ||
# | ||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
# SOFTWARE. | ||
|
||
set -e | ||
set -o pipefail | ||
set -x | ||
set -u | ||
|
||
SCRIPTS_DIRECTORY="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" | ||
ROOT_DIRECTORY="${SCRIPTS_DIRECTORY}/.." | ||
CHANGES_DIRECTORY="${SCRIPTS_DIRECTORY}/changes" | ||
BUILD_TOOLS_DIRECTORY="${SCRIPTS_DIRECTORY}/build-tools" | ||
|
||
ENVIRONMENT_PATH="${SCRIPTS_DIRECTORY}/environment.sh" | ||
|
||
if [ -d "${ROOT_DIRECTORY}/.local" ] ; then | ||
rm -r "${ROOT_DIRECTORY}/.local" | ||
fi | ||
source "${ENVIRONMENT_PATH}" | ||
|
||
# Install the Python dependencies | ||
pip3 install --user pipenv | ||
PIPENV_PIPFILE="$CHANGES_DIRECTORY/Pipfile" pipenv install | ||
PIPENV_PIPFILE="$BUILD_TOOLS_DIRECTORY/Pipfile" pipenv install |
Oops, something went wrong.