Skip to content

Commit d4f83dc

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

File tree

3 files changed

+39
-18
lines changed

3 files changed

+39
-18
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: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,26 @@ 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+
cmd_path="./vpn/dylib/lib.go"
152+
build_args+=("-buildmode=c-shared")
153+
SDKROOT="$(xcrun --sdk macosx --show-sdk-path)"
154+
export SDKROOT
155+
bin_ident="com.coder.vpn"
156+
157+
plist_file=$(mktemp)
158+
trap 'rm -f "$plist_file"' EXIT
159+
# CFBundleShortVersionString must be in the format /[0-9]+.[0-9]+.[0-9]+/
160+
# CFBundleVersion can be in any format
161+
BUNDLE_NAME="CoderVPN" BUNDLE_IDENTIFIER="$bin_ident" VERSION_STRING="$version" SHORT_VERSION_STRING=$(echo "$version" | grep -oE '^[0-9]+\.[0-9]+\.[0-9]+') \
162+
execrelative envsubst <"$(realpath ./scripts/info.plist.tmpl)" >"$plist_file"
163+
# ldflags+=("-extldflags '-sectcreate __TEXT __info_plist $plist_file'")
164+
fi
145165
build_args+=(-ldflags "${ldflags[*]}")
146166

147167
# Disable optimizations if building a binary for debuggers.
@@ -176,19 +196,6 @@ if [[ "$agpl" == 1 ]]; then
176196
cmd_path="./cmd/coder"
177197
fi
178198

179-
cgo=0
180-
if [[ "$dylib" == 1 ]]; then
181-
if [[ "$os" != "darwin" ]]; then
182-
error "dylib builds are not supported on $os"
183-
fi
184-
cgo=1
185-
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"
190-
fi
191-
192199
goexp=""
193200
if [[ "$boringcrypto" == 1 ]]; then
194201
cgo=1

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)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy