Skip to content

Commit 0265b95

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

File tree

8 files changed

+156
-4
lines changed

8 files changed

+156
-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>

Assets/README.md

Whitespace-only changes.
12.7 KB
Binary file not shown.

Makefile

Lines changed: 72 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,77 @@
1-
.PHONY: lint format
1+
.PHONY: lint format ipa clean build
2+
3+
build: core ipa
24

35
format: Sushitrain/*.swift
46
swift-format format -r -i .
57

68
lint: Sushitrain/*.swift
7-
swift-format lint -r .
9+
swift-format lint -r .
10+
11+
BUILD_DIR=$(shell pwd)/Build
12+
KEYCHAIN_PATH=$(BUILD_DIR)/keychain.db
13+
CODESIGN_IDENTITY="Apple Development: Tommy van der Vorst (NG3J47D2S7)"
14+
KEYCHAIN_PASSWORD="not so secret"
15+
16+
# Apple developer team ID (must match certificate and provisioning profile)
17+
TEAM_ID=2N89DJPQ2P
18+
19+
# UUID of Assets/synctrain-ios-ci.mobileprovision
20+
PROVISIONING_PROFILE_SPECIFIER="589483bc-da9c-4fda-a64f-8dc02e1491a1"
21+
22+
clean:
23+
rm -rf $(BUILD_DIR)
24+
cd SushitrainCore && make clean
25+
26+
core:
27+
cd SushitrainCore && make deps
28+
cd SushitrainCore && make
29+
30+
ipa: core
31+
ifndef P12_PASSWORD
32+
echo You need to set 'P12_PASSWORD' to the password of the .p12 certificate.
33+
exit 1
34+
endif
35+
mkdir -p $(BUILD_DIR)
36+
37+
# Set up a keychain
38+
security create-keychain -p $(KEYCHAIN_PASSWORD) $(KEYCHAIN_PATH)
39+
security set-keychain-settings -lut 21600 $(KEYCHAIN_PATH)
40+
security unlock-keychain -p $(KEYCHAIN_PASSWORD) $(KEYCHAIN_PATH)
41+
42+
# Import WWDR root certificate
43+
# See https://www.apple.com/certificateauthority/
44+
security import ./Assets/AppleWWDRCAG3.cer -A -t cert -k $(KEYCHAIN_PATH)
45+
46+
# Import developer certificate
47+
security import ./Assets/developer-certificate.p12 -P $(P12_PASSWORD) -A -t cert -f pkcs12 -k $(KEYCHAIN_PATH)
48+
security list-keychain -d user -s $(KEYCHAIN_PATH)
49+
50+
# Import provisioning profile
51+
#mkdir -p ~/Library/MobileDevice/Provisioning\ Profiles
52+
#cp ./Assets/synctrain-ios-ci.mobileprovision ~/Library/MobileDevice/Provisioning\ Profiles
53+
#ls -la ~/Library/MobileDevice/Provisioning\ Profiles
54+
55+
# Build archive
56+
xcodebuild -scheme "Synctrain release" \
57+
-archivePath "$(BUILD_DIR)/synctrain-ios.xcarchive" \
58+
-sdk iphoneos \
59+
-configuration Release \
60+
-destination generic/platform=iOS \
61+
CODE_SIGN_IDENTITY=$(CODESIGN_IDENTITY) \
62+
OTHER_CODE_SIGN_FLAGS="--keychain $(KEYCHAIN_PATH)" \
63+
PROVISIONING_PROFILE_SPECIFIER=$(PROVISIONING_PROFILE_SPECIFIER) \
64+
DEVELOPMENT_TEAM=$(TEAM_ID) \
65+
CODE_SIGN_STYLE="Manual" \
66+
clean archive
67+
68+
# Export ipa
69+
xcodebuild \
70+
-exportArchive \
71+
-exportOptionsPlist ./Assets/ExportOptions.plist \
72+
-archivePath "$(BUILD_DIR)/synctrain-ios.xcarchive" \
73+
-exportPath $(BUILD_DIR)
74+
75+
# Clean up
76+
security delete-keychain $(KEYCHAIN_PATH)
77+
#rm ~/Library/MobileDevice/Provisioning\ Profiles/synctrain-ios-ci.mobileprovision

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)