-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #49 from allanlang/github-actions-build
GitHub actions build
- Loading branch information
Showing
5 changed files
with
157 additions
and
3 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,69 @@ | ||
name: build-release | ||
on: [push, pull_request] | ||
jobs: | ||
build: | ||
name: Build default scheme | ||
runs-on: macos-latest | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
- name: Install tools | ||
run: | | ||
brew install sunshinejr/formulae/pouch | ||
- name: Generate Secrets.swift | ||
env: | ||
AIRTABLE_API_KEY: ${{ secrets.AIRTABLE_API_KEY }} | ||
AIRTABLE_BASE_ID: ${{ secrets.AIRTABLE_BASE_ID }} | ||
AIRTABLE_TREES_TABLE_NAME: ${{ secrets.AIRTABLE_TREES_TABLE_NAME }} | ||
AIRTABLE_SPECIES_TABLE_NAME: ${{ secrets.AIRTABLE_SPECIES_TABLE_NAME }} | ||
AIRTABLE_SUPERVISORS_TABLE_NAME: ${{ secrets.AIRTABLE_SUPERVISORS_TABLE_NAME }} | ||
AIRTABLE_SITES_TABLE_NAME: ${{ secrets.AIRTABLE_SITES_TABLE_NAME }} | ||
CLOUDINARY_CLOUD_NAME: ${{ secrets.CLOUDINARY_CLOUD_NAME }} | ||
CLOUDINARY_UPLOAD_PRESET_NAME: ${{ secrets.CLOUDINARY_UPLOAD_PRESET_NAME }} | ||
run: pouch | ||
- name: Set build number | ||
run: agvtool new-version $GITHUB_RUN_NUMBER | ||
- name: Build and test | ||
env: | ||
platform: ${{ 'iOS Simulator' }} | ||
run: | | ||
# xcrun xctrace returns via stderr, not the expected stdout (see https://developer.apple.com/forums/thread/663959) | ||
device=`xcrun xctrace list devices 2>&1 | grep -oE 'iPhone.*?[^\(]+' | head -1 | awk '{print $1" "$2}'` | ||
set -o pipefail | ||
xcodebuild build-for-testing test -scheme "Unit Tests" -project "Tree Tracker.xcodeproj" -destination "platform=$platform,name=$device" | xcpretty | ||
- name: Configure Keychain | ||
env: | ||
PROVISIONING_PROFILE_BASE64: ${{ secrets.PROVISIONING_PROFILE_BASE64 }} | ||
DISTRIBUTION_CERT_BASE64: ${{ secrets.DISTRIBUTION_CERT_BASE64 }} | ||
APP_SPECIFIC_PWD: ${{ secrets.APPLE_APP_SPECIFIC_PASSWORD }} | ||
run: | | ||
mkdir -p ~/Library/MobileDevice/Provisioning\ Profiles | ||
echo -n $PROVISIONING_PROFILE_BASE64 | base64 -D > ~/Library/MobileDevice/Provisioning\ Profiles/iOS_App_Store_Distribution_Profile_20220213.mobileprovision.mobileprovision | ||
echo -n $DISTRIBUTION_CERT_BASE64 | base64 -D > ~/Certificates.p12 | ||
ls -lrt ~/Library/MobileDevice/Provisioning\ Profiles | ||
ls -lrt ~/Certificates.p12 | ||
security create-keychain -p "" build.keychain | ||
security import ~/Certificates.p12 -t agg -k ~/Library/Keychains/build.keychain -P "" -A | ||
security list-keychains -s ~/Library/Keychains/build.keychain | ||
security default-keychain -s ~/Library/Keychains/build.keychain | ||
security unlock-keychain -p "" ~/Library/Keychains/build.keychain | ||
security set-key-partition-list -S apple-tool:,apple: -s -k "" ~/Library/Keychains/build.keychain | ||
- name: Build archive | ||
run: | | ||
set -o pipefail | ||
mkdir -p ~/build | ||
xcodebuild clean archive -scheme "Tree Tracker" -project "Tree Tracker.xcodeproj" -sdk iphoneos -configuration Release -archivePath ~/build/Tree\ Tracker.xcarchive | xcpretty | ||
- name: Export .ipa | ||
run: | | ||
set -o pipefail | ||
xcodebuild -archivePath ~/build/Tree\ Tracker.xcarchive -exportOptionsPlist $GITHUB_WORKSPACE/Tree\ Tracker/ExportOptions.plist -exportPath ~/build -allowProvisioningUpdates -exportArchive | xcpretty | ||
- name: Publish | ||
if: ${{ success() && github.ref_name == 'main' && github.event_name != 'pull_request' }} | ||
env: | ||
APPLEID_USERNAME: ${{ secrets.APPLE_APPLE_ID }} | ||
APPLEID_PASSWORD: ${{ secrets.APPLE_APP_SPECIFIC_PASSWORD }} | ||
run: | | ||
xcrun altool --upload-app -t ios -f ~/build/Tree\ Tracker.ipa -u "$APPLEID_USERNAME" -p "$APPLEID_PASSWORD" --verbose |
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,46 @@ | ||
# Tree Tracker CI/CD Setup | ||
CI/CD for Tree Tracker has been configured with GitHub Actions to allow new builds to be tested and delivered via TestFlight with a single click or in response to specific repository events. | ||
|
||
## Workflow | ||
|
||
The GitHub Actions workflow is located in `.github/workflows/build-release.yaml` and will trigger on any push or pull request for the repository. If the triggering event is a merge to `main`, the resulting application will also be published to TestFlight. Unit tests are executed early on in the workflow, which will exit if these do not pass. | ||
|
||
## Pre-requisites | ||
|
||
In order for the workflow to run successfully, repository secrets must be configured to provide the various API credentials the application requires. | ||
|
||
To add these, navigate to _Settings > Security > Secrets > Actions_ and add the following as repository secrets with the appropriate values: | ||
|
||
``` | ||
AIRTABLE_API_KEY | ||
AIRTABLE_BASE_ID | ||
AIRTABLE_TREES_TABLE_NAME | ||
AIRTABLE_SPECIES_TABLE_NAME | ||
AIRTABLE_SUPERVISORS_TABLE_NAME | ||
AIRTABLE_SITES_TABLE_NAME | ||
CLOUDINARY_CLOUD_NAME | ||
CLOUDINARY_UPLOAD_PRESET_NAME | ||
``` | ||
|
||
Finally, additional secrets must be configured to store the details required for signing and publishing the app to the AppStore. Add the following secrets in the same way as before, with the appropriate values: | ||
|
||
``` | ||
PROVISIONING_PROFILE_BASE64 | ||
DISTRIBUTION_CERT_BASE64 | ||
APPLE_APPLE_ID | ||
APPLE_APP_SPECIFIC_PASSWORD | ||
``` | ||
|
||
The provisioning profile used is currently _iOS App Store Distribution Profile 20220213_, which may be downloaded from AppStore Connect. Both files should be encoded to base64 via the following command line: | ||
|
||
`cat <path/to/file> | base64` | ||
|
||
The App Specific Password is essentially an additional password which you can use to authenticate your AppleID account with, and should only be used in specific cases. Generate a new password as follows: | ||
|
||
* Sign in with your AppleID at https://appleid.apple.com/ | ||
* Navigate to _Sign-In and Security > App-Specific Password_ | ||
* Add or generate a new App-Specific Password and add the password to the `APPLE_APP_SPECIFIC_PASSWORD` secret as listed above, along with your AppleID in `APPLE_APPLE_ID`. | ||
|
||
## TestFlight notes | ||
|
||
The build number of the app is set to the run number of the workflow using `agvtool`. Updates to the release number should be made manually via a PR. Once published, compliance requirements will need to be accepted manually in TestFlight, and the appropriate tester groups will need to be added in order to get access to the latest build. |
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 |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?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>teamID</key> | ||
<string>K5RUKV288P</string> | ||
<key>signingCertificate</key> | ||
<string>iPhone Distribution: Protect Earth CIO (K5RUKV288P)</string> | ||
<key>provisioningProfiles</key> | ||
<dict> | ||
<key>com.protect.earth.Tree-Tracker</key> | ||
<string>iOS App Store Distribution Profile 2022-02-13</string> | ||
</dict> | ||
<key>method</key> | ||
<string>app-store</string> | ||
</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