diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..e8afd79 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,136 @@ +name: Release Binaries + +on: + push: + tags: + - "v*" + workflow_dispatch: + inputs: + tag: + description: "Existing git tag to release (example: v0.1.0)" + required: true + type: string + +permissions: + contents: write + +env: + CARGO_TERM_COLOR: always + METADATA_CHAIN_ENDPOINT: wss://entrypoint-finney.opentensor.ai:443 + +jobs: + build: + name: Build (${{ matrix.name }}) + strategy: + fail-fast: false + matrix: + include: + - name: linux-x86_64 + os: ubuntu-latest + target: x86_64-unknown-linux-gnu + bin_name: agcli + archive_ext: tar.gz + - name: macos-x86_64 + os: macos-13 + target: x86_64-apple-darwin + bin_name: agcli + archive_ext: tar.gz + - name: macos-arm64 + os: macos-14 + target: aarch64-apple-darwin + bin_name: agcli + archive_ext: tar.gz + - name: windows-x86_64 + os: windows-latest + target: x86_64-pc-windows-msvc + bin_name: agcli.exe + archive_ext: zip + runs-on: ${{ matrix.os }} + + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Resolve release tag + id: tag + shell: bash + run: | + if [[ "${GITHUB_EVENT_NAME}" == "workflow_dispatch" ]]; then + echo "value=${{ github.event.inputs.tag }}" >> "$GITHUB_OUTPUT" + else + echo "value=${GITHUB_REF_NAME}" >> "$GITHUB_OUTPUT" + fi + + - name: Validate tag exists + shell: bash + run: | + git fetch --tags --force + git rev-parse "${{ steps.tag.outputs.value }}" >/dev/null + + - name: Set up Rust + uses: dtolnay/rust-toolchain@stable + with: + targets: ${{ matrix.target }} + + - name: Cache dependencies + uses: Swatinem/rust-cache@v2 + + - name: Build release binary + shell: bash + run: cargo build --release --target "${{ matrix.target }}" + + - name: Create archive (unix) + if: runner.os != 'Windows' + shell: bash + run: | + mkdir -p dist + cp "target/${{ matrix.target }}/release/${{ matrix.bin_name }}" dist/ + cp README.md LICENSE dist/ + archive="agcli-${{ steps.tag.outputs.value }}-${{ matrix.target }}.tar.gz" + tar -C dist -czf "$archive" "${{ matrix.bin_name }}" README.md LICENSE + echo "ASSET_PATH=$archive" >> "$GITHUB_ENV" + + - name: Create archive (windows) + if: runner.os == 'Windows' + shell: pwsh + run: | + New-Item -ItemType Directory -Path dist -Force | Out-Null + Copy-Item "target/${{ matrix.target }}/release/${{ matrix.bin_name }}" dist/ + Copy-Item README.md dist/ + Copy-Item LICENSE dist/ + $archive = "agcli-${{ steps.tag.outputs.value }}-${{ matrix.target }}.zip" + Compress-Archive -Path "dist/*" -DestinationPath $archive -Force + "ASSET_PATH=$archive" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append + + - name: Upload artifact + uses: actions/upload-artifact@v4 + with: + name: agcli-${{ matrix.target }} + path: ${{ env.ASSET_PATH }} + + publish: + name: Publish GitHub Release + needs: build + runs-on: ubuntu-latest + steps: + - name: Resolve release tag + id: tag + run: | + if [[ "${GITHUB_EVENT_NAME}" == "workflow_dispatch" ]]; then + echo "value=${{ github.event.inputs.tag }}" >> "$GITHUB_OUTPUT" + else + echo "value=${GITHUB_REF_NAME}" >> "$GITHUB_OUTPUT" + fi + + - name: Download all artifacts + uses: actions/download-artifact@v4 + with: + path: release-assets + + - name: Publish release assets + uses: softprops/action-gh-release@v2 + with: + tag_name: ${{ steps.tag.outputs.value }} + files: release-assets/**/* diff --git a/README.md b/README.md index 4ece33e..c841257 100644 --- a/README.md +++ b/README.md @@ -11,6 +11,14 @@ Agents first, fast, safe Rust toolkit for the [Bittensor](https://bittensor.com) cargo install --git https://github.com/unarbos/agcli ``` +### Pre-built binaries + +Pre-built binaries are published on GitHub Releases for tagged versions (`v*`) and include: +- Linux (`x86_64-unknown-linux-gnu`) +- macOS Intel (`x86_64-apple-darwin`) +- macOS Apple Silicon (`aarch64-apple-darwin`) +- Windows (`x86_64-pc-windows-msvc`) + ## Quick Examples ```bash