Skip to content

Commit 94f3392

Browse files
committed
ci: set up automatic build for iOS
1 parent 289734e commit 94f3392

File tree

8 files changed

+179
-4
lines changed

8 files changed

+179
-4
lines changed

.github/workflows/build-ios.yml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: "Build iOS 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: Make ipa
42+
env:
43+
P12_PASSWORD: ${{ secrets.P12_PASSWORD }}
44+
run: |
45+
make ipa
46+
47+
- name: Upload application
48+
uses: actions/upload-artifact@v4
49+
with:
50+
name: app
51+
path: ./Build
52+
retention-days: 3
53+
54+
# - name: Generate artifact attestation
55+
# uses: actions/attest-build-provenance@v2
56+
# with:
57+
# subject-path: ./Build/synctrain.ipa

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
/SushitrainCore/build
22
/Sushitrain.xcodeproj/project.xcworkspace/xcuserdata
33
/Sushitrain.xcodeproj/xcuserdata
4-
/localize.sh
4+
/localize.sh
5+
/Build
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.

Makefile

Lines changed: 88 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,93 @@
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 ipa clean build
7+
8+
build: core ipa
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=$(shell security cms -D -i ./Assets/synctrain-ios-ci.mobileprovision | plutil -extract UUID raw -)
26+
PROVISIONING_PROFILE_PATH=~/Library/MobileDevice/Provisioning\ Profiles/$(PROVISIONING_PROFILE_UUID).mobileprovision
27+
28+
clean:
29+
rm -rf $(BUILD_DIR)
30+
cd SushitrainCore && make clean
31+
32+
core:
33+
cd SushitrainCore && make deps
34+
cd SushitrainCore && make
35+
36+
ipa: core
37+
ifndef P12_PASSWORD
38+
echo You need to set 'P12_PASSWORD' to the password of the .p12 certificate.
39+
exit 1
40+
endif
41+
echo $(PROVISIONING_PROFILE_UUID) $(PROVISIONING_PROFILE_PATH)
42+
mkdir -p $(BUILD_DIR)
43+
44+
# Set up a keychain
45+
security create-keychain -p $(KEYCHAIN_PASSWORD) $(KEYCHAIN_PATH)
46+
security set-keychain-settings -lut 21600 $(KEYCHAIN_PATH)
47+
security unlock-keychain -p $(KEYCHAIN_PASSWORD) $(KEYCHAIN_PATH)
48+
49+
# Import WWDR root certificate
50+
# See https://www.apple.com/certificateauthority/
51+
security import ./Assets/AppleWWDRCAG3.cer -A -t cert -k $(KEYCHAIN_PATH)
52+
53+
# Import developer certificate
54+
security import ./Assets/developer-certificate.p12 -P $(P12_PASSWORD) -A -t cert -f pkcs12 -k $(KEYCHAIN_PATH)
55+
security list-keychain -d user -s $(KEYCHAIN_PATH)
56+
57+
# Import provisioning profile
58+
mkdir -p ~/Library/MobileDevice/Provisioning\ Profiles
59+
cp ./Assets/synctrain-ios-ci.mobileprovision $(PROVISIONING_PROFILE_PATH)
60+
ls -la ~/Library/MobileDevice/Provisioning\ Profiles
61+
62+
# Build archive
63+
xcodebuild -scheme "Synctrain release" \
64+
-archivePath "$(BUILD_DIR)/synctrain-ios.xcarchive" \
65+
-sdk iphoneos \
66+
-configuration Release \
67+
-destination generic/platform=iOS \
68+
CODE_SIGN_IDENTITY=$(CODESIGN_IDENTITY) \
69+
OTHER_CODE_SIGN_FLAGS="--keychain $(KEYCHAIN_PATH)" \
70+
PROVISIONING_PROFILE_SPECIFIER=$(PROVISIONING_PROFILE_UUID) \
71+
DEVELOPMENT_TEAM=$(TEAM_ID) \
72+
CODE_SIGN_STYLE="Manual" \
73+
clean archive
74+
75+
# Export ipa
76+
# ls -la ~/Library/MobileDevice/Provisioning\ Profiles
77+
# cp ./Assets/synctrain-ios-ci.mobileprovision $(PROVISIONING_PROFILE_PATH)
78+
# ls -la ~/Library/MobileDevice/Provisioning\ Profiles
79+
# xcodebuild \
80+
# -exportArchive \
81+
# -exportOptionsPlist ./Assets/ExportOptions.plist \
82+
# -archivePath "$(BUILD_DIR)/synctrain-ios.xcarchive" \
83+
# -exportPath $(BUILD_DIR) \
84+
# CODE_SIGN_IDENTITY=$(CODESIGN_IDENTITY) \
85+
# OTHER_CODE_SIGN_FLAGS="--keychain $(KEYCHAIN_PATH)" \
86+
# PROVISIONING_PROFILE_SPECIFIER=$(PROVISIONING_PROFILE_UUID) \
87+
# DEVELOPMENT_TEAM=$(TEAM_ID) \
88+
# CODE_SIGN_STYLE="Manual"
89+
90+
# Clean up
91+
-rm $(PROVISIONING_PROFILE_PATH)
92+
security delete-keychain $(KEYCHAIN_PATH)
93+
echo All done!

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)