Skip to content

Commit 95b31a0

Browse files
committed
chore: sign darwin binaries & dylib with an Info.plist
1 parent dcf5153 commit 95b31a0

File tree

3 files changed

+38
-15
lines changed

3 files changed

+38
-15
lines changed

.github/workflows/ci.yaml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -919,7 +919,7 @@ jobs:
919919
uses: ./.github/actions/setup-go
920920

921921
- name: Install rcodesign
922-
if: ${{ github.repository_owner == 'coder' && github.ref == 'refs/heads/main' }}
922+
# if: ${{ github.repository_owner == 'coder' && github.ref == 'refs/heads/main' }}
923923
run: |
924924
set -euo pipefail
925925
wget -O /tmp/rcodesign.tar.gz https://github.com/indygreg/apple-platform-rs/releases/download/apple-codesign%2F0.22.0/apple-codesign-0.22.0-macos-universal.tar.gz
@@ -930,7 +930,7 @@ jobs:
930930
rm /tmp/rcodesign.tar.gz
931931
932932
- name: Setup Apple Developer certificate and API key
933-
if: ${{ github.repository_owner == 'coder' && github.ref == 'refs/heads/main' }}
933+
# if: ${{ github.repository_owner == 'coder' && github.ref == 'refs/heads/main' }}
934934
run: |
935935
set -euo pipefail
936936
touch /tmp/{apple_cert.p12,apple_cert_password.txt,apple_apikey.p8}
@@ -951,12 +951,12 @@ jobs:
951951
make gen/mark-fresh
952952
make build/coder-dylib
953953
env:
954-
CODER_SIGN_DARWIN: ${{ github.ref == 'refs/heads/main' && '1' || '0' }}
954+
CODER_SIGN_DARWIN: 1
955955
AC_CERTIFICATE_FILE: /tmp/apple_cert.p12
956956
AC_CERTIFICATE_PASSWORD_FILE: /tmp/apple_cert_password.txt
957957

958958
- name: Upload build artifacts
959-
if: ${{ github.repository_owner == 'coder' && github.ref == 'refs/heads/main' }}
959+
# if: ${{ github.repository_owner == 'coder' && github.ref == 'refs/heads/main' }}
960960
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3
961961
with:
962962
name: dylibs
@@ -966,7 +966,7 @@ jobs:
966966
retention-days: 7
967967

968968
- name: Delete Apple Developer certificate and API key
969-
if: ${{ github.repository_owner == 'coder' && github.ref == 'refs/heads/main' }}
969+
# if: ${{ github.repository_owner == 'coder' && github.ref == 'refs/heads/main' }}
970970
run: rm -f /tmp/{apple_cert.p12,apple_cert_password.txt,apple_apikey.p8}
971971

972972
build:

scripts/build_go.sh

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,25 @@ if [[ "$agpl" == 1 ]]; then
142142
# a flag to control AGPL vs. enterprise behavior.
143143
ldflags+=(-X "'github.com/coder/coder/v2/buildinfo.agpl=true'")
144144
fi
145+
cgo=0
146+
if [[ "$dylib" == 1 ]]; then
147+
if [[ "$os" != "darwin" ]]; then
148+
error "dylib builds are not supported on $os"
149+
fi
150+
cgo=1
151+
build_args+=("-buildmode=c-shared")
152+
SDKROOT="$(xcrun --sdk macosx --show-sdk-path)"
153+
export SDKROOT
154+
bin_ident="com.coder.vpn"
155+
156+
plist_file=$(mktemp)
157+
trap 'rm -f "$plist_file"' EXIT
158+
# CFBundleShortVersionString must be in the format /[0-9]+.[0-9]+.[0-9]+/
159+
# CFBundleVersion can be in any format
160+
BUNDLE_NAME="CoderVPN" BUNDLE_IDENTIFIER="$bin_ident" VERSION_STRING="$version" SHORT_VERSION_STRING=$(echo "$version" | grep -oE '^[0-9]+\.[0-9]+\.[0-9]+') \
161+
execrelative envsubst <"$(realpath ./scripts/info.plist.tmpl)" >"$plist_file"
162+
ldflags+=("-extldflags '-sectcreate __TEXT __info_plist $plist_file'")
163+
fi
145164
build_args+=(-ldflags "${ldflags[*]}")
146165

147166
# Disable optimizations if building a binary for debuggers.
@@ -175,18 +194,8 @@ cmd_path="./enterprise/cmd/coder"
175194
if [[ "$agpl" == 1 ]]; then
176195
cmd_path="./cmd/coder"
177196
fi
178-
179-
cgo=0
180197
if [[ "$dylib" == 1 ]]; then
181-
if [[ "$os" != "darwin" ]]; then
182-
error "dylib builds are not supported on $os"
183-
fi
184-
cgo=1
185198
cmd_path="./vpn/dylib/lib.go"
186-
build_args+=("-buildmode=c-shared")
187-
SDKROOT="$(xcrun --sdk macosx --show-sdk-path)"
188-
export SDKROOT
189-
bin_ident="com.coder.vpn"
190199
fi
191200

192201
goexp=""

scripts/info.plist.tmpl

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
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>CFBundleName</key>
6+
<string>${BUNDLE_NAME}</string>
7+
<key>CFBundleIdentifier</key>
8+
<string>${BUNDLE_IDENTIFIER}</string>
9+
<key>CFBundleVersion</key>
10+
<string>${VERSION_STRING}</string>
11+
<key>CFBundleShortVersionString</key>
12+
<string>${SHORT_VERSION_STRING}</string>
13+
</dict>
14+
</plist>

0 commit comments

Comments
 (0)