From c96b1d26f17bf124b29fb5f61fcd1d99beaf5ba6 Mon Sep 17 00:00:00 2001 From: Dean Sheather Date: Tue, 8 Mar 2022 19:17:39 +0000 Subject: [PATCH] chore: automate updating formulae --- ci/update.sh | 28 ++++++++++++++++++++++++++++ coder-cli-nightly.rb | 10 +++++----- coder-cli.rb | 10 +++++----- 3 files changed, 38 insertions(+), 10 deletions(-) create mode 100755 ci/update.sh diff --git a/ci/update.sh b/ci/update.sh new file mode 100755 index 0000000..56a923c --- /dev/null +++ b/ci/update.sh @@ -0,0 +1,28 @@ +#!/bin/bash + +# Updates both the coder-cli and coder-cli-nightly formulae to have the given +# values. +# ./update.sh "" "" "" + +set -euo pipefail +cd "$(dirname "$0")" + +version="$1" +darwin_sha="$(echo "$2" | tr "[:upper:]" "[:lower:]")" +linux_sha="$(echo "$3" | tr "[:upper:]" "[:lower:]")" + +# Get the old version to use in our find/replace. +old_version="$(sed -n "s/.*version \"\(.*\)\".*/\1/p" ../coder-cli.rb)" +if [[ "$old_version" == "" ]]; then + echo "Could not determine the old version of the formula..." >&2 + exit 1 +fi + +# Replace version +sed -i "s/${old_version//./\.}/${version//./\.}/g" ../coder-cli{,-nightly}.rb + +# Darwin amd64 SHA256. This only selects the first match +sed -zi "s/sha256 \"[a-f0-9]*\"/sha256 \"$darwin_sha\"/1" ../coder-cli{,-nightly}.rb + +# Linux amd64 SHA256. This only selects the second match +sed -zi "s/sha256 \"[a-f0-9]*\"/sha256 \"$linux_sha\"/2" ../coder-cli{,-nightly}.rb diff --git a/coder-cli-nightly.rb b/coder-cli-nightly.rb index ef8c221..f93d3c3 100644 --- a/coder-cli-nightly.rb +++ b/coder-cli-nightly.rb @@ -1,14 +1,14 @@ class CoderCliNightly < Formula desc "Command-line tool for the Coder remote development platform, nightly release channel" homepage "https://github.com/cdr/coder-cli" - version "1.27.0" + version "1.28.2" if OS.mac? - url "https://github.com/cdr/coder-cli/releases/download/v1.27.0/coder-cli-darwin-amd64.zip" - sha256 "13a17e97de04c4207920b1830e2aea9e8f8f0a4f0a8362c91fc35d5d218246e8" + url "https://github.com/cdr/coder-cli/releases/download/v1.28.2/coder-cli-darwin-amd64.zip" + sha256 "b0fbf3486d63892ffe718f12b6b418c49eecebdd34a9c713b53c1cf81385dd57" else - url "https://github.com/cdr/coder-cli/releases/download/v1.27.0/coder-cli-linux-amd64.tar.gz" - sha256 "1c79598e5dd29f0ba724a77d482389dfa629825905254ab31d7fc349bbd8076b" + url "https://github.com/cdr/coder-cli/releases/download/v1.28.2/coder-cli-linux-amd64.tar.gz" + sha256 "a3472dc7968affcbd9bf03fd14304eff365c0dad5d8ed732bd98744a2de880f6" end def install diff --git a/coder-cli.rb b/coder-cli.rb index aa7edfa..fcbf676 100644 --- a/coder-cli.rb +++ b/coder-cli.rb @@ -1,14 +1,14 @@ class CoderCli < Formula desc "Command-line tool for the Coder remote development platform" homepage "https://github.com/cdr/coder-cli" - version "1.27.0" + version "1.28.2" if OS.mac? - url "https://github.com/cdr/coder-cli/releases/download/v1.27.0/coder-cli-darwin-amd64.zip" - sha256 "13a17e97de04c4207920b1830e2aea9e8f8f0a4f0a8362c91fc35d5d218246e8" + url "https://github.com/cdr/coder-cli/releases/download/v1.28.2/coder-cli-darwin-amd64.zip" + sha256 "b0fbf3486d63892ffe718f12b6b418c49eecebdd34a9c713b53c1cf81385dd57" else - url "https://github.com/cdr/coder-cli/releases/download/v1.27.0/coder-cli-linux-amd64.tar.gz" - sha256 "1c79598e5dd29f0ba724a77d482389dfa629825905254ab31d7fc349bbd8076b" + url "https://github.com/cdr/coder-cli/releases/download/v1.28.2/coder-cli-linux-amd64.tar.gz" + sha256 "a3472dc7968affcbd9bf03fd14304eff365c0dad5d8ed732bd98744a2de880f6" end def install