@@ -4,12 +4,12 @@ set -euo pipefail
44usage () {
55 echo " Usage: $0 [--version <version>] [--assignee <github handle>]"
66 echo " --version <version> Set the VERSION variable to fetch and generate the cask file for"
7- echo " --assignee <github handle> Set the ASSIGNE variable to assign the PR to (optional)"
7+ echo " --assignee <github handle> Set the ASSIGNEE variable to assign the PR to (optional)"
88 echo " -h, --help Display this help message"
99}
1010
1111VERSION=" "
12- ASSIGNE =" "
12+ ASSIGNEE =" "
1313
1414# Parse command line arguments
1515while [[ " $# " -gt 0 ]]; do
@@ -19,7 +19,7 @@ while [[ "$#" -gt 0 ]]; do
1919 shift 2
2020 ;;
2121 --assignee)
22- ASSIGNE =" $2 "
22+ ASSIGNEE =" $2 "
2323 shift 2
2424 ;;
2525 -h | --help)
3939 echo " Error: VERSION cannot be empty"
4040 exit 1
4141}
42- [[ " $VERSION " =~ ^v || " $VERSION " == " preview " ]] || {
42+ [[ " $VERSION " =~ ^v ]] || {
4343 echo " Error: VERSION must start with a 'v'"
4444 exit 1
4545}
@@ -54,55 +54,39 @@ gh release download "$VERSION" \
5454
5555HASH=$( shasum -a 256 " $GH_RELEASE_FOLDER " /Coder-Desktop.pkg | awk ' {print $1}' | tr -d ' \n' )
5656
57- IS_PREVIEW=false
58- if [[ " $VERSION " == " preview" ]]; then
59- IS_PREVIEW=true
60- VERSION=$( make ' print-CURRENT_PROJECT_VERSION' | sed ' s/CURRENT_PROJECT_VERSION=//g' )
61- fi
62-
6357# Check out the homebrew tap repo
64- TAP_CHECHOUT_FOLDER =$( mktemp -d)
58+ TAP_CHECKOUT_FOLDER =$( mktemp -d)
6559
66- gh repo clone " coder/homebrew-coder" " $TAP_CHECHOUT_FOLDER "
60+ gh repo clone " coder/homebrew-coder" " $TAP_CHECKOUT_FOLDER "
6761
68- cd " $TAP_CHECHOUT_FOLDER "
62+ cd " $TAP_CHECKOUT_FOLDER "
6963
7064BREW_BRANCH=" auto-release/desktop-$VERSION "
7165
7266# Check if a PR already exists.
7367# Continue on a main branch release, as the sha256 will change.
7468pr_count=" $( gh pr list --search " head:$BREW_BRANCH " --json id,closed | jq -r " .[] | select(.closed == false) | .id" | wc -l) "
75- if [[ " $pr_count " -gt 0 && " $IS_PREVIEW " == false ]]; then
69+ if [[ " $pr_count " -gt 0 ]]; then
7670 echo " Bailing out as PR already exists" 2>&1
7771 exit 0
7872fi
7973
8074git checkout -b " $BREW_BRANCH "
8175
82- # If this is a main branch build, append a preview suffix to the cask.
83- SUFFIX=" "
84- CONFLICTS_WITH=" coder-desktop-preview"
85- TAG=$VERSION
86- if [[ " $IS_PREVIEW " == true ]]; then
87- SUFFIX=" -preview"
88- CONFLICTS_WITH=" coder-desktop"
89- TAG=" preview"
90- fi
91-
92- mkdir -p " $TAP_CHECHOUT_FOLDER " /Casks
76+ mkdir -p " $TAP_CHECKOUT_FOLDER " /Casks
9377
9478# Overwrite the cask file
95- cat > " $TAP_CHECHOUT_FOLDER " /Casks/coder-desktop${SUFFIX} .rb << EOF
96- cask "coder-desktop${SUFFIX} " do
79+ cat > " $TAP_CHECKOUT_FOLDER " /Casks/coder-desktop.rb << EOF
80+ cask "coder-desktop" do
9781 version "${VERSION# v} "
98- sha256 $( [ " $IS_PREVIEW " = true ] && echo " :no_check " || echo " \" $ {HASH}\" " )
82+ sha256 " $ {HASH}"
9983
100- url "https://github.com/coder/coder-desktop-macos/releases/download/$( [ " $IS_PREVIEW " = true ] && echo " ${TAG} " || echo " v#{version}" ) /Coder-Desktop.pkg"
84+ url "https://github.com/coder/coder-desktop-macos/releases/download/v#{version}/Coder-Desktop.pkg"
10185 name "Coder Desktop"
10286 desc "Native desktop client for Coder"
10387 homepage "https://github.com/coder/coder-desktop-macos"
88+ auto_updates true
10489
105- conflicts_with cask: "coder/coder/${CONFLICTS_WITH} "
10690 depends_on macos: ">= :sonoma"
10791
10892 pkg "Coder-Desktop.pkg"
@@ -132,5 +116,5 @@ if [[ "$pr_count" -eq 0 ]]; then
132116 --base master --head " $BREW_BRANCH " \
133117 --title " Coder Desktop $VERSION " \
134118 --body " This automatic PR was triggered by the release of Coder Desktop $VERSION " \
135- ${ASSIGNE : + --assignee " $ASSIGNE " --reviewer " $ASSIGNE " }
119+ ${ASSIGNEE : + --assignee " $ASSIGNEE " --reviewer " $ASSIGNEE " }
136120fi
0 commit comments