Skip to content

Commit 134066b

Browse files
committed
fix: install script error -
file name mismatch between goreleaser and the install script Signed-off-by: Ayush <mail@ayuch.dev>
1 parent 92580f2 commit 134066b

File tree

2 files changed

+25
-14
lines changed

2 files changed

+25
-14
lines changed

.goreleaser.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@ archives:
3535
- # Format for the archive (tar.gz for Unix-like systems, zip for Windows).
3636
format: tar.gz
3737
# This template creates archives with platform-specific naming conventions
38-
# Examples: "gitx_1.0.0_Linux_x86_64.tar.gz", "gitx_1.0.0_Darwin_arm64.tar.gz"
38+
# Examples: "gitx_Linux_x86_64.tar.gz", "gitx_Darwin_arm64.tar.gz"
3939
name_template: >-
40-
{{ .ProjectName }}_{{ .Version }}_
40+
{{ .ProjectName }}_
4141
{{- title .Os }}_
4242
{{- if eq .Arch "amd64" }}x86_64
4343
{{- else if eq .Arch "386" }}i386

install.sh

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ INSTALL_DIR="/usr/local/bin"
1515
# Get the operating system.
1616
get_os() {
1717
case "$(uname -s)" in
18-
Linux*) OS='linux';;
19-
Darwin*) OS='darwin';;
18+
Linux*) OS='Linux';;
19+
Darwin*) OS='Darwin';;
2020
*)
2121
echo "Unsupported operating system: $(uname -s)"
2222
exit 1
@@ -28,8 +28,9 @@ get_os() {
2828
# Get the architecture.
2929
get_arch() {
3030
case "$(uname -m)" in
31-
x86_64|amd64) ARCH='amd64';;
31+
x86_64|amd64) ARCH='x86_64';;
3232
aarch64|arm64) ARCH='arm64';;
33+
i386|i686) ARCH='i386';;
3334
*)
3435
echo "Unsupported architecture: $(uname -m)"
3536
exit 1
@@ -40,12 +41,13 @@ get_arch() {
4041

4142
# Get the latest release tag from the GitHub API.
4243
get_latest_release() {
43-
API_URL="https://api.github.com/repos/$REPO/releases"
44+
API_URL="https://api.github.com/repos/$REPO/releases/latest"
4445

4546
# Use python if available, otherwise fall back to perl.
46-
if command -v python >/dev/null 2>&1; then
47-
# This python script now checks if the response is a list and not empty.
48-
curl -sL "$API_URL" | python -c "import sys, json; data = json.load(sys.stdin); print(data[0]['tag_name'] if isinstance(data, list) and data else '')"
47+
if command -v python3 >/dev/null 2>&1; then
48+
curl -sL "$API_URL" | python3 -c "import sys, json; print(json.load(sys.stdin)['tag_name'])"
49+
elif command -v python >/dev/null 2>&1; then
50+
curl -sL "$API_URL" | python -c "import sys, json; print(json.load(sys.stdin)['tag_name'])"
4951
elif command -v perl >/dev/null 2>&1; then
5052
curl -sL "$API_URL" | perl -ne 'if (/\"tag_name\":\s*\"([^\"]+)\"/) { print $1; exit }'
5153
else
@@ -69,19 +71,28 @@ main() {
6971
fi
7072

7173
# Construct the archive filename and download URL.
72-
VERSION_NUM=$(echo "$VERSION" | sed 's/v//')
73-
FILENAME="gitx_${VERSION_NUM}_${OS}_${ARCH}.tar.gz"
74+
FILENAME="gitx_${OS}_${ARCH}.tar.gz"
7475
DOWNLOAD_URL="https://github.com/$REPO/releases/download/${VERSION}/${FILENAME}"
7576

7677
# Download and extract the binary.
7778
echo "Downloading gitx ${VERSION} for ${OS}/${ARCH}..."
7879
TEMP_DIR=$(mktemp -d)
79-
# Download to a temporary directory.
80-
curl -sSL -o "$TEMP_DIR/$FILENAME" "$DOWNLOAD_URL"
80+
81+
# Download to a temporary directory with error checking.
82+
if ! curl -sSL -f -o "$TEMP_DIR/$FILENAME" "$DOWNLOAD_URL"; then
83+
echo "Error: Failed to download gitx from $DOWNLOAD_URL"
84+
echo "Please check that the release exists and try again."
85+
rm -rf "$TEMP_DIR"
86+
exit 1
87+
fi
8188

8289
echo "Installing gitx to ${INSTALL_DIR}..."
8390
# Extract the archive.
84-
tar -xzf "$TEMP_DIR/$FILENAME" -C "$TEMP_DIR"
91+
if ! tar -xzf "$TEMP_DIR/$FILENAME" -C "$TEMP_DIR"; then
92+
echo "Error: Failed to extract archive. The downloaded file may be corrupted."
93+
rm -rf "$TEMP_DIR"
94+
exit 1
95+
fi
8596

8697
# Ensure the installation directory exists.
8798
if [ ! -d "$INSTALL_DIR" ]; then

0 commit comments

Comments
 (0)