name: Release
on:
release:
types: [published]
permissions:
contents: read
concurrency:
group: ${{ github.workflow }}-${{ github.event.release.tag_name }}
cancel-in-progress: false
env:
CARGO_TERM_COLOR: always
jobs:
publish-crate:
name: Publish crate to crates.io
runs-on: ubuntu-latest
timeout-minutes: 20
environment: release
permissions:
contents: read
id-token: write
steps:
- name: Checkout repository
uses: actions/checkout@v6.0.3
with:
persist-credentials: false
- name: Set up Rust toolchain
uses: dtolnay/rust-toolchain@v1
with:
toolchain: stable
- name: Cache Rust dependencies
uses: Swatinem/rust-cache@v2.9.1
- name: Verify release tag matches crate version
run: |
VERSION=$(cargo metadata --format-version 1 --no-deps | jq -r '.packages[] | select(.name == "venice-e2ee-proxy") | .version')
if [ "${GITHUB_REF_NAME}" != "v${VERSION}" ] && [ "${GITHUB_REF_NAME}" != "${VERSION}" ]; then
echo "Release tag ${GITHUB_REF_NAME} does not match crate version ${VERSION}" >&2
exit 1
fi
- name: Verify crate can be published
run: cargo publish --locked --dry-run
- name: Authenticate to crates.io
id: auth
uses: rust-lang/crates-io-auth-action@v1.0.4
- name: Publish crate
run: cargo publish --locked
env:
CARGO_REGISTRY_TOKEN: ${{ steps.auth.outputs.token }}
publish-docker:
name: Publish Docker image to GHCR
runs-on: ubuntu-latest
timeout-minutes: 60
environment: release
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v6.0.3
with:
persist-credentials: false
- name: Set up QEMU
uses: docker/setup-qemu-action@v4.1.0
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4.1.0
- name: Log in to GHCR
uses: docker/login-action@v4.2.0
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Compute image name
id: image
run: echo "name=ghcr.io/${GITHUB_REPOSITORY,,}" >> "$GITHUB_OUTPUT"
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v6.1.0
with:
images: ${{ steps.image.outputs.name }}
tags: |
type=raw,value=${{ github.event.release.tag_name }}
type=raw,value=latest,enable=${{ !github.event.release.prerelease }}
- name: Build and push Docker image
uses: docker/build-push-action@v7.2.0
with:
context: .
push: true
platforms: linux/amd64,linux/arm64
pull: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
provenance: true
sbom: true