diff --git a/.github/workflows/build-binaries.yml b/.github/workflows/build-binaries.yml new file mode 100644 index 0000000..77a8c08 --- /dev/null +++ b/.github/workflows/build-binaries.yml @@ -0,0 +1,81 @@ +name: Build and Release Binaries + +on: + push: + tags: + - "v*.*.*" # Triggers on version tag pushes like v1.0.0 + +jobs: + build: + name: Build Binaries + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest, macos-latest, windows-latest] + include: + - os: ubuntu-latest + platform: linux + arch: x86_64 + - os: macos-latest + platform: macos + arch: x86_64 + - os: windows-latest + platform: windows + arch: x86_64 + steps: + - name: Checkout Code + uses: actions/checkout@v3 + + - name: Set Up Elixir + uses: erlef/setup-beam@v1 + with: + elixir-version: "1.17.2" + otp-version: "26" + + - name: Install Dependencies + run: mix deps.get + + - name: Build Release + env: + MIX_ENV: prod + run: mix release + + - name: Prepare Artifact + if: ${{ runner.os != 'Windows' }} + run: | + tar czvf cashubrew-${{ matrix.platform }}-${{ matrix.arch }}-${{ github.ref_name }}.tar.gz -C _build/prod/rel/cashubrew . + - name: Prepare Artifact (Windows) + if: ${{ runner.os == 'Windows' }} + shell: pwsh + run: | + Compress-Archive -Path "_build\prod\rel\cashubrew\*" -DestinationPath "cashubrew-${{ matrix.platform }}-${{ matrix.arch }}-${{ github.ref_name }}.zip" + + - name: Upload Artifact + uses: actions/upload-artifact@v3 + with: + name: cashubrew-${{ matrix.platform }}-${{ matrix.arch }}-${{ github.ref_name }} + path: | + cashubrew-${{ matrix.platform }}-${{ matrix.arch }}-${{ github.ref_name }}.tar.gz + cashubrew-${{ matrix.platform }}-${{ matrix.arch }}-${{ github.ref_name }}.zip + + release: + name: Create Release + runs-on: ubuntu-latest + needs: build + steps: + - name: Download Artifacts + uses: actions/download-artifact@v3 + with: + path: ./artifacts + + - name: Create GitHub Release + id: create_release + uses: softprops/action-gh-release@v1 + with: + files: ./artifacts/* + draft: false + prerelease: false + tag_name: ${{ github.ref_name }} + name: Release ${{ github.ref_name }} + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/install.sh b/install.sh new file mode 100755 index 0000000..ac942df --- /dev/null +++ b/install.sh @@ -0,0 +1,79 @@ +#!/bin/bash + +set -e + +OS="$(uname -s)" +ARCH="$(uname -m)" + +# Normalize OS name +case "$OS" in + Linux*) PLATFORM="linux";; + Darwin*) PLATFORM="macos";; + CYGWIN*|MINGW*|MSYS_NT*) PLATFORM="windows";; + *) echo "Unsupported OS: $OS"; exit 1;; +esac + +# Normalize ARCH +case "$ARCH" in + x86_64|amd64) ARCH="x86_64";; + arm64|aarch64) ARCH="arm64";; + *) echo "Unsupported architecture: $ARCH"; exit 1;; +esac + +echo "Detected platform: $PLATFORM" +echo "Detected architecture: $ARCH" + +# Get the version to install +if [ -n "$1" ]; then + VERSION="$1" +else + # Get latest version + VERSION=$(curl -s https://api.github.com/repos/keep-starknet-strange/cashubrew/releases/latest | grep '"tag_name"' | sed -E 's/.*"tag_name": "([^"]+)".*/\1/') +fi + +if [ -z "$VERSION" ]; then + echo "Failed to get version to install" + exit 1 +fi + +echo "Installing version: $VERSION" + +# Construct download URL +if [ "$PLATFORM" = "windows" ]; then + EXT="zip" +else + EXT="tar.gz" +fi + +BINARY_NAME="cashubrew-${PLATFORM}-${ARCH}-${VERSION}.${EXT}" +DOWNLOAD_URL="https://github.com/keep-starknet-strange/cashubrew/releases/download/${VERSION}/${BINARY_NAME}" + +echo "Downloading $DOWNLOAD_URL" + +# Download the binary +curl -L -o "$BINARY_NAME" "$DOWNLOAD_URL" + +# Extract and install +if [ "$EXT" = "tar.gz" ]; then + tar xzvf "$BINARY_NAME" +elif [ "$EXT" = "zip" ]; then + unzip "$BINARY_NAME" +else + echo "Unknown file extension: $EXT" + exit 1 +fi + +# Move binary to /usr/local/bin +if [ -d "cashubrew/bin" ]; then + sudo cp cashubrew/bin/cashubrew /usr/local/bin/ +elif [ -f "cashubrew.exe" ]; then + sudo cp cashubrew.exe /usr/local/bin/ +else + echo "Binary not found after extraction" + exit 1 +fi + +# Clean up +rm -rf "$BINARY_NAME" cashubrew cashubrew.exe + +echo "✅ Cashubrew installed successfully!"