diff --git a/Makefile b/Makefile index 86733f49..277dac7d 100644 --- a/Makefile +++ b/Makefile @@ -88,17 +88,17 @@ ifndef GH $(error please install github-cli) endif - if [ ! -d ${cliHomebrewDir} ]; then \ - @echo "homebrew-dnote not found locally. did you clone it?"; \ - @exit 1; \ - fi - @echo "==> releasing cli" @${currentDir}/scripts/release.sh cli $(version) ${cliOutputDir} +.PHONY: release-cli - @echo "===> releasing on Homebrew" - @(cd "${cliHomebrewDir}" && \ - ./release.sh "$(version)" "${cliOutputDir}/dnote_$(version)_darwin_amd64.tar.gz") +release-cli-homebrew: clean build-cli +ifndef version + $(error version is required. Usage: make version=0.1.0 release-cli) +endif + + @echo "==> releasing cli on Homebrew" + @${currentDir}/scripts/cli/release-homebrew.sh $(version) ${cliOutputDir} .PHONY: release-cli release-server: diff --git a/scripts/cli/release-homebrew.sh b/scripts/cli/release-homebrew.sh new file mode 100755 index 00000000..bf02e4d8 --- /dev/null +++ b/scripts/cli/release-homebrew.sh @@ -0,0 +1,48 @@ +#!/usr/bin/env bash +set -eux + +currentDir=$(dirname "${BASH_SOURCE[0]}") +cliHomebrewDir=${currentDir}/../../homebrew-dnote + +if [ ! -d "$cliHomebrewDir" ]; then + echo "homebrew-dnote not found locally. Cloning." + git clone git@github.com:dnote/homebrew-dnote.git "$cliHomebrewDir" +fi + +version=$1 +tarball=$2 + +echo "version: $version" +echo "tarball: $tarball" + +sha=$(shasum -a 256 "$tarball" | cut -d ' ' -f 1) + +pushd "$cliHomebrewDir" + +echo "pulling latest dnote-homebrew repo" +git checkout master +git pull origin master + +cat > ./Formula/dnote.rb << EOF +class Dnote < Formula + desc "A simple command line notebook for programmers" + homepage "https://www.getdnote.com" + url "https://github.com/dnote/dnote/releases/download/cli-v${version}/dnote_${version}_darwin_amd64.tar.gz" + version "${version}" + sha256 "${sha}" + + def install + bin.install "dnote" + end + + test do + system "#{bin}/dnote", "version" + end +end +EOF + +git add . +git commit --author="Monomax Bot " -m "Release ${version}" +git push --author="Monomax Bot " origin master + +popd