Skip to content
This repository was archived by the owner on Jan 15, 2026. It is now read-only.

Commit 4641d18

Browse files
authored
feat: install script (#17)
* feat: update go-releaser script * feat: add install script
1 parent 2bbb502 commit 4641d18

File tree

3 files changed

+80
-23
lines changed

3 files changed

+80
-23
lines changed

.goreleaser.yaml

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -14,31 +14,13 @@ before:
1414

1515
builds:
1616
- main: ./cmd/slick/main.go
17+
binary: slick
1718
env:
1819
- CGO_ENABLED=0
1920
goos:
2021
- linux
2122
- windows
2223
- darwin
23-
24-
archives:
25-
- format: tar.gz
26-
# this name template makes the OS and Arch compatible with the results of `uname`.
27-
name_template: >-
28-
{{ .ProjectName }}_
29-
{{- title .Os }}_
30-
{{- if eq .Arch "amd64" }}x86_64
31-
{{- else if eq .Arch "386" }}i386
32-
{{- else }}{{ .Arch }}{{ end }}
33-
{{- if .Arm }}v{{ .Arm }}{{ end }}
34-
# use zip for windows archives
35-
format_overrides:
36-
- goos: windows
37-
format: zip
38-
39-
changelog:
40-
sort: asc
41-
filters:
42-
exclude:
43-
- "^docs:"
44-
- "^test:"
24+
goarch:
25+
- amd64
26+
- arm64

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ require (
77
github.com/docker/go-connections v0.4.0
88
github.com/joho/godotenv v1.5.1
99
github.com/jonboulle/clockwork v0.4.0
10+
github.com/opencontainers/image-spec v1.0.2
1011
github.com/spf13/cobra v1.8.0
1112
github.com/stretchr/testify v1.8.4
1213
gopkg.in/yaml.v3 v3.0.1
@@ -23,7 +24,6 @@ require (
2324
github.com/moby/term v0.5.0 // indirect
2425
github.com/morikuni/aec v1.0.0 // indirect
2526
github.com/opencontainers/go-digest v1.0.0 // indirect
26-
github.com/opencontainers/image-spec v1.0.2 // indirect
2727
github.com/pkg/errors v0.9.1 // indirect
2828
github.com/pmezard/go-difflib v1.0.0 // indirect
2929
github.com/spf13/pflag v1.0.5 // indirect

scripts/install.sh

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
#!/bin/bash
2+
# This script installs the slick deploy to /usr/local/bin/slick from Github release
3+
args=("$@")
4+
custom_version=${args[0]}
5+
6+
# Function to detect latest GitHub release
7+
get_latest_release() {
8+
local repo=$1
9+
curl -s "https://api.github.com/repos/${repo}/releases/latest" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/'
10+
}
11+
12+
if [ -z "$custom_version" ]; then
13+
custom_version=$(get_latest_release "scmmishra/slick-deploy")
14+
fi
15+
16+
# Function to detect platform, architecture, etc.
17+
detect_platform() {
18+
OS=$(uname -s)
19+
ARCH=$(uname -m)
20+
21+
case $OS in
22+
Linux) OS="linux" ;;
23+
Darwin) OS="darwin" ;;
24+
*)
25+
echo "Unsupported operating system: $OS"
26+
exit 1
27+
;;
28+
esac
29+
30+
case $ARCH in
31+
x86_64) ARCH="amd64" ;;
32+
aarch64 | arm64) ARCH="arm64" ;;
33+
*)
34+
echo "Unsupported architecture: $ARCH"
35+
exit 1
36+
;;
37+
esac
38+
39+
echo "Detected platform: $OS $ARCH"
40+
}
41+
42+
# Function to download file from GitHub release
43+
download_from_github() {
44+
local repo=$1
45+
local release=$2
46+
local name=$3
47+
local filename=${name}_${release}_${OS}_${ARCH}.tar.gz
48+
# Construct download URL
49+
local download_url="https://github.com/${repo}/releases/download/${release}/${filename}"
50+
51+
# Use curl to download the file quietly
52+
echo "Downloading ${name} ${release} from GitHub release"
53+
curl -sL -o "${filename}" "${download_url}"
54+
55+
# Determine the binary directory
56+
local binary_dir=""
57+
if [ "$OS" == "linux" ] || [ "$OS" == "darwin" ]; then
58+
binary_dir="/usr/local/bin"
59+
fi
60+
echo "Installing ${name}"
61+
echo filename
62+
sudo tar -xzvf "${filename}" -C "${binary_dir}" > /dev/null
63+
64+
# Make the binary executable
65+
sudo chmod +x "${binary_dir}/slick"
66+
67+
# Cleanup
68+
rm "${filename}"
69+
70+
echo "${name} installed successfully to ${binary_dir}/slick"
71+
}
72+
73+
echo "⠠⠞⠑⠭⠞⠶⠠⠑⠙⠊⠞⠕⠗ Slick Deploy ⠠⠞⠑⠭⠞⠶⠠⠑⠙⠊⠞⠕⠗"
74+
detect_platform
75+
download_from_github "scmmishra/slick-deploy" $custom_version "slick-deploy"

0 commit comments

Comments
 (0)