163 lines
4.7 KiB
YAML
163 lines
4.7 KiB
YAML
name: Release
|
|
|
|
on:
|
|
push:
|
|
tags:
|
|
- 'v*'
|
|
workflow_dispatch:
|
|
inputs:
|
|
version:
|
|
description: 'Version to release (e.g., 1.0.0)'
|
|
required: true
|
|
dry_run:
|
|
description: 'Dry run (do not publish)'
|
|
required: false
|
|
default: 'true'
|
|
|
|
env:
|
|
CARGO_TERM_COLOR: always
|
|
|
|
jobs:
|
|
validate:
|
|
name: Validate Release
|
|
runs-on: ubuntu-latest
|
|
outputs:
|
|
version: ${{ steps.version.outputs.version }}
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Extract version
|
|
id: version
|
|
run: |
|
|
if [ "${{ gitea.event_name }}" == "push" ]; then
|
|
VERSION=${GITEA_REF#refs/tags/v}
|
|
else
|
|
VERSION=${{ gitea.event.inputs.version }}
|
|
fi
|
|
echo "version=$VERSION" >> $GITEA_OUTPUT
|
|
echo "Releasing version: $VERSION"
|
|
|
|
- uses: dtolnay/rust-toolchain@stable
|
|
|
|
- name: Validate Cargo.toml versions
|
|
run: |
|
|
echo "Checking workspace version consistency..."
|
|
cargo metadata --format-version 1 | jq '.packages[] | select(.manifest_path | contains("rustytorch")) | {name: .name, version: .version}' | head -20
|
|
|
|
- name: Run tests
|
|
run: cargo test --workspace
|
|
continue-on-error: true
|
|
|
|
- name: Check formatting
|
|
run: cargo fmt --all -- --check
|
|
|
|
build-artifacts:
|
|
name: Build Release Artifacts
|
|
needs: validate
|
|
runs-on: ${{ matrix.os }}
|
|
strategy:
|
|
matrix:
|
|
include:
|
|
- os: ubuntu-latest
|
|
target: x86_64-unknown-linux-gnu
|
|
artifact: rtx-serving-api-linux-x86_64
|
|
ext: ""
|
|
- os: macos-latest
|
|
target: x86_64-apple-darwin
|
|
artifact: rtx-serving-api-macos-x86_64
|
|
ext: ""
|
|
- os: macos-latest
|
|
target: aarch64-apple-darwin
|
|
artifact: rtx-serving-api-macos-arm64
|
|
ext: ""
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- uses: dtolnay/rust-toolchain@stable
|
|
with:
|
|
targets: ${{ matrix.target }}
|
|
|
|
- uses: Swatinem/rust-cache@v2
|
|
|
|
- name: Build release binary
|
|
run: |
|
|
cargo build --release --target ${{ matrix.target }} -p rtx-serving-api 2>/dev/null || \
|
|
cargo build --release -p rtx-serving-api || \
|
|
echo "Build may have failed - continuing"
|
|
continue-on-error: true
|
|
|
|
- name: Package artifact
|
|
run: |
|
|
mkdir -p dist
|
|
if [ -f "target/${{ matrix.target }}/release/rtx-serving-api" ]; then
|
|
cp target/${{ matrix.target }}/release/rtx-serving-api dist/${{ matrix.artifact }}
|
|
elif [ -f "target/release/rtx-serving-api" ]; then
|
|
cp target/release/rtx-serving-api dist/${{ matrix.artifact }}
|
|
fi
|
|
if [ -f "dist/${{ matrix.artifact }}" ]; then
|
|
chmod +x dist/${{ matrix.artifact }}
|
|
tar -czvf dist/${{ matrix.artifact }}.tar.gz -C dist ${{ matrix.artifact }}
|
|
fi
|
|
continue-on-error: true
|
|
|
|
- name: Upload artifact
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: ${{ matrix.artifact }}
|
|
path: |
|
|
dist/*.tar.gz
|
|
if-no-files-found: warn
|
|
|
|
create-release:
|
|
name: Create Gitea Release
|
|
needs: [validate, build-artifacts]
|
|
runs-on: ubuntu-latest
|
|
if: gitea.event_name == 'push' || gitea.event.inputs.dry_run == 'false'
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
- name: Download all artifacts
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
path: artifacts
|
|
|
|
- name: Create Release via Gitea API
|
|
env:
|
|
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
|
|
run: |
|
|
VERSION="${{ needs.validate.outputs.version }}"
|
|
GITEA_URL="${GITEA_SERVER_URL:-https://your-gitea-instance.com}"
|
|
REPO="${{ gitea.repository }}"
|
|
|
|
curl -X POST "${GITEA_URL}/api/v1/repos/${REPO}/releases" \
|
|
-H "Authorization: token ${GITEA_TOKEN}" \
|
|
-H "Content-Type: application/json" \
|
|
-d "{
|
|
\"tag_name\": \"v${VERSION}\",
|
|
\"name\": \"RustyTorch++ v${VERSION}\",
|
|
\"body\": \"Release v${VERSION}\",
|
|
\"draft\": false,
|
|
\"prerelease\": false
|
|
}"
|
|
|
|
publish-crates:
|
|
name: Publish to Kellnr
|
|
needs: [validate, create-release]
|
|
runs-on: ubuntu-latest
|
|
if: false # Disabled by default - enable when ready
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- uses: dtolnay/rust-toolchain@stable
|
|
|
|
- name: Publish crates to Kellnr
|
|
env:
|
|
CARGO_REGISTRIES_KELLNR_TOKEN: ${{ secrets.KELLNR_TOKEN }}
|
|
run: |
|
|
for crate in rtx-tensor rtx-autograd rtx-inference rtx-serving-api; do
|
|
echo "Publishing $crate to Kellnr..."
|
|
cargo publish -p $crate --registry kellnr || true
|
|
sleep 10
|
|
done
|