Skip to content

Commit 837bb5b

Browse files
committed
chore(ci): build for distribution
1 parent 15f2bcc commit 837bb5b

File tree

8 files changed

+131
-19
lines changed

8 files changed

+131
-19
lines changed

.github/workflows/ci.yml

+3
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ jobs:
1717
test:
1818
name: test
1919
runs-on: ${{ github.repository_owner == 'coder' && 'depot-macos-latest' || 'macos-latest'}}
20+
if: false
2021
steps:
2122
- name: Harden Runner
2223
uses: step-security/harden-runner@cb605e52c26070c328afc4562f0b4ada7618a84e # v2.10.4
@@ -43,6 +44,7 @@ jobs:
4344
format:
4445
name: fmt
4546
runs-on: ${{ github.repository_owner == 'coder' && 'depot-macos-latest' || 'macos-latest'}}
47+
if: false
4648
steps:
4749
- name: Harden Runner
4850
uses: step-security/harden-runner@cb605e52c26070c328afc4562f0b4ada7618a84e # v2.10.4
@@ -69,6 +71,7 @@ jobs:
6971
lint:
7072
name: lint
7173
runs-on: ${{ github.repository_owner == 'coder' && 'depot-macos-latest' || 'macos-latest'}}
74+
if: false
7275
steps:
7376
- name: Harden Runner
7477
uses: step-security/harden-runner@cb605e52c26070c328afc4562f0b4ada7618a84e # v2.10.4

.github/workflows/release.yml

+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
name: release
2+
3+
on:
4+
# TODO: Switch to on `v*` tag push
5+
pull_request:
6+
7+
# permissions:
8+
# # To upload assets to the release
9+
# contents: write
10+
11+
jobs:
12+
build:
13+
runs-on: ${{ github.repository_owner == 'coder' && 'depot-macos-latest' || 'macos-latest'}}
14+
if: ${{ github.repository_owner == 'coder' }}
15+
env:
16+
CERT_PATH: /tmp/apple_cert.p12
17+
APP_PROF_PATH: /tmp/app.provisionprofile
18+
EXT_PROF_PATH: /tmp/ext.provisionprofile
19+
KEYCHAIN_PATH: /tmp/app-signing.keychain-db"
20+
RELEASE_BUILD: true
21+
steps:
22+
- name: Harden Runner
23+
uses: step-security/harden-runner@cb605e52c26070c328afc4562f0b4ada7618a84e # v2.10.4
24+
with:
25+
egress-policy: audit
26+
27+
- name: Checkout
28+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
29+
with:
30+
fetch-depth: 1
31+
32+
- name: Switch XCode Version
33+
uses: maxim-lobanov/setup-xcode@60606e260d2fc5762a71e64e74b2174e8ea3c8bd # v1.6.0
34+
with:
35+
xcode-version: "16.0.0"
36+
37+
# - name: Setup Nix
38+
# uses: ./.github/actions/nix-devshell
39+
40+
- name: Install Cert & Retrieve Provisioning Profiles
41+
run: |
42+
set -euxo pipefail
43+
echo -n "${{ secrets.APPLE_DEVELOPER_ID_PKCS12_B64 }}" | base64 -d -o "$CERT_PATH"
44+
security create-keychain -p "" "$KEYCHAIN_PATH"
45+
security set-keychain-settings -lut 21600 "$KEYCHAIN_PATH"
46+
security unlock-keychain -p "" "$KEYCHAIN_PATH"
47+
security import "$CERT_PATH" -P "${{ secrets.APPLE_DEVELOPER_ID_PKCS12_PASSWORD }}" -A -t cert -f pkcs12 -k "$KEYCHAIN_PATH"
48+
security list-keychain -d user -s "$KEYCHAIN_PATH"
49+
50+
echo -n "${{ secrets.CODER_DESKTOP_APP_PROVISIONPROFILE_B64 }}" | base64 -d -o "$APP_PROF_PATH"
51+
echo -n "${{ secrets.CODER_DESKTOP_EXTENSION_PROVISIONPROFILE_B64 }}" | base64 -d -o "EXT_PROF_PATH"
52+
53+
- name: Build
54+
run: |
55+
make
56+
./scripts/build.sh
57+
58+
- name: Clean Up
59+
if: always()
60+
run: |
61+
security delete-keychain "$KEYCHAIN_PATH"
62+
rm -f /tmp/{apple_cert.p12,app.provisionprofile,ext.provisionprofile,app-signing.keychain-db}

Coder Desktop/Coder Desktop/Views/LoginForm.swift

+6-4
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,9 @@ enum LoginField: Hashable {
194194
case sessionToken
195195
}
196196

197-
#Preview {
198-
LoginForm<PreviewSession>()
199-
.environmentObject(PreviewSession())
200-
}
197+
#if DEBUG
198+
#Preview {
199+
LoginForm<PreviewSession>()
200+
.environmentObject(PreviewSession())
201+
}
202+
#endif

Coder Desktop/Coder Desktop/Views/Settings/NetworkTab.swift

+5-3
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ struct NetworkTab<VPN: VPNService>: View {
99
}
1010
}
1111

12-
#Preview {
13-
NetworkTab<PreviewVPN>()
14-
}
12+
#if DEBUG
13+
#Preview {
14+
NetworkTab<PreviewVPN>()
15+
}
16+
#endif

Coder Desktop/Coder Desktop/Views/VPNMenu.swift

+7-5
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,10 @@ struct VPNMenu<VPN: VPNService, S: Session>: View {
8888
}
8989
}
9090

91-
#Preview {
92-
VPNMenu<PreviewVPN, PreviewSession>().frame(width: 256)
93-
.environmentObject(PreviewVPN())
94-
.environmentObject(PreviewSession())
95-
}
91+
#if DEBUG
92+
#Preview {
93+
VPNMenu<PreviewVPN, PreviewSession>().frame(width: 256)
94+
.environmentObject(PreviewVPN())
95+
.environmentObject(PreviewSession())
96+
}
97+
#endif

Coder Desktop/project.yml

+11-6
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: "Coder Desktop"
22
options:
33
bundleIdPrefix: com.coder
44
deploymentTarget:
5-
macOS: "14.6"
5+
macOS: "14.0"
66
xcodeVersion: "1600"
77
minimumXcodeGenVersion: "2.42.0"
88

@@ -114,7 +114,7 @@ targets:
114114
path: Coder Desktop/Coder_Desktop.entitlements
115115
properties:
116116
com.apple.developer.networking.networkextension:
117-
- packet-tunnel-provider
117+
- packet-tunnel-provider${PTP_SUFFIX}
118118
com.apple.developer.system-extension.install: true
119119
com.apple.security.app-sandbox: true
120120
com.apple.security.files.user-selected.read-only: true
@@ -135,6 +135,8 @@ targets:
135135
INFOPLIST_KEY_NSHumanReadableCopyright: ""
136136
SWIFT_EMIT_LOC_STRINGS: YES
137137
PRODUCT_BUNDLE_IDENTIFIER: "com.coder.Coder-Desktop"
138+
# Populated from environment variables at `xcodebuild` time
139+
PROVISIONING_PROFILE_SPECIFIER: $CODER_APP_PROFILE
138140

139141
# (ThomasK33): Install the application into the /Applications folder
140142
# so that macOS stops complaining about the app being run from an
@@ -146,7 +148,7 @@ targets:
146148
dependencies:
147149
- target: CoderSDK
148150
embed: true
149-
- target: VPNXPC
151+
- target: VPNLib
150152
embed: true
151153
- target: VPN
152154
embed: without-signing # Embed without signing.
@@ -200,7 +202,8 @@ targets:
200202
path: VPN/VPN.entitlements
201203
properties:
202204
com.apple.developer.networking.networkextension:
203-
- packet-tunnel-provider
205+
# PTP_SUFFIX is populated at `xcodegen` time.
206+
- packet-tunnel-provider${PTP_SUFFIX}
204207
com.apple.security.app-sandbox: true
205208
com.apple.security.application-groups:
206209
- $(TeamIdentifierPrefix)com.coder.Coder-Desktop
@@ -215,13 +218,13 @@ targets:
215218
PRODUCT_NAME: "$(PRODUCT_BUNDLE_IDENTIFIER)"
216219
SWIFT_EMIT_LOC_STRINGS: YES
217220
SWIFT_OBJC_BRIDGING_HEADER: "VPN/com_coder_Coder_Desktop_VPN-Bridging-Header.h"
221+
# Populated from environment variables at `xcodebuild` time
222+
PROVISIONING_PROFILE_SPECIFIER: $CODER_EXT_PROFILE
218223
dependencies:
219224
- target: VPNLib
220225
embed: true
221226
- target: CoderSDK
222227
embed: true
223-
- target: VPNXPC
224-
embed: true
225228
- sdk: NetworkExtension.framework
226229

227230
VPNLib:
@@ -281,6 +284,8 @@ targets:
281284
DYLIB_COMPATIBILITY_VERSION: 1
282285
DYLIB_CURRENT_VERSION: 1
283286
DYLIB_INSTALL_NAME_BASE: "@rpath"
287+
CODE_SIGN_IDENTITY: "Apple Development"
288+
CODE_SIGN_STYLE: Automatic
284289
scheme:
285290
testTargets:
286291
- CoderSDKTests

Makefile

+9-1
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,22 @@ XCPROJECT := Coder\ Desktop/Coder\ Desktop.xcodeproj
1111
SCHEME := Coder\ Desktop
1212
SWIFT_VERSION := 6.0
1313

14+
ifdef RELEASE_BUILD
15+
PTP_SUFFIX := -systemextension
16+
else
17+
PTP_SUFFIX := ""
18+
endif
19+
1420
.PHONY: setup
1521
setup: \
1622
$(XCPROJECT) \
1723
$(PROJECT)/VPNLib/vpn.pb.swift
1824

1925
$(XCPROJECT): $(PROJECT)/project.yml
2026
cd $(PROJECT); \
21-
SWIFT_VERSION=$(SWIFT_VERSION) xcodegen
27+
SWIFT_VERSION=$(SWIFT_VERSION) \
28+
PTP_SUFFIX=$(PTP_SUFFIX) \
29+
xcodegen
2230

2331
$(PROJECT)/VPNLib/vpn.pb.swift: $(PROJECT)/VPNLib/vpn.proto
2432
protoc --swift_opt=Visibility=public --swift_out=. 'Coder Desktop/VPNLib/vpn.proto'

scripts/build.sh

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/usr/bin/env bash
2+
3+
set -euxo pipefail
4+
5+
get_uuid() {
6+
strings "$1" | grep -E -o '[0-9a-f]{8}(-[0-9a-f]{4}){3}-[0-9a-f]{12}'
7+
}
8+
9+
# Build Documentatation @ https://developer.apple.com/forums/thread/737894
10+
11+
XCODE_PROVISIONING_PROFILES_DIR="$HOME/Library/Developer/Xcode/UserData/Provisioning Profiles"
12+
CODE_SIGN_IDENTITY="Developer ID Application: Coder Technologies Inc (4399GN35BJ)"
13+
14+
app_prof_id=$(get_uuid "$APP_PROF_PATH")
15+
ext_prof_id=$(get_uuid "$EXT_PROF_PATH")
16+
17+
# Install Provisioning Profiles
18+
cp "$APP_PROF_PATH" "${XCODE_PROVISIONING_PROFILES_DIR}/${app_prof_id}.provisionprofile"
19+
cp "$EXT_PROF_PATH" "${XCODE_PROVISIONING_PROFILES_DIR}/${ext_prof_id}.provisionprofile"
20+
21+
xcodebuild \
22+
-project "Coder Desktop/Coder Desktop.xcodeproj" \
23+
-scheme "Coder Desktop" \
24+
-configuration "Release" \
25+
CODE_SIGN_STYLE=Manual \
26+
CODE_SIGN_IDENTITY="$CODE_SIGN_IDENTITY" \
27+
CODER_APP_PROFILE="$app_prof_id" \
28+
CODER_EXT_PROFILE="$ext_prof_id" | xcpretty

0 commit comments

Comments
 (0)