Skip to content

Commit 5e831ab

Browse files
committed
feat: add homebrew cask release action
Change-Id: I6e76a8fa519f378cda92b4edffa64c17294e01b9 Signed-off-by: Thomas Kosiewski <tk@coder.com>
1 parent d2ed4a9 commit 5e831ab

File tree

6 files changed

+147
-6
lines changed

6 files changed

+147
-6
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,3 +75,5 @@ jobs:
7575
uses: ./.github/actions/nix-devshell
7676

7777
- run: make lint
78+
env:
79+
GH_TOKEN: ${{ github.token }}

.github/workflows/release.yml

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ permissions: {}
88

99
jobs:
1010
build:
11+
name: Build Coder Desktop
1112
runs-on: ${{ github.repository_owner == 'coder' && 'depot-macos-latest' || 'macos-latest'}}
1213
if: ${{ github.repository_owner == 'coder' }}
1314
permissions:
@@ -42,5 +43,29 @@ jobs:
4243
- name: Upload Release Assets
4344
run: gh release upload "$RELEASE_TAG" "$out"/*
4445
env:
45-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
46+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4647
RELEASE_TAG: ${{ github.event.release.tag_name }}
48+
49+
update-cask:
50+
name: Update homebrew-coder cask
51+
runs-on: ${{ github.repository_owner == 'coder' && 'depot-ubuntu-latest' || 'ubuntu-latest'}}
52+
if: ${{ github.repository_owner == 'coder' }}
53+
needs: build
54+
steps:
55+
- name: Checkout
56+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
57+
with:
58+
fetch-depth: 1
59+
persist-credentials: false
60+
61+
- name: Setup Nix
62+
uses: ./.github/actions/nix-devshell
63+
64+
- name: Update homebrew-coder
65+
env:
66+
GH_TOKEN: ${{ secrets.CODERCI_GITHUB_TOKEN }}
67+
RELEASE_TAG: ${{ github.event.release.tag_name }}
68+
run: |
69+
gh auth setup-git
70+
71+
./scripts/update-cask.sh --version "$RELEASE_TAG"

Coder Desktop/Coder Desktop.xctestplan

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
{
2020
"target" : {
2121
"containerPath" : "container:Coder Desktop.xcodeproj",
22-
"identifier" : "AA3B40972D2FC8560099996A",
22+
"identifier" : "5151F2C6964AB885B71A2AE4",
2323
"name" : "CoderSDKTests"
2424
}
2525
},
@@ -28,21 +28,21 @@
2828
"parallelizable" : true,
2929
"target" : {
3030
"containerPath" : "container:Coder Desktop.xcodeproj",
31-
"identifier" : "961679182CFF100E00B2B6DF",
31+
"identifier" : "11762B23091AD2D3C71D48A9",
3232
"name" : "Coder DesktopUITests"
3333
}
3434
},
3535
{
3636
"target" : {
3737
"containerPath" : "container:Coder Desktop.xcodeproj",
38-
"identifier" : "AA3B3DA72D2D23860099996A",
38+
"identifier" : "941FE7A4B097CD66FD100DA4",
3939
"name" : "VPNLibTests"
4040
}
4141
},
4242
{
4343
"target" : {
4444
"containerPath" : "container:Coder Desktop.xcodeproj",
45-
"identifier" : "9616790E2CFF100E00B2B6DF",
45+
"identifier" : "CEF327EDA9B70DF13F678CB3",
4646
"name" : "Coder DesktopTests"
4747
}
4848
}

Coder Desktop/VPN/PacketTunnelProvider.swift

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,16 @@ import VPNLib
66
let CTLIOCGINFO: UInt = 0xC064_4E03
77

88
class PacketTunnelProvider: NEPacketTunnelProvider, @unchecked Sendable {
9-
private let logger = Logger(subsystem: Bundle.main.bundleIdentifier!, category: "provider")
9+
// Debugging instructions and best practices: https://developer.apple.com/forums/thread/725805
10+
static let logger = Logger(subsystem: Bundle.main.bundleIdentifier!, category: "packet-tunnel")
11+
12+
override init() {
13+
self.logger = Self.logger
14+
logger.log(level: .debug, "first light")
15+
super.init()
16+
}
17+
18+
private let logger: Logger
1019
private var manager: Manager?
1120
// a `tunnelRemoteAddress` is required, but not currently used.
1221
private var currentSettings: NEPacketTunnelNetworkSettings = .init(tunnelRemoteAddress: "127.0.0.1")

Coder Desktop/VPN/main.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ xpcListener.delegate = globalXPCListenerDelegate
5353
xpcListener.resume()
5454

5555
autoreleasepool {
56+
let logger = PacketTunnelProvider.logger
57+
logger.log(level: .debug, "first light")
5658
NEProvider.startSystemExtensionMode()
5759
}
5860

scripts/update-cask.sh

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
usage() {
5+
echo "Usage: $0 [--version <version>]"
6+
echo " --version <version> Set VERSION variable to fetch and generate the cask file for"
7+
echo " -h, --help Display this help message"
8+
}
9+
10+
VERSION=""
11+
12+
# Parse command line arguments
13+
while [[ "$#" -gt 0 ]]; do
14+
case $1 in
15+
--version)
16+
VERSION="$2"
17+
shift 2
18+
;;
19+
-h | --help)
20+
usage
21+
exit 0
22+
;;
23+
*)
24+
echo "Unknown parameter passed: $1"
25+
usage
26+
exit 1
27+
;;
28+
esac
29+
done
30+
31+
# Assert version is not empty and starts with v
32+
[ -z "$VERSION" ] && {
33+
echo "Error: VERSION cannot be empty"
34+
exit 1
35+
}
36+
[[ "$VERSION" =~ ^v ]] || {
37+
echo "Error: VERSION must start with 'v'"
38+
exit 1
39+
}
40+
41+
set -x
42+
43+
# Download the Coder Desktop dmg
44+
GH_RELEASE_FOLDER=$(mktemp -d)
45+
46+
gh release download "$VERSION" \
47+
--repo coder/coder-desktop-macos \
48+
--dir "$GH_RELEASE_FOLDER" \
49+
--pattern 'Coder.Desktop.dmg'
50+
51+
HASH=$(shasum -a 256 "$GH_RELEASE_FOLDER"/Coder.Desktop.dmg | awk '{print $1}' | tr -d '\n')
52+
53+
# Check out the homebrew tap repo
54+
TAP_CHECHOUT_FOLDER=$(mktemp -d)
55+
56+
gh repo clone "coder/homebrew-coder" "$TAP_CHECHOUT_FOLDER"
57+
58+
cd "$TAP_CHECHOUT_FOLDER"
59+
60+
BREW_BRANCH="auto-release/desktop-$VERSION"
61+
62+
# Check if a PR already exists.
63+
pr_count="$(gh pr list --search "head:$BREW_BRANCH" --json id,closed | jq -r ".[] | select(.closed == false) | .id" | wc -l)"
64+
if [[ "$pr_count" -gt 0 ]]; then
65+
echo "Bailing out as PR already exists" 2>&1
66+
exit 0
67+
fi
68+
69+
git checkout -b "$BREW_BRANCH"
70+
71+
# If this is a beta or pre-release version, append
72+
# and experimental suffix to the cask.
73+
SUFFIX=""
74+
if [[ $VERSION =~ ^v?[0-9]+\.[0-9]+\.[0-9]+-.*$ ]]; then
75+
SUFFIX="-experimental"
76+
fi
77+
78+
# Overwrite the coder-desktop cask
79+
cat >"$TAP_CHECHOUT_FOLDER"/Formula/coder-desktop${SUFFIX}.rb <<EOF
80+
cask "coder-desktop${SUFFIX}" do
81+
version "${VERSION}"
82+
sha256 "${HASH}"
83+
84+
url "https://github.com/coder/coder-desktop-macos/releases/download/#{version}/Coder.Desktop.dmg"
85+
name "Coder Desktop"
86+
desc "Coder Desktop client"
87+
homepage "https://github.com/coder/coder-desktop-macos"
88+
89+
depends_on macos: ">= :sonoma"
90+
91+
app "Coder Desktop.app"
92+
end
93+
EOF
94+
95+
git add .
96+
git commit -m "Coder Desktop $VERSION"
97+
git push -u origin -f "$BREW_BRANCH"
98+
99+
# Create a PR
100+
gh pr create \
101+
--base master --head "$BREW_BRANCH" \
102+
--title "Coder Desktop $VERSION" \
103+
--body "This automatic PR was triggered by the release of Coder Desktop $VERSION"

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