name: Release Pipeline
on:
push:
tags:
- 'v*'
workflow_dispatch:
inputs:
version:
description: 'Version to release (e.g., v1.0.1)'
required: true
env:
CARGO_TERM_COLOR: always
RUST_BACKTRACE: 1
jobs:
preflight:
name: Pre-flight Checks
runs-on: ubuntu-latest
outputs:
version: ${{ steps.version.outputs.version }}
should_publish: ${{ steps.checks.outputs.should_publish }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Extract version
id: version
run: |
if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
VERSION="${{ github.event.inputs.version }}"
else
VERSION="${GITHUB_REF#refs/tags/}"
fi
echo "version=${VERSION}" >> $GITHUB_OUTPUT
echo "Version: ${VERSION}"
- name: Setup Rust toolchain
uses: dtolnay/rust-toolchain@stable
- name: Cache dependencies
uses: actions/cache@v3
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Validate Cargo.toml
run: |
echo "๐ Validating Cargo.toml..."
CARGO_VERSION=$(grep '^version = ' Cargo.toml | head -1 | sed 's/version = "\(.*\)"/\1/')
TAG_VERSION="${{ steps.version.outputs.version }}"
TAG_VERSION_CLEAN="${TAG_VERSION#v}"
echo "Cargo.toml version: ${CARGO_VERSION}"
echo "Git tag version: ${TAG_VERSION_CLEAN}"
if [[ "${CARGO_VERSION}" != "${TAG_VERSION_CLEAN}" ]]; then
echo "โ Version mismatch: Cargo.toml (${CARGO_VERSION}) != tag (${TAG_VERSION_CLEAN})"
exit 1
fi
echo "โ
Version validated"
- name: Check compilation
run: |
echo "๐ง Checking compilation..."
cargo check --all-features --verbose
echo "โ
Compilation check passed"
- name: Run tests
run: |
echo "๐งช Running test suite..."
cargo test --all-features --verbose
echo "โ
Tests passed"
- name: Check crate package
run: |
echo "๐ฆ Validating crate package..."
cargo package --list | head -20
cargo package --allow-dirty
echo "โ
Package validation passed"
- name: Security audit
run: |
echo "๐ Running security audit..."
cargo install cargo-audit || true
cargo audit || echo "โ ๏ธ Security audit completed with warnings"
- name: Final validation
id: checks
run: |
echo "โ
All pre-flight checks passed!"
echo "๐ Ready for release pipeline"
echo "should_publish=true" >> $GITHUB_OUTPUT
build:
name: Build ${{ matrix.target }}
needs: preflight
if: needs.preflight.outputs.should_publish == 'true'
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- target: x86_64-unknown-linux-gnu
os: ubuntu-latest
name: rustchain-linux-x64
- target: x86_64-apple-darwin
os: macos-latest
name: rustchain-macos-x64
- target: aarch64-apple-darwin
os: macos-latest
name: rustchain-macos-arm64
- target: x86_64-pc-windows-msvc
os: windows-latest
name: rustchain-windows-x64.exe
steps:
- uses: actions/checkout@v4
- name: Setup Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Cache dependencies
uses: actions/cache@v3
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-${{ matrix.target }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Build release binary
run: |
echo "๐ง Building for ${{ matrix.target }}..."
cargo build --release --target ${{ matrix.target }} --verbose
echo "โ
Build completed"
- name: Prepare artifacts
shell: bash
run: |
if [[ "${{ matrix.os }}" == "windows-latest" ]]; then
cp target/${{ matrix.target }}/release/rustchain.exe ${{ matrix.name }}
else
cp target/${{ matrix.target }}/release/rustchain ${{ matrix.name }}
fi
- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.name }}
path: ${{ matrix.name }}
docker:
name: Build Docker Images
needs: preflight
if: needs.preflight.outputs.should_publish == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Extract metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ secrets.DOCKER_USERNAME }}/rustchain
tags: |
type=ref,event=tag
type=raw,value=latest
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
create-release:
name: Create GitHub Release
needs: [preflight, build, docker]
if: always() && needs.preflight.outputs.should_publish == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Download all artifacts
uses: actions/download-artifact@v3
- name: Create release
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ needs.preflight.outputs.version }}
name: Rustchain ${{ needs.preflight.outputs.version }}
body: |
## ๐ Rustchain ${{ needs.preflight.outputs.version }}
**Cross-platform AI agent framework built in Rust**
### ๐ฆ Installation
**From crates.io:**
```bash
cargo install rustchain
```
**From Docker:**
```bash
docker pull ${{ secrets.DOCKER_USERNAME }}/rustchain:${{ needs.preflight.outputs.version }}
```
### ๐ฝ Downloads
Choose the binary for your platform below.
### ๐ Links
- **Website**: https://rustchain.dev
- **Documentation**: https://docs.rs/rustchain
- **Docker Hub**: https://hub.docker.com/r/${{ secrets.DOCKER_USERNAME }}/rustchain
files: |
rustchain-linux-x64/rustchain-linux-x64
rustchain-macos-x64/rustchain-macos-x64
rustchain-macos-arm64/rustchain-macos-arm64
rustchain-windows-x64.exe/rustchain-windows-x64.exe
draft: false
prerelease: false