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

Commit 08be377

Browse files
authored
Merge pull request #170 from triggermesh/goreleaser-brew-completions
goreleaser: generate completions from brew Formula
2 parents 8b35f17 + b13283e commit 08be377

File tree

3 files changed

+32
-9
lines changed

3 files changed

+32
-9
lines changed

.goreleaser.yaml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,12 @@ builds:
2424

2525
archives:
2626
- id: default
27-
format: binary
28-
name_template: '{{ .Binary }}_{{ .Os }}_{{ .Arch }}{{ with .Arm }}v{{ . }}{{ end }}{{ with .Mips }}_{{ . }}{{ end }}{{ if not (eq .Amd64 "v1") }}{{ .Amd64 }}{{ end }}'
27+
name_template: '{{ .ProjectName }}_{{ .Os }}_{{ .Arch }}{{ with .Arm }}v{{ . }}{{ end }}{{ if not (eq .Amd64 "v1") }}{{ .Amd64 }}{{ end }}'
2928
replacements:
3029
darwin: macOS
30+
format_overrides:
31+
- goos: windows
32+
format: zip
3133

3234
checksum:
3335
name_template: 'checksums.txt'
@@ -52,3 +54,6 @@ brews:
5254
owner: triggermesh
5355
name: homebrew-cli
5456
token: "{{ .Env.TAP_GITHUB_TOKEN }}"
57+
install: |
58+
bin.install "tmctl"
59+
generate_completions_from_executable(bin/"tmctl", "completion", shells: [:bash, :zsh])

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,9 @@ brew install triggermesh/cli/tmctl
2727
Download and install the latest version for your platform from the [releases page](https://github.com/triggermesh/tmctl/releases). For example,
2828

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

hack/install.sh

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ PKG_VERSION=
66
GITHUB_URL=https://github.com/triggermesh/tmctl
77

88
PLATFORM=
9-
EXT=
109
ARCH=
1110

1211
SUDO=sudo
@@ -36,6 +35,7 @@ if [ -z "${BIN_DIR}" ]; then
3635
fi
3736

3837
# os platform
38+
EXT=".tar.gz"
3939
if [ -z "${PLATFORM}" ]; then
4040
case $(uname) in
4141
Linux)
@@ -46,7 +46,7 @@ if [ -z "${PLATFORM}" ]; then
4646
;;
4747
Windows)
4848
PLATFORM="windows"
49-
EXT=".exe"
49+
EXT=".zip"
5050
;;
5151
*)
5252
fatal "Unsupported platform ${PLATFORM}"
@@ -82,9 +82,26 @@ else
8282
DOWNLOAD_URL="${GITHUB_URL}/releases/latest/download/${PKG_NAME}_${PLATFORM}_${ARCH}${EXT}"
8383
fi
8484

85-
info "Downloading ${DOWNLOAD_URL}..."
86-
TMP_BIN=$(mktemp -u /tmp/${PKG_NAME}.XXXXXX)
87-
${CURL} -sfL ${DOWNLOAD_URL} -o ${TMP_BIN}
85+
TMP_DIR=$(mktemp -d -t tmctl-install.XXXXXX)
86+
TMP_ARCHIVE=${TMP_DIR}/${PKG_NAME}_${PLATFORM}_${ARCH}${EXT}
87+
TMP_BIN=${TMP_DIR}/tmctl
88+
cleanup() {
89+
code=$?
90+
set +e
91+
trap - EXIT
92+
rm -rf ${TMP_DIR}
93+
exit $code
94+
}
95+
trap cleanup INT EXIT
96+
97+
info "Downloading ${DOWNLOAD_URL}... to ${TMP_ARCHIVE}"
98+
${CURL} -sfL ${DOWNLOAD_URL} -o ${TMP_ARCHIVE}
99+
100+
if [ "${EXT}" = ".zip" ]; then
101+
unzip ${TMP_ARCHIVE} -d ${TMP_DIR}
102+
else
103+
tar xzf ${TMP_ARCHIVE} -C ${TMP_DIR}
104+
fi
88105

89106
info "Installing to ${BIN_DIR}/${PKG_NAME}"
90107
chmod 755 ${TMP_BIN}

0 commit comments

Comments
 (0)