Skip to content

Commit b3b6a00

Browse files
committed
ci: set up automatic build for iOS
1 parent 5bde9e2 commit b3b6a00

File tree

9 files changed

+183
-4
lines changed

9 files changed

+183
-4
lines changed

.github/workflows/build.yml

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
name: "Build iOS+macOS app"
2+
3+
on:
4+
pull_request:
5+
push:
6+
7+
env:
8+
GO_VERSION: "~1.24.0"
9+
10+
permissions:
11+
id-token: write
12+
contents: read
13+
attestations: write
14+
15+
jobs:
16+
build:
17+
runs-on: macos-latest
18+
steps:
19+
- name: Check Xcode version
20+
run: |
21+
/usr/bin/xcodebuild -version
22+
sudo /usr/bin/xcode-select -switch /Applications/Xcode_16.2.app/Contents/Developer
23+
/usr/bin/xcodebuild -version
24+
25+
- name: Check out repository
26+
uses: actions/checkout@v3
27+
28+
- name: Obtain certificate
29+
env:
30+
BUILD_CERTIFICATE_BASE64: ${{ secrets.BUILD_CERTIFICATE_BASE64 }}
31+
run: |
32+
echo -n "$BUILD_CERTIFICATE_BASE64" | base64 --decode -o "./Assets/developer-certificate.p12"
33+
34+
- name: Install Go
35+
uses: actions/setup-go@v5
36+
with:
37+
go-version: ${{ env.GO_VERSION }}
38+
cache: false
39+
check-latest: true
40+
41+
- name: Build for iOS and macOS
42+
env:
43+
P12_PASSWORD: ${{ secrets.P12_PASSWORD }}
44+
run: |
45+
make ios mac
46+
make cleanup
47+
48+
- name: Upload application
49+
uses: actions/upload-artifact@v4
50+
with:
51+
name: app
52+
path: ./Build
53+
retention-days: 3
54+
55+
# - name: Generate artifact attestation
56+
# uses: actions/attest-build-provenance@v2
57+
# with:
58+
# subject-path: ./Build/synctrain.ipa

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33
/Sushitrain.xcodeproj/xcuserdata
44
/localize.sh
55
/Build
6-
/Assets
6+
*.p12

Assets/AppleWWDRCAG3.cer

1.08 KB
Binary file not shown.

Assets/ExportOptions.plist

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
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>compileBitcode</key>
6+
<false />
7+
<key>method</key>
8+
<string>development</string>
9+
<key>signingStyle</key>
10+
<string>automatic</string>
11+
<key>stripSwiftSymbols</key>
12+
<true />
13+
<key>teamID</key>
14+
<string>2N89DJPQ2P</string>
15+
<key>thinning</key>
16+
<string>&lt;none&gt;</string>
17+
<key>provisioningProfiles</key>
18+
<dict>
19+
<key>nl.t-shaped.Sushitrain</key>
20+
<string>CI</string>
21+
</dict>
22+
</dict>
23+
</plist>
14.7 KB
Binary file not shown.
12.4 KB
Binary file not shown.

Makefile

Lines changed: 93 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,98 @@
1-
.PHONY: lint format
1+
# Copyright (C) 2025 Tommy van der Vorst
2+
#
3+
# This Source Code Form is subject to the terms of the Mozilla Public
4+
# License, v. 2.0. If a copy of the MPL was not distributed with this file,
5+
# You can obtain one at https://mozilla.org/MPL/2.0/.
6+
.PHONY: lint format macos ios clean build cleanup
7+
8+
build: macos ios
29

310
format: Sushitrain/*.swift
411
swift-format format -r -i .
512

613
lint: Sushitrain/*.swift
7-
swift-format lint -r .
14+
swift-format lint -r .
15+
16+
BUILD_DIR=$(shell pwd)/Build
17+
KEYCHAIN_PATH=$(BUILD_DIR)/keychain.db
18+
CODESIGN_IDENTITY="Apple Development: Tommy van der Vorst (NG3J47D2S7)"
19+
KEYCHAIN_PASSWORD="not so secret"
20+
21+
# Apple developer team ID (must match certificate and provisioning profile)
22+
TEAM_ID=2N89DJPQ2P
23+
24+
# UUID of Assets/synctrain-ios-ci.mobileprovision
25+
PROVISIONING_PROFILE_UUID_IOS=$(shell security cms -D -i ./Assets/synctrain-ios-ci.mobileprovision | plutil -extract UUID raw -)
26+
PROVISIONING_PROFILE_PATH_IOS=~/Library/MobileDevice/Provisioning\ Profiles/$(PROVISIONING_PROFILE_UUID_IOS).mobileprovision
27+
PROVISIONING_PROFILE_UUID_MACOS=$(shell security cms -D -i ./Assets/synctrain-macos-ci.provisionprofile | plutil -extract UUID raw -)
28+
PROVISIONING_PROFILE_PATH_MACOS=~/Library/MobileDevice/Provisioning\ Profiles/$(PROVISIONING_PROFILE_UUID_MACOS).provisionprofile
29+
30+
clean:
31+
rm -rf $(BUILD_DIR)
32+
cd SushitrainCore && make clean
33+
34+
core:
35+
cd SushitrainCore && make deps
36+
cd SushitrainCore && make
37+
38+
provisioning:
39+
ifndef P12_PASSWORD
40+
echo You need to set 'P12_PASSWORD' to the password of the .p12 certificate.
41+
exit 1
42+
endif
43+
44+
echo $(PROVISIONING_PROFILE_UUID_IOS) $(PROVISIONING_PROFILE_PATH_IOS)
45+
echo $(PROVISIONING_PROFILE_UUID_MACOS) $(PROVISIONING_PROFILE_PATH_MACOS)
46+
mkdir -p $(BUILD_DIR)
47+
48+
# Set up a keychain
49+
security create-keychain -p $(KEYCHAIN_PASSWORD) $(KEYCHAIN_PATH)
50+
security set-keychain-settings -lut 21600 $(KEYCHAIN_PATH)
51+
security unlock-keychain -p $(KEYCHAIN_PASSWORD) $(KEYCHAIN_PATH)
52+
53+
# Import WWDR root certificate
54+
# See https://www.apple.com/certificateauthority/
55+
security import ./Assets/AppleWWDRCAG3.cer -A -t cert -k $(KEYCHAIN_PATH)
56+
57+
# Import developer certificate
58+
security import ./Assets/developer-certificate.p12 -P $(P12_PASSWORD) -A -t cert -f pkcs12 -k $(KEYCHAIN_PATH)
59+
security list-keychain -d user -s $(KEYCHAIN_PATH)
60+
61+
# Import provisioning profile
62+
mkdir -p ~/Library/MobileDevice/Provisioning\ Profiles
63+
cp ./Assets/synctrain-ios-ci.mobileprovision $(PROVISIONING_PROFILE_PATH_IOS)
64+
cp ./Assets/synctrain-macos-ci.provisionprofile $(PROVISIONING_PROFILE_PATH_MACOS)
65+
ls -la ~/Library/MobileDevice/Provisioning\ Profiles
66+
67+
mac: core provisioning
68+
# Build .app
69+
xcodebuild -scheme "Synctrain release" \
70+
-archivePath "$(BUILD_DIR)/synctrain-macos.xcarchive" \
71+
-sdk macosx \
72+
-configuration Release \
73+
-destination generic/platform=macOS \
74+
CODE_SIGN_IDENTITY=$(CODESIGN_IDENTITY) \
75+
OTHER_CODE_SIGN_FLAGS="--keychain $(KEYCHAIN_PATH)" \
76+
PROVISIONING_PROFILE_SPECIFIER=$(PROVISIONING_PROFILE_UUID_MACOS) \
77+
DEVELOPMENT_TEAM=$(TEAM_ID) \
78+
CODE_SIGN_STYLE="Manual" \
79+
clean archive
80+
81+
ios: core provisioning
82+
# Build archive
83+
xcodebuild -scheme "Synctrain release" \
84+
-archivePath "$(BUILD_DIR)/synctrain-ios.xcarchive" \
85+
-sdk iphoneos \
86+
-configuration Release \
87+
-destination generic/platform=iOS \
88+
CODE_SIGN_IDENTITY=$(CODESIGN_IDENTITY) \
89+
OTHER_CODE_SIGN_FLAGS="--keychain $(KEYCHAIN_PATH)" \
90+
PROVISIONING_PROFILE_SPECIFIER=$(PROVISIONING_PROFILE_UUID_IOS) \
91+
DEVELOPMENT_TEAM=$(TEAM_ID) \
92+
CODE_SIGN_STYLE="Manual" \
93+
clean archive
94+
95+
cleanup:
96+
# Clean up
97+
-rm $(PROVISIONING_PROFILE_PATH_IOS)
98+
security delete-keychain $(KEYCHAIN_PATH)

Sushitrain.xcodeproj/project.pbxproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -522,6 +522,7 @@
522522
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
523523
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
524524
CODE_SIGN_ENTITLEMENTS = Sushitrain/Sushitrain.entitlements;
525+
CODE_SIGN_IDENTITY = "Apple Development";
525526
CODE_SIGN_STYLE = Automatic;
526527
CURRENT_PROJECT_VERSION = 32;
527528
DEVELOPMENT_ASSET_PATHS = "\"Sushitrain/Preview Content\"";
@@ -549,6 +550,7 @@
549550
MARKETING_VERSION = 1.9;
550551
PRODUCT_BUNDLE_IDENTIFIER = "nl.t-shaped.Sushitrain";
551552
PRODUCT_NAME = "$(TARGET_NAME)";
553+
PROVISIONING_PROFILE_SPECIFIER = "";
552554
REGISTER_APP_GROUPS = NO;
553555
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator macosx";
554556
SUPPORTS_MACCATALYST = NO;
@@ -565,6 +567,7 @@
565567
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
566568
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
567569
CODE_SIGN_ENTITLEMENTS = Sushitrain/Sushitrain.entitlements;
570+
CODE_SIGN_IDENTITY = "Apple Development";
568571
CODE_SIGN_STYLE = Automatic;
569572
CURRENT_PROJECT_VERSION = 32;
570573
DEVELOPMENT_ASSET_PATHS = "\"Sushitrain/Preview Content\"";
@@ -592,6 +595,7 @@
592595
MARKETING_VERSION = 1.9;
593596
PRODUCT_BUNDLE_IDENTIFIER = "nl.t-shaped.Sushitrain";
594597
PRODUCT_NAME = "$(TARGET_NAME)";
598+
PROVISIONING_PROFILE_SPECIFIER = "";
595599
REGISTER_APP_GROUPS = NO;
596600
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator macosx";
597601
SUPPORTS_MACCATALYST = NO;

SushitrainCore/Makefile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# This Source Code Form is subject to the terms of the Mozilla Public
44
# License, v. 2.0. If a copy of the MPL was not distributed with this file,
55
# You can obtain one at https://mozilla.org/MPL/2.0/.
6-
PATH := /opt/homebrew/bin:$(HOME)/go/bin:$(PATH)
6+
PATH := $(shell pwd):/opt/homebrew/bin:$(HOME)/go/bin:$(PATH)
77
SHELL := env PATH="$(PATH)" /bin/bash
88
GOMOBILE_VERSION := $(shell gomobile version)
99
GO_VERSION := $(shell go version)
@@ -18,6 +18,9 @@ ifndef GO_VERSION
1818
endif
1919
ifndef GOMOBILE_VERSION
2020
go get golang.org/x/mobile/cmd/gomobile
21+
go get golang.org/x/mobile/cmd/gobind
22+
go build golang.org/x/mobile/cmd/gomobile
23+
go build golang.org/x/mobile/cmd/gobind
2124
endif
2225

2326
notices.html: notices.template.html go.mod go.sum

0 commit comments

Comments
 (0)