Separate homebrew command for testing (#625)

This commit is contained in:
Sung 2023-02-11 19:06:03 +11:00 committed by GitHub
commit 420f30fb92
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 56 additions and 8 deletions

View file

@ -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:

48
scripts/cli/release-homebrew.sh Executable file
View file

@ -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 <bot@monomaxlabs.com>" -m "Release ${version}"
git push --author="Monomax Bot <bot@monomaxlabs.com>" origin master
popd