LINE1 10 20 30 40 50 60 70 80 90 1001#!/usr/bin/env bash2set -euo pipefail34#MISE description="Cut a release: bump the patch version in Cargo.toml, then build & push silenloc/dial:<v>"5# Always run, even if nothing changed: no `sources`/`outputs` markers, which6# would otherwise let mise cache-skip the task. Releasing must always bump,7# build and push.89# Cut a release from a clean worktree:10# 1. Bump the patch component of [package].version and update Cargo.lock.11# 2. Verify the crate, then commit and push only the two version files.12# 3. `docker buildx build --push` builds the image from the Dockerfile using13# the new version and streams it straight to the registry (expects14# `docker login` to be configured already).15#16# `--provenance=false` keeps the result a plain single-arch manifest.17# Releases use `docker build` rather than `mise oci build` because the18# experimental OCI builder cannot RUN commands.1920# 1. Read the current version from Cargo.toml's [package].version line.21if [[ -n "$(git status --porcelain)" ]]; then22 echo "release requires a clean worktree; commit or stash existing changes first" >&223 exit 124fi2526v=$(awk '/^\[package\]/ { p=1; next }27 p && /^version = / { sub(/^version = /, ""); gsub(/"/, ""); print; exit }' Cargo.toml)2829# 2. Compute the next patch version.30major=$(echo "$v" | cut -d. -f1)31minor=$(echo "$v" | cut -d. -f2)32patch=$(echo "$v" | cut -d. -f3)33patch=$((patch + 1))34nv="$major.$minor.$patch"3536# 3. Rewrite the first `version = "..."` line under [package] in-place.37awk -v new="$nv" '38 /^\[package\]/ { p=1; print; next }39 p && /^version = / { $0 = "version = \"" new "\""; p=0 }40 { print }41' Cargo.toml > Cargo.toml.tmp && mv Cargo.toml.tmp Cargo.toml4243# 4. Resolve the new version into Cargo.lock and verify the crate.44cargo check4546# 5. Commit and push only the release version files. Do this before publishing47# the image so a failed Git push cannot leave an untracked image release.48git add Cargo.toml Cargo.lock49git commit -m "chore: release $nv"50git push5152# 6. Build the release image and push it as silenloc/dial:<nv> in one pass.53docker buildx build --provenance=false --push -t "silenloc/dial:$nv" -t "silenloc/dial:latest" .5455echo "bumped Cargo.toml to $nv; released silenloc/dial:$nv"