Skip to content

Commit 2bf9be6

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

File tree

3 files changed

+127
-1
lines changed

3 files changed

+127
-1
lines changed

.github/workflows/build-ios.yml

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
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: Install Go
26+
uses: actions/setup-go@v5
27+
with:
28+
go-version: ${{ env.GO_VERSION }}
29+
cache: false
30+
check-latest: true
31+
32+
- name: Build core
33+
run: |
34+
cd SushitrainCore && make deps && make
35+
36+
- name: Install the Apple certificate and provisioning profile
37+
env:
38+
BUILD_CERTIFICATE_BASE64: ${{ secrets.BUILD_CERTIFICATE_BASE64 }}
39+
P12_PASSWORD: ${{ secrets.P12_PASSWORD }}
40+
BUILD_PROVISION_PROFILE_BASE64: ${{ secrets.BUILD_PROVISION_PROFILE_BASE64 }}
41+
KEYCHAIN_PASSWORD: ${{ secrets.KEYCHAIN_PASSWORD }}
42+
run: |
43+
# create variables
44+
CERTIFICATE_PATH=$RUNNER_TEMP/build_certificate.p12
45+
PP_PATH=$RUNNER_TEMP/build_pp.mobileprovision
46+
KEYCHAIN_PATH=$RUNNER_TEMP/app-signing.keychain-db
47+
48+
# import certificate and provisioning profile from secrets
49+
echo -n "$BUILD_CERTIFICATE_BASE64" | base64 --decode -o $CERTIFICATE_PATH
50+
echo -n "$BUILD_PROVISION_PROFILE_BASE64" | base64 --decode -o $PP_PATH
51+
52+
# create temporary keychain
53+
security create-keychain -p "$KEYCHAIN_PASSWORD" $KEYCHAIN_PATH
54+
security set-keychain-settings -lut 21600 $KEYCHAIN_PATH
55+
security unlock-keychain -p "$KEYCHAIN_PASSWORD" $KEYCHAIN_PATH
56+
57+
# import certificate to keychain
58+
security import $CERTIFICATE_PATH -P "$P12_PASSWORD" -A -t cert -f pkcs12 -k $KEYCHAIN_PATH
59+
security list-keychain -d user -s $KEYCHAIN_PATH
60+
61+
# apply provisioning profile
62+
mkdir -p ~/Library/MobileDevice/Provisioning\ Profiles
63+
cp $PP_PATH ~/Library/MobileDevice/Provisioning\ Profiles
64+
ls -la ~/Library/MobileDevice/Provisioning\ Profiles
65+
66+
- name: Build archive
67+
run: |
68+
xcodebuild -scheme "Synctrain release" \
69+
-archivePath $RUNNER_TEMP/synctrain.xcarchive \
70+
-exportOptionsPlist ./Scripts/ExportOptions.plist \
71+
-sdk iphoneos \
72+
-configuration Release \
73+
-destination generic/platform=iOS \
74+
clean archive
75+
ls -la $RUNNER_TEMP
76+
77+
- name: Export ipa
78+
env:
79+
EXPORT_OPTIONS_PLIST: ${{ secrets.EXPORT_OPTIONS_PLIST }}
80+
run: |
81+
xcodebuild -exportArchive -archivePath $RUNNER_TEMP/synctrain.xcarchive -exportOptionsPlist ./Scripts/ExportOptions.plist -exportPath $RUNNER_TEMP/build
82+
ls -la $RUNNER_TEMP
83+
84+
- name: Upload application
85+
uses: actions/upload-artifact@v4
86+
with:
87+
name: app
88+
path: ${{ runner.temp }}/build/synctrain.ipa
89+
# you can also archive the entire directory
90+
# path: ${{ runner.temp }}/build
91+
retention-days: 3
92+
93+
- name: Generate artifact attestation
94+
uses: actions/attest-build-provenance@v2
95+
with:
96+
subject-path: ${{ runner.temp }}/build/synctrain.ipa
97+
98+
- name: Clean up
99+
run: |
100+
security delete-keychain $KEYCHAIN_PATH

Scripts/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>

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)