Skip to content

Commit 329cc34

Browse files
authored
Merge pull request #49 from allanlang/github-actions-build
GitHub actions build
2 parents 6edcb51 + e825eaf commit 329cc34

File tree

5 files changed

+157
-3
lines changed

5 files changed

+157
-3
lines changed

.github/workflows/build-release.yaml

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
name: build-release
2+
on: [push, pull_request]
3+
jobs:
4+
build:
5+
name: Build default scheme
6+
runs-on: macos-latest
7+
8+
steps:
9+
- name: Checkout
10+
uses: actions/checkout@v2
11+
- name: Install tools
12+
run: |
13+
brew install sunshinejr/formulae/pouch
14+
- name: Generate Secrets.swift
15+
env:
16+
AIRTABLE_API_KEY: ${{ secrets.AIRTABLE_API_KEY }}
17+
AIRTABLE_BASE_ID: ${{ secrets.AIRTABLE_BASE_ID }}
18+
AIRTABLE_TREES_TABLE_NAME: ${{ secrets.AIRTABLE_TREES_TABLE_NAME }}
19+
AIRTABLE_SPECIES_TABLE_NAME: ${{ secrets.AIRTABLE_SPECIES_TABLE_NAME }}
20+
AIRTABLE_SUPERVISORS_TABLE_NAME: ${{ secrets.AIRTABLE_SUPERVISORS_TABLE_NAME }}
21+
AIRTABLE_SITES_TABLE_NAME: ${{ secrets.AIRTABLE_SITES_TABLE_NAME }}
22+
CLOUDINARY_CLOUD_NAME: ${{ secrets.CLOUDINARY_CLOUD_NAME }}
23+
CLOUDINARY_UPLOAD_PRESET_NAME: ${{ secrets.CLOUDINARY_UPLOAD_PRESET_NAME }}
24+
run: pouch
25+
- name: Set build number
26+
run: agvtool new-version $GITHUB_RUN_NUMBER
27+
- name: Build and test
28+
env:
29+
platform: ${{ 'iOS Simulator' }}
30+
run: |
31+
# xcrun xctrace returns via stderr, not the expected stdout (see https://developer.apple.com/forums/thread/663959)
32+
device=`xcrun xctrace list devices 2>&1 | grep -oE 'iPhone.*?[^\(]+' | head -1 | awk '{print $1" "$2}'`
33+
set -o pipefail
34+
xcodebuild build-for-testing test -scheme "Unit Tests" -project "Tree Tracker.xcodeproj" -destination "platform=$platform,name=$device" | xcpretty
35+
- name: Configure Keychain
36+
env:
37+
PROVISIONING_PROFILE_BASE64: ${{ secrets.PROVISIONING_PROFILE_BASE64 }}
38+
DISTRIBUTION_CERT_BASE64: ${{ secrets.DISTRIBUTION_CERT_BASE64 }}
39+
APP_SPECIFIC_PWD: ${{ secrets.APPLE_APP_SPECIFIC_PASSWORD }}
40+
run: |
41+
mkdir -p ~/Library/MobileDevice/Provisioning\ Profiles
42+
echo -n $PROVISIONING_PROFILE_BASE64 | base64 -D > ~/Library/MobileDevice/Provisioning\ Profiles/iOS_App_Store_Distribution_Profile_20220213.mobileprovision.mobileprovision
43+
echo -n $DISTRIBUTION_CERT_BASE64 | base64 -D > ~/Certificates.p12
44+
45+
ls -lrt ~/Library/MobileDevice/Provisioning\ Profiles
46+
ls -lrt ~/Certificates.p12
47+
48+
security create-keychain -p "" build.keychain
49+
security import ~/Certificates.p12 -t agg -k ~/Library/Keychains/build.keychain -P "" -A
50+
security list-keychains -s ~/Library/Keychains/build.keychain
51+
security default-keychain -s ~/Library/Keychains/build.keychain
52+
security unlock-keychain -p "" ~/Library/Keychains/build.keychain
53+
security set-key-partition-list -S apple-tool:,apple: -s -k "" ~/Library/Keychains/build.keychain
54+
- name: Build archive
55+
run: |
56+
set -o pipefail
57+
mkdir -p ~/build
58+
xcodebuild clean archive -scheme "Tree Tracker" -project "Tree Tracker.xcodeproj" -sdk iphoneos -configuration Release -archivePath ~/build/Tree\ Tracker.xcarchive | xcpretty
59+
- name: Export .ipa
60+
run: |
61+
set -o pipefail
62+
xcodebuild -archivePath ~/build/Tree\ Tracker.xcarchive -exportOptionsPlist $GITHUB_WORKSPACE/Tree\ Tracker/ExportOptions.plist -exportPath ~/build -allowProvisioningUpdates -exportArchive | xcpretty
63+
- name: Publish
64+
if: ${{ success() && github.ref_name == 'main' && github.event_name != 'pull_request' }}
65+
env:
66+
APPLEID_USERNAME: ${{ secrets.APPLE_APPLE_ID }}
67+
APPLEID_PASSWORD: ${{ secrets.APPLE_APP_SPECIFIC_PASSWORD }}
68+
run: |
69+
xcrun altool --upload-app -t ios -f ~/build/Tree\ Tracker.ipa -u "$APPLEID_USERNAME" -p "$APPLEID_PASSWORD" --verbose

CICD.md

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# Tree Tracker CI/CD Setup
2+
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.
3+
4+
## Workflow
5+
6+
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.
7+
8+
## Pre-requisites
9+
10+
In order for the workflow to run successfully, repository secrets must be configured to provide the various API credentials the application requires.
11+
12+
To add these, navigate to _Settings > Security > Secrets > Actions_ and add the following as repository secrets with the appropriate values:
13+
14+
```
15+
AIRTABLE_API_KEY
16+
AIRTABLE_BASE_ID
17+
AIRTABLE_TREES_TABLE_NAME
18+
AIRTABLE_SPECIES_TABLE_NAME
19+
AIRTABLE_SUPERVISORS_TABLE_NAME
20+
AIRTABLE_SITES_TABLE_NAME
21+
CLOUDINARY_CLOUD_NAME
22+
CLOUDINARY_UPLOAD_PRESET_NAME
23+
```
24+
25+
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:
26+
27+
```
28+
PROVISIONING_PROFILE_BASE64
29+
DISTRIBUTION_CERT_BASE64
30+
APPLE_APPLE_ID
31+
APPLE_APP_SPECIFIC_PASSWORD
32+
```
33+
34+
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:
35+
36+
`cat <path/to/file> | base64`
37+
38+
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:
39+
40+
* Sign in with your AppleID at https://appleid.apple.com/
41+
* Navigate to _Sign-In and Security > App-Specific Password_
42+
* 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`.
43+
44+
## TestFlight notes
45+
46+
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.

Tree Tracker.xcodeproj/project.pbxproj

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@
108108
85DC214625E0FCBF003F0721 /* GRDBImageCache.swift in Sources */ = {isa = PBXBuildFile; fileRef = 85DC214525E0FCBF003F0721 /* GRDBImageCache.swift */; };
109109
85E0E05E25B33F8C009D8FC0 /* TappableButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 85E0E05D25B33F8C009D8FC0 /* TappableButton.swift */; };
110110
85E0E06225B35744009D8FC0 /* UIView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 85E0E06125B35744009D8FC0 /* UIView.swift */; };
111+
9D5CDBD727BBC080007D4F0A /* ExportOptions.plist in Resources */ = {isa = PBXBuildFile; fileRef = 9D5CDBD627BBC080007D4F0A /* ExportOptions.plist */; };
111112
/* End PBXBuildFile section */
112113

113114
/* Begin PBXContainerItemProxy section */
@@ -225,6 +226,7 @@
225226
85DC214525E0FCBF003F0721 /* GRDBImageCache.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GRDBImageCache.swift; sourceTree = "<group>"; };
226227
85E0E05D25B33F8C009D8FC0 /* TappableButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TappableButton.swift; sourceTree = "<group>"; };
227228
85E0E06125B35744009D8FC0 /* UIView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UIView.swift; sourceTree = "<group>"; };
229+
9D5CDBD627BBC080007D4F0A /* ExportOptions.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = ExportOptions.plist; sourceTree = "<group>"; };
228230
/* End PBXFileReference section */
229231

230232
/* Begin PBXFrameworksBuildPhase section */
@@ -307,6 +309,7 @@
307309
853ABD7225961B4800144B0D /* IDETemplateMacros.plist */,
308310
853ABD602596144A00144B0D /* LaunchScreen.storyboard */,
309311
853ABD632596144A00144B0D /* Info.plist */,
312+
9D5CDBD627BBC080007D4F0A /* ExportOptions.plist */,
310313
);
311314
path = "Tree Tracker";
312315
sourceTree = "<group>";
@@ -566,6 +569,7 @@
566569
buildRules = (
567570
);
568571
dependencies = (
572+
9D5CDBD527BBB7D2007D4F0A /* PBXTargetDependency */,
569573
);
570574
name = "Tree Tracker";
571575
packageProductDependencies = (
@@ -634,6 +638,7 @@
634638
buildActionMask = 2147483647;
635639
files = (
636640
853ABD7A25961C6500144B0D /* License.md in Resources */,
641+
9D5CDBD727BBC080007D4F0A /* ExportOptions.plist in Resources */,
637642
853ABD622596144A00144B0D /* LaunchScreen.storyboard in Resources */,
638643
853ABD7325961B4800144B0D /* IDETemplateMacros.plist in Resources */,
639644
853ABD5F2596144A00144B0D /* Assets.xcassets in Resources */,
@@ -759,6 +764,10 @@
759764
target = 853ABD512596144900144B0D /* Tree Tracker */;
760765
targetProxy = 851DAC2C262F2FA70087E1D4 /* PBXContainerItemProxy */;
761766
};
767+
9D5CDBD527BBB7D2007D4F0A /* PBXTargetDependency */ = {
768+
isa = PBXTargetDependency;
769+
productRef = 9D5CDBD427BBB7D2007D4F0A /* Alamofire */;
770+
};
762771
/* End PBXTargetDependency section */
763772

764773
/* Begin PBXVariantGroup section */
@@ -939,7 +948,9 @@
939948
buildSettings = {
940949
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
941950
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
942-
CODE_SIGN_STYLE = Automatic;
951+
CODE_SIGN_IDENTITY = "iPhone Distribution: Protect Earth CIO (K5RUKV288P)";
952+
CODE_SIGN_STYLE = Manual;
953+
CURRENT_PROJECT_VERSION = 1;
943954
DEVELOPMENT_TEAM = K5RUKV288P;
944955
INFOPLIST_FILE = "Tree Tracker/Info.plist";
945956
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
@@ -950,8 +961,10 @@
950961
MARKETING_VERSION = 0.7.0;
951962
PRODUCT_BUNDLE_IDENTIFIER = "com.protect.earth.Tree-Tracker";
952963
PRODUCT_NAME = "$(TARGET_NAME)";
964+
PROVISIONING_PROFILE_SPECIFIER = "iOS App Store Distribution Profile 2022-02-13";
953965
SWIFT_VERSION = 5.0;
954966
TARGETED_DEVICE_FAMILY = "1,2";
967+
VERSIONING_SYSTEM = "apple-generic";
955968
};
956969
name = Debug;
957970
};
@@ -960,7 +973,9 @@
960973
buildSettings = {
961974
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
962975
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
963-
CODE_SIGN_STYLE = Automatic;
976+
CODE_SIGN_IDENTITY = "iPhone Distribution: Protect Earth CIO (K5RUKV288P)";
977+
CODE_SIGN_STYLE = Manual;
978+
CURRENT_PROJECT_VERSION = 1;
964979
DEVELOPMENT_TEAM = K5RUKV288P;
965980
INFOPLIST_FILE = "Tree Tracker/Info.plist";
966981
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
@@ -971,8 +986,10 @@
971986
MARKETING_VERSION = 0.7.0;
972987
PRODUCT_BUNDLE_IDENTIFIER = "com.protect.earth.Tree-Tracker";
973988
PRODUCT_NAME = "$(TARGET_NAME)";
989+
PROVISIONING_PROFILE_SPECIFIER = "iOS App Store Distribution Profile 2022-02-13";
974990
SWIFT_VERSION = 5.0;
975991
TARGETED_DEVICE_FAMILY = "1,2";
992+
VERSIONING_SYSTEM = "apple-generic";
976993
};
977994
name = Release;
978995
};
@@ -1051,6 +1068,11 @@
10511068
package = 85B83A0B25B87C0D0008E167 /* XCRemoteSwiftPackageReference "BSImagePicker" */;
10521069
productName = BSImagePicker;
10531070
};
1071+
9D5CDBD427BBB7D2007D4F0A /* Alamofire */ = {
1072+
isa = XCSwiftPackageProductDependency;
1073+
package = 85A0EF8125A2271C003CE744 /* XCRemoteSwiftPackageReference "Alamofire" */;
1074+
productName = Alamofire;
1075+
};
10541076
/* End XCSwiftPackageProductDependency section */
10551077
};
10561078
rootObject = 853ABD4A2596144900144B0D /* Project object */;

Tree Tracker/ExportOptions.plist

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>teamID</key>
6+
<string>K5RUKV288P</string>
7+
<key>signingCertificate</key>
8+
<string>iPhone Distribution: Protect Earth CIO (K5RUKV288P)</string>
9+
<key>provisioningProfiles</key>
10+
<dict>
11+
<key>com.protect.earth.Tree-Tracker</key>
12+
<string>iOS App Store Distribution Profile 2022-02-13</string>
13+
</dict>
14+
<key>method</key>
15+
<string>app-store</string>
16+
</dict>
17+
</plist>

Tree Tracker/Info.plist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
<key>CFBundleShortVersionString</key>
2020
<string>$(MARKETING_VERSION)</string>
2121
<key>CFBundleVersion</key>
22-
<string>1</string>
22+
<string>$(CURRENT_PROJECT_VERSION)</string>
2323
<key>LSRequiresIPhoneOS</key>
2424
<true/>
2525
<key>NSCameraUsageDescription</key>

0 commit comments

Comments
 (0)