Skip to content

Commit 6f7fa68

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

File tree

7 files changed

+165
-4
lines changed

7 files changed

+165
-4
lines changed

.github/workflows/build-ios.yml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
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_with_signing:
17+
runs-on: macos-latest
18+
steps:
19+
- name: Check Xcode version
20+
run: /usr/bin/xcodebuild -version
21+
22+
- name: Check out repository
23+
uses: actions/checkout@v3
24+
25+
- name: Obtain certificate
26+
env:
27+
BUILD_CERTIFICATE_BASE64: ${{ secrets.BUILD_CERTIFICATE_BASE64 }}
28+
run: |
29+
echo -n "$BUILD_CERTIFICATE_BASE64" | base64 --decode -o "./Assets/developer-certificate.p12"
30+
31+
- name: Install Go
32+
uses: actions/setup-go@v5
33+
with:
34+
go-version: ${{ env.GO_VERSION }}
35+
cache: false
36+
check-latest: true
37+
38+
- name: Make ipa
39+
env:
40+
P12_PASSWORD: ${{ secrets.P12_PASSWORD }}
41+
run: |
42+
make ipa
43+
44+
- name: Upload application
45+
uses: actions/upload-artifact@v4
46+
with:
47+
name: app
48+
path: ./Build
49+
retention-days: 3
50+
51+
- name: Generate artifact attestation
52+
uses: actions/attest-build-provenance@v2
53+
with:
54+
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>589483bc-da9c-4fda-a64f-8dc02e1491a1</string>
21+
</dict>
22+
</dict>
23+
</plist>
12.7 KB
Binary file not shown.

Makefile

Lines changed: 81 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,86 @@
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_SPECIFIER="589483bc-da9c-4fda-a64f-8dc02e1491a1"
26+
27+
PROVISIONING_PROFILE_UUID=$(shell security cms -D -i ./Assets/synctrain-ios-ci.mobileprovision | plutil -extract UUID raw -)
28+
PROVISIONING_PROFILE_PATH=~/Library/MobileDevice/Provisioning\ Profiles/$(PROVISIONING_PROFILE_UUID).mobileprovision
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+
ipa: core
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+
echo $(PROVISIONING_PROFILE_UUID) $(PROVISIONING_PROFILE_PATH)
44+
mkdir -p $(BUILD_DIR)
45+
46+
# Set up a keychain
47+
security create-keychain -p $(KEYCHAIN_PASSWORD) $(KEYCHAIN_PATH)
48+
security set-keychain-settings -lut 21600 $(KEYCHAIN_PATH)
49+
security unlock-keychain -p $(KEYCHAIN_PASSWORD) $(KEYCHAIN_PATH)
50+
51+
# Import WWDR root certificate
52+
# See https://www.apple.com/certificateauthority/
53+
security import ./Assets/AppleWWDRCAG3.cer -A -t cert -k $(KEYCHAIN_PATH)
54+
55+
# Import developer certificate
56+
security import ./Assets/developer-certificate.p12 -P $(P12_PASSWORD) -A -t cert -f pkcs12 -k $(KEYCHAIN_PATH)
57+
security list-keychain -d user -s $(KEYCHAIN_PATH)
58+
59+
# Import provisioning profile
60+
mkdir -p ~/Library/MobileDevice/Provisioning\ Profiles
61+
cp ./Assets/synctrain-ios-ci.mobileprovision $(PROVISIONING_PROFILE_PATH)
62+
ls -la ~/Library/MobileDevice/Provisioning\ Profiles
63+
64+
# Build archive
65+
xcodebuild -scheme "Synctrain release" \
66+
-archivePath "$(BUILD_DIR)/synctrain-ios.xcarchive" \
67+
-sdk iphoneos \
68+
-configuration Release \
69+
-destination generic/platform=iOS \
70+
CODE_SIGN_IDENTITY=$(CODESIGN_IDENTITY) \
71+
OTHER_CODE_SIGN_FLAGS="--keychain $(KEYCHAIN_PATH)" \
72+
PROVISIONING_PROFILE_SPECIFIER=$(PROVISIONING_PROFILE_UUID) \
73+
DEVELOPMENT_TEAM=$(TEAM_ID) \
74+
CODE_SIGN_STYLE="Manual" \
75+
clean archive
76+
77+
# Export ipa
78+
xcodebuild \
79+
-exportArchive \
80+
-exportOptionsPlist ./Assets/ExportOptions.plist \
81+
-archivePath "$(BUILD_DIR)/synctrain-ios.xcarchive" \
82+
-exportPath $(BUILD_DIR)
83+
84+
# Clean up
85+
security delete-keychain $(KEYCHAIN_PATH)
86+
rm $(PROVISIONING_PROFILE_PATH)

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)