Skip to content

Workflow file for this run

name: Upload assets to GitHub Release and publish Docker image
on:
release:
types:
- created
env:
TAG_VERSION: ${{ github.event.release.tag_name }}
jobs:
bump-version:
name: Bump version
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Bump version in Cargo.toml and Cargo.lock
run: |
sed -i "s/^version = \".*\"/version = \"${TAG_VERSION:1}\"/" Cargo.toml
awk -v tag="${TAG_VERSION:1}" '/name = "model_runner"/{getline; sub(/version = ".+"/, "name = \"model_runner\"\nversion = \"" tag "\""); print; next}1' Cargo.lock > temp && mv temp Cargo.lock
- name: Commit changes
uses: stefanzweifel/git-auto-commit-action@v5
with:
branch: master
commit_message: "Release ${{ env.TAG_VERSION }}"
file_pattern: "Cargo.toml Cargo.lock"
add-release-assets:
name: Add Release assets ${{ matrix.target }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- target: x86_64-pc-windows-gnu
archive: zip
- target: x86_64-unknown-linux-musl
archive: zip tar.gz tar.zst
# - target: x86_64-apple-darwin
# archive: zip tar.gz tar.zst
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Bump version in Cargo.toml and Cargo.lock
run: |
sed -i "s/^version = \".*\"/version = \"${TAG_VERSION:1}\"/" Cargo.toml
awk -v tag="${TAG_VERSION:1}" '/name = "model_runner"/{getline; sub(/version = ".+"/, "name = \"model_runner\"\nversion = \"" tag "\""); print; next}1' Cargo.lock > temp && mv temp Cargo.lock
- name: Install sqlx-cli
run: cargo install sqlx-cli --no-default-features --features sqlite
- run: |
chmod +x ~/.cargo/bin/sqlx
echo ~/.cargo/bin >> $GITHUB_PATH
- name: Setup sqlx
env:
DATABASE_URL: sqlite://model_runner_build.db
run: sqlx db setup
- name: Compile and upload
uses: rust-build/rust-build.action@v1.4.5
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
DATABASE_URL: sqlite://model_runner_build.db
with:
RUSTTARGET: ${{ matrix.target }}
ARCHIVE_TYPES: ${{ matrix.archive }}
image:
name: Publish docker image ${{ matrix.suffix }}
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
strategy:
fail-fast: false
matrix:
include:
- flags: "" # No optimizations
suffix: "" # '-' must be appended manually
- flags: "-C target-feature=+avx,+avx2"
suffix: "-avx"
- flags: "-C target-feature=+f16c"
suffix: "-f16c"
- flags: "-C target-feature=+avx,+avx2,+f16c"
suffix: "-avx-f16c"
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Bump version in Cargo.toml and Cargo.lock
run: |
sed -i "s/^version = \".*\"/version = \"${TAG_VERSION:1}\"/" Cargo.toml
awk -v tag="${TAG_VERSION:1}" '/name = "model_runner"/{getline; sub(/version = ".+"/, "name = \"model_runner\"\nversion = \"" tag "\""); print; next}1' Cargo.lock > temp && mv temp Cargo.lock
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Extract metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ghcr.io/${{ github.repository }}
flavor: |
suffix=${{ matrix.suffix }},onlatest=true
tags: |
type=semver,pattern={{version}}
- name: Build and push
uses: docker/build-push-action@v5
with:
context: .
file: ./Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
rust_flags=${{ matrix.flags }}