Skip to content

Commit

Permalink
Initial work on adding the install.sh script
Browse files Browse the repository at this point in the history
This will be used by the users of Prompt-Ops to download the pops binary

Signed-off-by: ytimocin <ytimocin@microsoft.com>
  • Loading branch information
ytimocin committed Jan 4, 2025
1 parent 99e7952 commit 4aba41a
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 7 deletions.
43 changes: 43 additions & 0 deletions .github/scripts/install.sh
Original file line number Diff line number Diff line change
@@ -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!"
25 changes: 18 additions & 7 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,29 @@ jobs:
uses: actions/setup-go@v5
with:
go-version: 1.22
cache: false

- name: Install dependencies
run: go mod tidy

- 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 dist/pops-${{ matrix.goos }}-${{ matrix.goarch }}
- name: Validate binary
run: |
file dist/pops-${{ matrix.goos }}-${{ matrix.goarch }}
- name: List dist folder
run: ls -R dist

- name: Upload binaries as artifact
uses: actions/upload-artifact@v4
with:
name: pops-${{ matrix.goos }}-${{ matrix.goarch }}
path: pops-${{ matrix.goos }}-${{ matrix.goarch }}
path: dist/*

release:
runs-on: ubuntu-latest
Expand All @@ -51,10 +60,12 @@ jobs:
- name: Download build artifacts
uses: actions/download-artifact@v4
with:
path: release
pattern: pops-*
path: dist
pattern: dist/pops-*
merge-multiple: true
- run: ls -R release

- name: List dist folder
run: ls -R dist

- name: Release
id: create_release
Expand All @@ -63,6 +74,6 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
repository: prompt-ops/pops
files: release/*
files: dist/*
draft: false
prerelease: false
1 change: 1 addition & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ jobs:
uses: actions/setup-go@v5
with:
go-version: 1.22
cache: false

- name: Install dependencies
run: go mod tidy
Expand Down

0 comments on commit 4aba41a

Please sign in to comment.