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
with:
ref: ${{ github.head_ref }}
- name: Setup Rust
uses: dtolnay/rust-toolchain@stable
- name: Bump version in Cargo.toml and Cargo.lock
# TODO: This is very wasteful
run: |
echo ${TAG_VERSION}
echo "TAG_VERSION=${TAG_VERSION:1}" >> "$GITHUB_ENV"
echo ${TAG_VERSION}
echo "Bumping version to ${{ github.event.release.tag_name }}"
sed -i "s/^version = \".*\"/version = \"${TAG_VERSION}\"/" Cargo.toml
cargo fetch
cargo generate-lockfile --offline
- name: Commit changes
uses: stefanzweifel/git-auto-commit-action@v5
with:
branch: ${{ github.head_ref }}
commit_message: "Bump version to ${{ github.event.release.tag_name }}"
file_pattern: "Cargo.toml Cargo.lock"
release:
name: Release assets-${{ matrix.target }}
runs-on: ubuntu-latest
needs: bump-version
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: Compile and upload
uses: rust-build/rust-build.action@v1.4.5
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
RUSTTARGET: ${{ matrix.target }}
ARCHIVE_TYPES: ${{ matrix.archive }}
image:
name: Publish docker image${{ matrix.suffix }}
runs-on: ubuntu-latest
needs: bump-version
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: 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 }}
tags: |
type=raw,value=latest,suffix=${{ matrix.suffix }}
type=semver,pattern={{version}},suffix=${{ matrix.suffix }}
- 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 }}