release: enforce source qualification contract

This commit is contained in:
DeFiDude committed 2026-08-17 00:10:21 -06:00
1 parent d9a1024a16
commit ccf2f11419
16 files changed
+204 -11

No files matched your search

+2
View File
@@ -46,6 +46,8 @@ jobs:
components: clippy, rustfmt
- name: Install system deps
run: sudo apt-get update && sudo apt-get install -y libudev-dev libdbus-1-dev libpcsclite-dev pkg-config
- name: Check source-release contract
run: python3 scripts/ci/check_source_release_contract.py
- run: cargo fmt --all -- --check
- run: cargo clippy --workspace --all-targets --all-features --locked -- -D warnings
- name: Check public API documentation
+24 -8
View File
@@ -19,8 +19,22 @@ env:
RETICULUM_BINS: rnsd-rs rnstatus-rs rnpath-rs rnid-rs rnprobe-rs rncp-rs rnsh-rs rnodeconf-rs
jobs:
verify:
name: Verify release source
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09 # v5
with:
ref: ${{ env.RELEASE_TAG }}
- uses: dtolnay/rust-toolchain@6c977a6ca4077a0ceb28ffbe03f59d46e9ac8772 # master
with:
toolchain: 1.85.0
- run: python3 scripts/ci/check_source_release_contract.py --release-tag "${RELEASE_TAG}"
build:
name: Build ${{ matrix.artifact_suffix }}
needs: verify
timeout-minutes: 30
strategy:
fail-fast: false
@@ -39,18 +53,20 @@ jobs:
env:
ARCHIVE_NAME: rsReticulum-${{ github.event.inputs.tag_name || github.ref_name }}-${{ matrix.artifact_suffix }}
steps:
- uses: actions/checkout@v5
- uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09 # v5
with:
ref: ${{ env.RELEASE_TAG }}
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- uses: dtolnay/rust-toolchain@6c977a6ca4077a0ceb28ffbe03f59d46e9ac8772 # master
with:
toolchain: 1.85.0
- uses: Swatinem/rust-cache@6323deb102c322ba6fcbdcafc7e3dddab59af2b6 # v2
with:
cache-bin: false
- name: Install system deps (Linux)
if: runner.os == 'Linux'
run: sudo apt-get update && sudo apt-get install -y libudev-dev libdbus-1-dev pkg-config
- name: Build release binaries
run: cargo build -p rns-tools --release --bins
run: cargo build -p rns-tools --release --bins --locked
- name: Stage archive contents
shell: bash
run: |
@@ -63,7 +79,7 @@ jobs:
cp "target/release/${bin}" "dist/${PACKAGE_ROOT}/bin/${bin}"
fi
done
cp README.md LICENSE "dist/${PACKAGE_ROOT}/"
cp README.md LICENSE CHANGELOG.md RELEASING.md "dist/${PACKAGE_ROOT}/"
- name: Create tar archive
if: runner.os != 'Windows'
shell: bash
@@ -72,7 +88,7 @@ jobs:
if: runner.os == 'Windows'
shell: pwsh
run: Compress-Archive -Path "dist/${env:PACKAGE_ROOT}" -DestinationPath "${env:ARCHIVE_NAME}.zip" -Force
- uses: actions/upload-artifact@v7
- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
with:
name: ${{ env.ARCHIVE_NAME }}
path: |
@@ -87,14 +103,14 @@ jobs:
permissions:
contents: write
steps:
- uses: actions/download-artifact@v7
- uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131 # v7
with:
path: release-assets
merge-multiple: true
- name: Generate checksums
working-directory: release-assets
run: sha256sum * > SHA256SUMS
- uses: softprops/action-gh-release@v3
- uses: softprops/action-gh-release@3d0d9888cb7fd7b750713d6e236d1fcb99157228 # v3
with:
tag_name: ${{ env.RELEASE_TAG }}
prerelease: ${{ contains(env.RELEASE_TAG, '-') }}
+4
View File
@@ -2,6 +2,10 @@
## Unreleased
- Made source releases reproducible from an existing immutable component tag:
packages are non-publishable by default, release builds use the committed
lockfile and Rust 1.85.0, actions are commit-pinned, and CI verifies the
manifest, changelog, tag, and checkout contract.
- Isolate exact announce subscriptions from legacy aspect-wide deregistration,
and resolve finite destination identities through validated recall plus
deadline-bounded path discovery instead of temporary announce handlers.
+3 -3
View File
@@ -51,7 +51,7 @@ Build the tools:
```bash
cd rsReticulum
cargo build --release
cargo build --release --locked
```
### Linux, Raspberry Pi, and VPS Hosts
@@ -81,7 +81,7 @@ sudo pacman -S --needed base-devel pkgconf
```bash
cd rsReticulum
cargo build --release
cargo build --release --locked
```
### Windows
@@ -93,7 +93,7 @@ Build from PowerShell:
```powershell
cd rsReticulum
cargo build --release
cargo build --release --locked
```
After the build, use the commands below with `./target/release/<tool>` on
+24
View File
@@ -0,0 +1,24 @@
# Source release policy
rsReticulum source releases are built from immutable Git history. A release is
identified by an annotated `vX.Y.Z` tag whose version matches the workspace
package version and a dated `X.Y.Z` section in `CHANGELOG.md`.
Before creating a tag:
1. Move the relevant `Unreleased` changelog entries into a dated version
section.
2. Set the workspace version to that same semantic version.
3. Run `python3 scripts/ci/check_source_release_contract.py` and the normal CI
suite with the committed `Cargo.lock`.
4. Create the tag only after the release commit is final. Published tags are
immutable and must not be retargeted.
The release workflow checks out the requested existing tag, verifies that the
tag, manifest, changelog, and checked-out commit agree, and builds with
`--locked` on Rust 1.85.0. Release artifacts include this policy and the
changelog alongside the README and license.
All workspace packages are intentionally marked `publish = false`. Changing
that safeguard requires a separate package-distribution decision; a source
release does not change it.
+1
View File
@@ -1,6 +1,7 @@
[package]
name = "rns-crypto"
description = "Cryptographic primitives for Reticulum"
publish = false
version.workspace = true
edition.workspace = true
rust-version.workspace = true
+1
View File
@@ -1,6 +1,7 @@
[package]
name = "rns-identity"
description = "Identity, Destination, and Announce system for Reticulum"
publish = false
version.workspace = true
edition.workspace = true
rust-version.workspace = true
+1
View File
@@ -1,6 +1,7 @@
[package]
name = "rns-interface"
description = "Network interface trait and implementations for Reticulum"
publish = false
version.workspace = true
edition.workspace = true
rust-version.workspace = true
+1
View File
@@ -1,6 +1,7 @@
[package]
name = "rns-link"
description = "Link layer and encrypted channel for Reticulum"
publish = false
version.workspace = true
edition.workspace = true
rust-version.workspace = true
+1
View File
@@ -1,6 +1,7 @@
[package]
name = "rns-protocol"
description = "Resource, Channel, and Buffer protocols for Reticulum"
publish = false
version.workspace = true
edition.workspace = true
rust-version.workspace = true
+1
View File
@@ -1,6 +1,7 @@
[package]
name = "rns-ratkey"
description = "Hardware-backed identity (YubiKey/Nitrokey PIV) for Reticulum"
publish = false
version.workspace = true
edition.workspace = true
license.workspace = true
+1
View File
@@ -1,6 +1,7 @@
[package]
name = "rns-runtime"
description = "Core runtime, config parsing, and lifecycle for Reticulum"
publish = false
version.workspace = true
edition.workspace = true
rust-version.workspace = true
+1
View File
@@ -1,6 +1,7 @@
[package]
name = "rns-tools"
description = "Rust CLI utilities for Reticulum (rnsd-rs, rnstatus-rs, etc.)"
publish = false
version.workspace = true
edition.workspace = true
rust-version.workspace = true
+1
View File
@@ -1,6 +1,7 @@
[package]
name = "rns-transport"
description = "Transport and routing engine for Reticulum"
publish = false
version.workspace = true
edition.workspace = true
rust-version.workspace = true
+1
View File
@@ -1,6 +1,7 @@
[package]
name = "rns-wire"
description = "Wire format, packet encoding, and hash computation for Reticulum"
publish = false
version.workspace = true
edition.workspace = true
rust-version.workspace = true
+137
View File
@@ -0,0 +1,137 @@
#!/usr/bin/env python3
"""Validate rsReticulum's source-release invariants."""
from __future__ import annotations
import argparse
import json
import re
import subprocess
from pathlib import Path
ROOT = Path(__file__).resolve().parents[2]
EXPECTED_RUST_VERSION = "1.85"
SHA_PATTERN = re.compile(r"^[0-9a-f]{40}$")
def fail(message: str) -> None:
raise SystemExit(f"source-release contract failed: {message}")
def command(*args: str) -> str:
return subprocess.check_output(args, cwd=ROOT, text=True).strip()
def metadata() -> dict[str, object]:
output = command(
"cargo",
"metadata",
"--format-version",
"1",
"--locked",
"--no-deps",
)
return json.loads(output)
def check_packages(document: dict[str, object]) -> str:
packages = document["packages"]
assert isinstance(packages, list)
versions = {package["version"] for package in packages}
if len(versions) != 1:
fail(f"workspace packages do not share one version: {sorted(versions)}")
problems = []
for package in packages:
name = package["name"]
if package["publish"] != []:
problems.append(f"{name} is not marked publish = false")
if package["rust_version"] != EXPECTED_RUST_VERSION:
problems.append(
f"{name} exposes rust-version {package['rust_version']!r}, "
f"expected {EXPECTED_RUST_VERSION!r}"
)
if problems:
fail("; ".join(problems))
return str(versions.pop())
def check_release_workflow() -> None:
workflow = (ROOT / ".github/workflows/release.yml").read_text()
action_uses = re.findall(r"^\s*-\s+uses:\s+([^\s#]+)", workflow, re.MULTILINE)
for action in action_uses:
if action.startswith("./"):
continue
if "@" not in action or not SHA_PATTERN.fullmatch(action.rsplit("@", 1)[1]):
fail(f"release action is not pinned to a commit: {action}")
if not re.search(r"^\s*toolchain:\s*1\.85\.0\s*$", workflow, re.MULTILINE):
fail("release workflow does not select Rust 1.85.0")
if "ref: ${{ env.RELEASE_TAG }}" not in workflow:
fail("release workflow does not check out RELEASE_TAG")
release_builds = [
line.strip()
for line in workflow.splitlines()
if "cargo build" in line and "--release" in line
]
if not release_builds or any("--locked" not in line for line in release_builds):
fail("every release Cargo build must use --locked")
def check_documentation(version: str) -> None:
changelog = (ROOT / "CHANGELOG.md").read_text()
if not re.search(r"^## Unreleased\s*$", changelog, re.MULTILINE):
fail("CHANGELOG.md is missing an Unreleased section")
if not re.search(
rf"^## {re.escape(version)} - \d{{4}}-\d{{2}}-\d{{2}}\s*$",
changelog,
re.MULTILINE,
):
fail(f"CHANGELOG.md is missing the current {version} release section")
readme = (ROOT / "README.md").read_text()
unlocked = re.findall(
r"^.*cargo build --release(?![^\n]*--locked).*$", readme, re.MULTILINE
)
if unlocked:
fail("README.md contains an unlocked release build command")
def check_release_tag(release_tag: str, version: str) -> None:
expected_tag = f"v{version}"
if release_tag != expected_tag:
fail(f"release tag {release_tag!r} does not match {expected_tag!r}")
try:
tag_type = command("git", "cat-file", "-t", release_tag)
except subprocess.CalledProcessError:
fail(f"release tag {release_tag!r} is not present in this checkout")
if tag_type != "tag":
fail(f"release tag {release_tag!r} must be an annotated tag")
head = command("git", "rev-parse", "HEAD")
try:
tagged_commit = command("git", "rev-list", "-n", "1", release_tag)
except subprocess.CalledProcessError:
fail(f"release tag {release_tag!r} is not present in this checkout")
if head != tagged_commit:
fail(f"HEAD {head} is not the commit named by {release_tag} ({tagged_commit})")
def main() -> None:
parser = argparse.ArgumentParser()
parser.add_argument("--release-tag")
args = parser.parse_args()
version = check_packages(metadata())
check_release_workflow()
check_documentation(version)
if args.release_tag:
check_release_tag(args.release_tag, version)
print(f"source-release contract passed for rsReticulum {version}")
if __name__ == "__main__":
main()