From 010ef861a8459620cc5e737e38825a8dc204f50d Mon Sep 17 00:00:00 2001 From: ytimocin Date: Fri, 3 Jan 2025 16:58:45 -0800 Subject: [PATCH] Initial work on adding the install.sh script This will be used by the users of Prompt-Ops to download the pops binary Signed-off-by: ytimocin --- .github/scripts/install.sh | 43 +++++++++++++++++++++++++++++++++++ .github/workflows/release.yml | 9 ++++++-- 2 files changed, 50 insertions(+), 2 deletions(-) create mode 100755 .github/scripts/install.sh diff --git a/.github/scripts/install.sh b/.github/scripts/install.sh new file mode 100755 index 0000000..9d8c6fc --- /dev/null +++ b/.github/scripts/install.sh @@ -0,0 +1,43 @@ +#!/bin/bash + +set -e + +# Get the latest release version if not provided +VERSION=${1:-$(curl -s https://api.github.com/repos/prompt-ops/pops/releases/latest | grep tag_name | cut -d '"' -f 4)} + +# Check if the version is valid +if [[ ! "$VERSION" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then + echo "Invalid version format: '$VERSION'. Expected format: vX.Y.Z" + exit 1 +fi + +echo "Installing Prompt-Ops $VERSION..." + +# Detect OS and ARCH +OS=$(uname | tr '[:upper:]' '[:lower:]') +ARCH=$(uname -m) + +if [[ "$ARCH" == "x86_64" ]]; then + ARCH="amd64" +elif [[ "$ARCH" == "aarch64" ]]; then + ARCH="arm64" +else + echo "Unsupported architecture: $ARCH" + exit 1 +fi + +echo "Detected OS: $OS" +echo "Detected ARCH: $ARCH" + +# Construct download URL +URL="https://github.com/prompt-ops/pops/releases/download/$VERSION/pops-${OS}-${ARCH}" + +echo "Downloading Prompt-Ops $VERSION from $URL..." +curl -Lo pops "$URL" +chmod +x pops + +# Move to /usr/local/bin +echo "Installing Prompt-Ops to /usr/local/bin..." +sudo mv pops /usr/local/bin/ + +echo "Prompt-Ops $VERSION installed successfully!" diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 7ae42a7..52ba659 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -31,8 +31,13 @@ jobs: - name: Build binaries run: | - GOOS=${{ matrix.goos }} GOARCH=${{ matrix.goarch }} CGO_ENABLED=0 \ - export GO111MODULE=on && go build -ldflags="-s -w" -o pops-${{ matrix.goos }}-${{ matrix.goarch }} + echo "Building for GOOS=${{ matrix.goos }} GOARCH=${{ matrix.goarch }}" + GOOS=${{ matrix.goos }} GOARCH=${{ matrix.goarch }} CGO_ENABLED=0 GO111MODULE=on \ + go build -ldflags="-s -w" -o pops-${{ matrix.goos }}-${{ matrix.goarch }} + + - name: Validate binary + run: | + file pops-${{ matrix.goos }}-${{ matrix.goarch }} - name: Upload binaries as artifact uses: actions/upload-artifact@v4