Skip to content
This repository has been archived by the owner on Dec 11, 2023. It is now read-only.

Commit

Permalink
Merge pull request #170 from triggermesh/goreleaser-brew-completions
Browse files Browse the repository at this point in the history
goreleaser: generate completions from brew Formula
  • Loading branch information
sameersbn authored Dec 5, 2022
2 parents 8b35f17 + b13283e commit 08be377
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 9 deletions.
9 changes: 7 additions & 2 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,12 @@ builds:

archives:
- id: default
format: binary
name_template: '{{ .Binary }}_{{ .Os }}_{{ .Arch }}{{ with .Arm }}v{{ . }}{{ end }}{{ with .Mips }}_{{ . }}{{ end }}{{ if not (eq .Amd64 "v1") }}{{ .Amd64 }}{{ end }}'
name_template: '{{ .ProjectName }}_{{ .Os }}_{{ .Arch }}{{ with .Arm }}v{{ . }}{{ end }}{{ if not (eq .Amd64 "v1") }}{{ .Amd64 }}{{ end }}'
replacements:
darwin: macOS
format_overrides:
- goos: windows
format: zip

checksum:
name_template: 'checksums.txt'
Expand All @@ -52,3 +54,6 @@ brews:
owner: triggermesh
name: homebrew-cli
token: "{{ .Env.TAP_GITHUB_TOKEN }}"
install: |
bin.install "tmctl"
generate_completions_from_executable(bin/"tmctl", "completion", shells: [:bash, :zsh])
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@ brew install triggermesh/cli/tmctl
Download and install the latest version for your platform from the [releases page](https://github.com/triggermesh/tmctl/releases). For example,

```bash
curl -L https://github.com/triggermesh/tmctl/releases/latest/download/tmctl_macOS_amd64 -o /tmp/tmctl
mv /tmp/tmctl /usr/local/bin/tmctl
curl -L https://github.com/triggermesh/tmctl/releases/latest/download/tmctl_macOS_amd64.tar.gz
tar -zxf tmctl_macOS_amd64.tar.gz
mv tmctl /usr/local/bin/tmctl
chmod +x /usr/local/bin/tmctl
```

Expand Down
27 changes: 22 additions & 5 deletions hack/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ PKG_VERSION=
GITHUB_URL=https://github.com/triggermesh/tmctl

PLATFORM=
EXT=
ARCH=

SUDO=sudo
Expand Down Expand Up @@ -36,6 +35,7 @@ if [ -z "${BIN_DIR}" ]; then
fi

# os platform
EXT=".tar.gz"
if [ -z "${PLATFORM}" ]; then
case $(uname) in
Linux)
Expand All @@ -46,7 +46,7 @@ if [ -z "${PLATFORM}" ]; then
;;
Windows)
PLATFORM="windows"
EXT=".exe"
EXT=".zip"
;;
*)
fatal "Unsupported platform ${PLATFORM}"
Expand Down Expand Up @@ -82,9 +82,26 @@ else
DOWNLOAD_URL="${GITHUB_URL}/releases/latest/download/${PKG_NAME}_${PLATFORM}_${ARCH}${EXT}"
fi

info "Downloading ${DOWNLOAD_URL}..."
TMP_BIN=$(mktemp -u /tmp/${PKG_NAME}.XXXXXX)
${CURL} -sfL ${DOWNLOAD_URL} -o ${TMP_BIN}
TMP_DIR=$(mktemp -d -t tmctl-install.XXXXXX)
TMP_ARCHIVE=${TMP_DIR}/${PKG_NAME}_${PLATFORM}_${ARCH}${EXT}
TMP_BIN=${TMP_DIR}/tmctl
cleanup() {
code=$?
set +e
trap - EXIT
rm -rf ${TMP_DIR}
exit $code
}
trap cleanup INT EXIT

info "Downloading ${DOWNLOAD_URL}... to ${TMP_ARCHIVE}"
${CURL} -sfL ${DOWNLOAD_URL} -o ${TMP_ARCHIVE}

if [ "${EXT}" = ".zip" ]; then
unzip ${TMP_ARCHIVE} -d ${TMP_DIR}
else
tar xzf ${TMP_ARCHIVE} -C ${TMP_DIR}
fi

info "Installing to ${BIN_DIR}/${PKG_NAME}"
chmod 755 ${TMP_BIN}
Expand Down

0 comments on commit 08be377

Please sign in to comment.