Skip to content

Commit 47d0464

Browse files
ci: build for distribution (#37)
Signed-off-by: Thomas Kosiewski <[email protected]> Co-authored-by: Thomas Kosiewski <[email protected]>
1 parent 64b8d52 commit 47d0464

File tree

18 files changed

+9955
-81
lines changed

18 files changed

+9955
-81
lines changed

Diff for: .env

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Build a release locally using: op run --env-file="./.env" -- make release
2+
APPLE_CERT="op://Apple/Apple DeveloperID PKCS12 base64/notesPlain"
3+
CERT_PASSWORD="op://Apple/DeveloperID p12 password/password"
4+
5+
APPLE_ID="op://Apple/3apcadvvcojjbpxnd7m5fgh5wm/username"
6+
APPLE_ID_PASSWORD="op://Apple/3apcadvvcojjbpxnd7m5fgh5wm/password"
7+
8+
APP_PROF="op://Apple/Provisioning Profiles/profiles/application_base64"
9+
EXT_PROF="op://Apple/Provisioning Profiles/profiles/extension_base64"

Diff for: .gitattributes

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
nix/create-dmg/package-lock.json -diff

Diff for: .github/actions/nix-devshell/action.yaml

-3
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,5 @@ runs:
66
- name: Setup Nix
77
uses: DeterminateSystems/nix-installer-action@e50d5f73bfe71c2dd0aa4218de8f4afa59f8f81d # v16
88

9-
- name: Setup GHA Nix cache
10-
uses: DeterminateSystems/magic-nix-cache-action@6221693898146dc97e38ad0e013488a16477a4c4 # v9
11-
129
- name: Enter devshell
1310
uses: nicknovitski/nix-develop@9be7cfb4b10451d3390a75dc18ad0465bed4932a # v1.2.1

Diff for: .github/dependabot.yaml

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: "github-actions"
4+
directory: "/"
5+
schedule:
6+
interval: "weekly"
7+
time: "06:00"
8+
timezone: "America/Chicago"
9+
labels: []
10+
commit-message:
11+
prefix: "ci"
12+
groups:
13+
github-actions:
14+
patterns:
15+
- "*"

Diff for: .github/workflows/ci.yml

+9-15
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,13 @@ jobs:
1818
name: test
1919
runs-on: ${{ github.repository_owner == 'coder' && 'depot-macos-latest' || 'macos-latest'}}
2020
steps:
21-
- name: Harden Runner
22-
uses: step-security/harden-runner@cb605e52c26070c328afc4562f0b4ada7618a84e # v2.10.4
23-
with:
24-
egress-policy: audit
25-
2621
- name: Checkout
2722
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
2823
with:
2924
fetch-depth: 1
25+
persist-credentials: false
26+
27+
- run: git fetch --tags
3028

3129
- name: Switch XCode Version
3230
uses: maxim-lobanov/setup-xcode@60606e260d2fc5762a71e64e74b2174e8ea3c8bd # v1.6.0
@@ -44,15 +42,13 @@ jobs:
4442
name: fmt
4543
runs-on: ${{ github.repository_owner == 'coder' && 'depot-macos-latest' || 'macos-latest'}}
4644
steps:
47-
- name: Harden Runner
48-
uses: step-security/harden-runner@cb605e52c26070c328afc4562f0b4ada7618a84e # v2.10.4
49-
with:
50-
egress-policy: audit
51-
5245
- name: Checkout
5346
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
5447
with:
5548
fetch-depth: 1
49+
persist-credentials: false
50+
51+
- run: git fetch --tags
5652

5753
- name: Switch XCode Version
5854
uses: maxim-lobanov/setup-xcode@60606e260d2fc5762a71e64e74b2174e8ea3c8bd # v1.6.0
@@ -70,15 +66,13 @@ jobs:
7066
name: lint
7167
runs-on: ${{ github.repository_owner == 'coder' && 'depot-macos-latest' || 'macos-latest'}}
7268
steps:
73-
- name: Harden Runner
74-
uses: step-security/harden-runner@cb605e52c26070c328afc4562f0b4ada7618a84e # v2.10.4
75-
with:
76-
egress-policy: audit
77-
7869
- name: Checkout
7970
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
8071
with:
8172
fetch-depth: 1
73+
persist-credentials: false
74+
75+
- run: git fetch --tags
8276

8377
- name: Setup Nix
8478
uses: ./.github/actions/nix-devshell

Diff for: .github/workflows/release.yml

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: release
2+
3+
on:
4+
release:
5+
types: [published]
6+
7+
permissions: {}
8+
9+
jobs:
10+
build:
11+
runs-on: ${{ github.repository_owner == 'coder' && 'depot-macos-latest' || 'macos-latest'}}
12+
if: ${{ github.repository_owner == 'coder' }}
13+
permissions:
14+
# To upload assets to the release
15+
contents: write
16+
steps:
17+
- name: Checkout
18+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
19+
with:
20+
fetch-depth: 1
21+
persist-credentials: false
22+
23+
- run: git fetch --tags
24+
25+
- name: Switch XCode Version
26+
uses: maxim-lobanov/setup-xcode@60606e260d2fc5762a71e64e74b2174e8ea3c8bd # v1.6.0
27+
with:
28+
xcode-version: "16.0.0"
29+
30+
- name: Setup Nix
31+
uses: ./.github/actions/nix-devshell
32+
33+
- name: Build
34+
env:
35+
APPLE_CERT: ${{ secrets.APPLE_DEVELOPER_ID_PKCS12_B64 }}
36+
APPLE_ID: ${{ secrets.APPLE_NOTARYTOOL_USERNAME }}
37+
APPLE_ID_PASSWORD: ${{ secrets.APPLE_NOTARYTOOL_PASSWORD }}
38+
APP_PROF: ${{ secrets.CODER_DESKTOP_APP_PROVISIONPROFILE_B64 }}
39+
CERT_PASSWORD: ${{ secrets.APPLE_DEVELOPER_ID_PKCS12_PASSWORD }}
40+
EXT_PROF: ${{ secrets.CODER_DESKTOP_EXTENSION_PROVISIONPROFILE_B64 }}
41+
run: make release
42+
43+
- name: Upload Release Assets
44+
run: gh release upload "$RELEASE_TAG" "$out"
45+
env:
46+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
47+
RELEASE_TAG: ${{ github.event.release.tag_name }}

Diff for: .gitignore

+7
Original file line numberDiff line numberDiff line change
@@ -295,3 +295,10 @@ xcuserdata
295295
buildServer.json
296296

297297
# End of https://www.toptal.com/developers/gitignore/api/xcode,jetbrains,macos,direnv,swift,swiftpm,objective-c
298+
299+
*.entitlements
300+
app-signing.keychain-db
301+
release/
302+
303+
# marker files
304+
.fl5C1A396C

Diff for: Coder Desktop/Coder Desktop/Coder_Desktop.entitlements

-16
This file was deleted.

Diff for: 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

Diff for: 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

Diff for: Coder Desktop/Coder Desktop/Views/VPNMenu.swift

+7-5
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,10 @@ func openSystemExtensionSettings() {
101101
NSWorkspace.shared.open(URL(string: "x-apple.systempreferences:com.apple.ExtensionsPreferences?extensionPointIdentifier=com.apple.system_extension.network_extension.extension-point")!)
102102
}
103103

104-
#Preview {
105-
VPNMenu<PreviewVPN, PreviewSession>().frame(width: 256)
106-
.environmentObject(PreviewVPN())
107-
.environmentObject(PreviewSession())
108-
}
104+
#if DEBUG
105+
#Preview {
106+
VPNMenu<PreviewVPN, PreviewSession>().frame(width: 256)
107+
.environmentObject(PreviewVPN())
108+
.environmentObject(PreviewSession())
109+
}
110+
#endif

Diff for: Coder Desktop/VPN/Manager.swift

+2-1
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,13 @@ actor Manager {
4848
}
4949

5050
// HACK: The downloaded dylib may be quarantined, but we've validated it's signature
51-
// so it's safe to execute. However, this SE must be sandboxed, so we defer to the app.
51+
// so it's safe to execute. However, the SE must be sandboxed, so we defer to the app.
5252
try await removeQuarantine(dest)
5353

5454
do {
5555
try tunnelHandle = TunnelHandle(dylibPath: dest)
5656
} catch {
57+
logger.error("couldn't open dylib \(error, privacy: .public)")
5758
throw .tunnelSetup(error)
5859
}
5960
speaker = await Speaker<Vpn_ManagerMessage, Vpn_TunnelMessage>(

Diff for: Coder Desktop/VPN/VPN.entitlements

-20
This file was deleted.

Diff for: Coder Desktop/project.yml

+14-7
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ options:
88

99
settings:
1010
base:
11-
MARKETING_VERSION: "1.0" # Sets the version number.
12-
CURRENT_PROJECT_VERSION: "1" # Sets the build number.
11+
MARKETING_VERSION: ${MARKETING_VERSION} # Sets the version number.
12+
CURRENT_PROJECT_VERSION: ${CURRENT_PROJECT_VERSION} # Sets the build number.
1313

1414
ALWAYS_SEARCH_USER_PATHS: NO
1515
ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS: YES
@@ -114,14 +114,15 @@ 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.application-groups:
120120
- $(TeamIdentifierPrefix)com.coder.Coder-Desktop
121121
settings:
122122
base:
123123
ASSETCATALOG_COMPILER_APPICON_NAME: AppIcon # Sets the app icon to "AppIcon".
124124
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME: AccentColor
125+
# `CODE_SIGN_*` options are overriden during a release build
125126
CODE_SIGN_IDENTITY: "Apple Development"
126127
CODE_SIGN_STYLE: Automatic
127128
COMBINE_HIDPI_IMAGES: YES
@@ -132,6 +133,8 @@ targets:
132133
INFOPLIST_KEY_NSHumanReadableCopyright: ""
133134
SWIFT_EMIT_LOC_STRINGS: YES
134135
PRODUCT_BUNDLE_IDENTIFIER: "com.coder.Coder-Desktop"
136+
# Empty outside of release builds
137+
PROVISIONING_PROFILE_SPECIFIER: ${APP_PROVISIONING_PROFILE_ID}
135138

136139
# (ThomasK33): Install the application into the /Applications folder
137140
# so that macOS stops complaining about the app being run from an
@@ -197,7 +200,8 @@ targets:
197200
path: VPN/VPN.entitlements
198201
properties:
199202
com.apple.developer.networking.networkextension:
200-
- packet-tunnel-provider
203+
# PTP_SUFFIX is populated at `xcodegen` time.
204+
- packet-tunnel-provider${PTP_SUFFIX}
201205
com.apple.security.app-sandbox: true
202206
com.apple.security.application-groups:
203207
- $(TeamIdentifierPrefix)com.coder.Coder-Desktop
@@ -212,6 +216,11 @@ targets:
212216
PRODUCT_NAME: "$(PRODUCT_BUNDLE_IDENTIFIER)"
213217
SWIFT_EMIT_LOC_STRINGS: YES
214218
SWIFT_OBJC_BRIDGING_HEADER: "VPN/com_coder_Coder_Desktop_VPN-Bridging-Header.h"
219+
# `CODE_SIGN_*` are overriden during a release build
220+
CODE_SIGN_IDENTITY: "Apple Development"
221+
CODE_SIGN_STYLE: Automatic
222+
# Empty outside of release builds
223+
PROVISIONING_PROFILE_SPECIFIER: ${EXT_PROVISIONING_PROFILE_ID}
215224
dependencies:
216225
- target: VPNLib
217226
embed: true
@@ -232,8 +241,6 @@ targets:
232241
DYLIB_COMPATIBILITY_VERSION: 1
233242
DYLIB_CURRENT_VERSION: 1
234243
DYLIB_INSTALL_NAME_BASE: "@rpath"
235-
CODE_SIGN_IDENTITY: "Apple Development"
236-
CODE_SIGN_STYLE: Automatic
237244
LD_RUNPATH_SEARCH_PATHS:
238245
- "@executable_path/../Frameworks"
239246
- "@loader_path/Frameworks"
@@ -294,4 +301,4 @@ targets:
294301
settings:
295302
base:
296303
TEST_HOST: "$(BUILT_PRODUCTS_DIR)/Coder Desktop.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/Coder Desktop"
297-
PRODUCT_BUNDLE_IDENTIFIER: com.coder.Coder-Desktop.CoderSDKTests
304+
PRODUCT_BUNDLE_IDENTIFIER: com.coder.Coder-Desktop.CoderSDKTests

0 commit comments

Comments
 (0)