Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
# dyode-<version>-src.tar.gz source + Cargo.lock + vendored crates
#
# Runs on tags, by hand ("Run workflow"), and on pull requests that change
# the installer or the build tools.
# the installer or the build tools. On a tag it first runs
# tools/check_release.sh: the tag, Cargo.toml and a dated CHANGELOG.md
# heading must agree, or nothing is built.
name: Release / offline bundle

on:
Expand Down Expand Up @@ -40,6 +42,17 @@ jobs:
version: ${{ steps.v.outputs.version }}
steps:
- uses: actions/checkout@v4
# Before anything is built: Cargo.toml and a dated CHANGELOG heading
# must match the tag (a release once shipped as "- unreleased").
- name: Release check (tag, Cargo.toml, CHANGELOG.md)
if: startsWith(github.ref, 'refs/tags/')
run: tools/check_release.sh "${GITHUB_REF_NAME}"
- name: Release check preview (does not fail a pull request)
if: "!startsWith(github.ref, 'refs/tags/')"
run: |
v="$(sed -n 's/^version = "\(.*\)"/\1/p' Cargo.toml | head -1)"
tools/check_release.sh "v$v" ||
echo "::notice::tagging v$v now would fail the release check: date its CHANGELOG.md heading first"
- uses: dtolnay/rust-toolchain@stable
- id: v
run: echo "version=$(sed -n 's/^version = \"\(.*\)\"/\1/p' Cargo.toml | head -1)" >> "$GITHUB_OUTPUT"
Expand Down
10 changes: 9 additions & 1 deletion docs/OFFLINE.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,11 @@ is a one-line change to `tools/build_binary.sh`.
`.github/workflows/release.yml`, on every tag (and by hand, and on pull
requests that touch the installer or tools):

1. **source** -- `cargo generate-lockfile` (if needed) and `cargo vendor`, into
1. **source** -- on a tag, first `tools/check_release.sh`: the tag,
Cargo.toml's version and a *dated* CHANGELOG.md heading
(`## [2.1.0] - 2026-10-28`, the newest one) must agree, or nothing is
built. Pull requests get the same check as a notice only. Then
`cargo generate-lockfile` (if needed) and `cargo vendor`, into
`dyode-<version>-src.tar.gz`.
2. **binary** -- the binaries are built *from that vendored source with
`--offline`*, in a Debian 12 container with no network, on native amd64
Expand All @@ -93,6 +97,10 @@ requests that touch the installer or tools):
6. **publish** (tags only) -- the bundle, the source tarball and the bare
binaries are attached to the release, with `SHA256SUMS`.

To release: set the version in Cargo.toml, date its CHANGELOG.md heading,
merge, check locally with `tools/check_release.sh vX.Y.Z`, then tag
`vX.Y.Z` on main.

By hand, on a machine with internet and Docker:

```bash
Expand Down
48 changes: 48 additions & 0 deletions tools/check_release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#!/usr/bin/env bash
# Check that a release is ready to publish, before anything is built:
#
# tools/check_release.sh v2.1.0 (the release workflow passes the tag)
#
# - Cargo.toml's version is the tag's version;
# - CHANGELOG.md has a dated heading for it, "## [2.1.0] - 2026-10-28",
# not "- unreleased", with a real date;
# - that heading is the newest versioned one (only "## [Unreleased]" may
# come before it).
#
# Exits 1 with a message naming what to fix.
set -euo pipefail

ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
CHANGELOG="${CHANGELOG:-$ROOT/CHANGELOG.md}"
CARGO="${CARGO_TOML:-$ROOT/Cargo.toml}"

[ $# -eq 1 ] || { echo "usage: $0 vX.Y.Z" >&2; exit 2; }
version="${1#refs/tags/}"
version="${version#v}"
fail=0
err() { printf 'release check: %s\n' "$*" >&2; fail=1; }

[[ "$version" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z.]+)?$ ]] || { err "tag '$1' is not vX.Y.Z"; exit 1; }

cargo_version="$(sed -n 's/^version = "\(.*\)"/\1/p' "$CARGO" | head -1)"
[ "$cargo_version" = "$version" ] ||
err "Cargo.toml says version $cargo_version, the tag says $version"

esc="${version//./\\.}"
heading="$(grep -E "^## \[$esc\]" "$CHANGELOG" | head -1 || true)"
if [ -z "$heading" ]; then
err "CHANGELOG.md has no '## [$version] - YYYY-MM-DD' heading"
else
date="$(sed -nE 's/^## \[[^]]+\] - ([0-9]{4}-[0-9]{2}-[0-9]{2})[[:space:]]*$/\1/p' <<<"$heading")"
if [ -z "$date" ]; then
err "CHANGELOG.md heading '$heading' has no date: write '## [$version] - $(date -u +%F)'"
elif ! date -u -d "$date" +%F >/dev/null 2>&1 || [ "$(date -u -d "$date" +%F)" != "$date" ]; then
err "CHANGELOG.md heading '$heading': $date is not a real date"
fi
first="$(grep -E '^## \[' "$CHANGELOG" | grep -viE '^## \[unreleased\]' | head -1)"
[ "$first" = "$heading" ] ||
err "'$heading' is not the newest release in CHANGELOG.md (the first is '$first')"
fi

[ "$fail" -eq 0 ] && echo "release check: $version ready (Cargo.toml and CHANGELOG.md agree, dated $date)"
exit "$fail"
Loading