From cc222e52c034a0ebeca96ec30722f509d2e0176a Mon Sep 17 00:00:00 2001 From: Gabriel Kaszewski Date: Sun, 24 Aug 2025 14:01:33 +0200 Subject: [PATCH] feat: add GitHub Actions workflow for automated release and installation script --- .github/workflows/release.yml | 78 +++++++++++++++++++++++++++++++++++ install.sh | 28 +++++++++++++ 2 files changed, 106 insertions(+) create mode 100644 .github/workflows/release.yml create mode 100644 install.sh diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..3bfb0c4 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,78 @@ +name: Release + +on: + push: + tags: + - "v*" + +jobs: + build: + name: Build for ${{ matrix.os }} + runs-on: ${{ matrix.os }} + strategy: + matrix: + include: + - os: ubuntu-latest + target: x86_64-unknown-linux-gnu + - os: macos-latest + target: x86_64-apple-darwin + - os: windows-latest + target: x86_64-pc-windows-msvc + + steps: + - uses: actions/checkout@v2 + - name: Build + run: cargo build --release --target ${{ matrix.target }} + - name: Upload Artifact + uses: actions/upload-artifact@v2 + with: + name: codebase-to-prompt-${{ matrix.target }} + path: target/${{ matrix.target }}/release/codebase-to-prompt* + + release: + name: Create Release + needs: build + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Download Artifacts + uses: actions/download-artifact@v2 + with: + path: artifacts + - name: Create Release + id: create_release + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ github.ref }} + release_name: Release ${{ github.ref }} + draft: false + prerelease: false + - name: Upload Release Asset (Linux) + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: ./artifacts/codebase-to-prompt-x86_64-unknown-linux-gnu/codebase-to-prompt + asset_name: codebase-to-prompt-x86_64-unknown-linux-gnu + asset_content_type: application/octet-stream + - name: Upload Release Asset (macOS) + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: ./artifacts/codebase-to-prompt-x86_64-apple-darwin/codebase-to-prompt + asset_name: codebase-to-prompt-x86_64-apple-darwin + asset_content_type: application/octet-stream + - name: Upload Release Asset (Windows) + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: ./artifacts/codebase-to-prompt-x86_64-pc-windows-msvc/codebase-to-prompt.exe + asset_name: codebase-to-prompt-x86_64-pc-windows-msvc.exe + asset_content_type: application/octet-stream diff --git a/install.sh b/install.sh new file mode 100644 index 0000000..620c4f0 --- /dev/null +++ b/install.sh @@ -0,0 +1,28 @@ +#!/bin/sh +# install.sh +# +# This script downloads and installs the latest release of codebase-to-prompt. +set -e + +LATEST_RELEASE=$(curl -s "https://api.github.com/repos/GKaszewski/codebase-to-prompt/releases/latest" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/') + +OS=$(uname -s | tr '[:upper:]' '[:lower:]') +ARCH=$(uname -m) + +TARGET="" +if [ "$OS" = "linux" ] && [ "$ARCH" = "x86_64" ]; then + TARGET="x86_64-unknown-linux-gnu" +elif [ "$OS" = "darwin" ] && [ "$ARCH" = "x86_64" ]; then + TARGET="x86_64-apple-darwin" +else + echo "Unsupported OS or architecture: $OS $ARCH" + exit 1 +fi + +DOWNLOAD_URL="https://github.com/GKaszewski/codebase-to-prompt/releases/download/$LATEST_RELEASE/codebase-to-prompt-$TARGET" +curl -L "$DOWNLOAD_URL" -o codebase-to-prompt + +chmod +x codebase-to-prompt +mv codebase-to-prompt /usr/local/bin/ + +echo "codebase-to-prompt installed successfully!" \ No newline at end of file