Simplify release candidate validation

This commit is contained in:
2026-09-28 01:47:20 +00:00
parent 3695303100
commit 65502ce5b4
4 changed files with 102 additions and 76 deletions

View File

@@ -73,7 +73,7 @@ for target in linux/amd64 linux/arm64 darwin/arm64; do
target_os=${target%%/*}
target_arch=${target#*/}
asset_path="$output_dir/narratio-$release_version-$target_os-$target_arch"
CGO_ENABLED=0 GOOS="$target_os" GOARCH="$target_arch" go build -trimpath -ldflags "$build_flags" -o "$asset_path" ./cmd/narratio
CGO_ENABLED=0 GOOS="$target_os" GOARCH="$target_arch" go build -mod=readonly -trimpath -ldflags "$build_flags" -o "$asset_path" ./cmd/narratio
if [ "$target_os" = "$host_os" ] && [ "$target_arch" = "$host_arch" ]; then
host_asset=$asset_path
fi
@@ -81,7 +81,7 @@ done
if [ -z "$host_asset" ]; then
temporary_smoke_binary="$output_dir/.narratio-release-version-smoke"
CGO_ENABLED=0 go build -trimpath -ldflags "$build_flags" -o "$temporary_smoke_binary" ./cmd/narratio
CGO_ENABLED=0 go build -mod=readonly -trimpath -ldflags "$build_flags" -o "$temporary_smoke_binary" ./cmd/narratio
host_asset=$temporary_smoke_binary
fi

View File

@@ -29,25 +29,14 @@ note_heading=$(sed -n '1p' "$release_note")
if [ "$note_heading" != "# Narratio $release_version" ]; then
narratio_release_fail "$tool_name" "release note must begin with # Narratio $release_version"
fi
for required_heading in '## Summary' '## Compatibility' '## Upgrade' '## Changes'; do
if ! grep -Fqx "$required_heading" "$release_note"; then
narratio_release_fail "$tool_name" "release note is missing required heading: $required_heading"
fi
done
if ! grep -Eq '^module[[:space:]]+gitea\.maximumdirect\.net/eric/narratio[[:space:]]*$' go.mod; then
narratio_release_fail "$tool_name" 'go.mod must declare module gitea.maximumdirect.net/eric/narratio'
fi
for workspace_file in go.work go.work.sum; do
if git ls-files --error-unmatch "$workspace_file" >/dev/null 2>&1; then
narratio_release_fail "$tool_name" "tracked workspace file is not allowed: $workspace_file"
fi
done
if [ -d vendor ]; then
narratio_release_fail "$tool_name" 'vendor directory is not allowed'
if ! local_replacements=$(GOWORK=off go list -m -mod=readonly -f '{{if .Replace}}{{if not .Replace.Version}}{{.Path}}{{end}}{{end}}' all); then
narratio_release_fail "$tool_name" 'failed: go list -m replacement metadata'
fi
if grep -Eq '^[[:space:]]*replace[[:space:]]' go.mod; then
narratio_release_fail "$tool_name" 'go.mod replace directives are not allowed'
if [ -n "$local_replacements" ]; then
narratio_release_fail "$tool_name" "filesystem module replacements are not allowed: $local_replacements"
fi
narratio_release_go() {
@@ -68,12 +57,8 @@ if ! git diff --cached --check; then
narratio_release_fail "$tool_name" 'cached whitespace check failed'
fi
narratio_release_go test -count=1 ./...
narratio_release_go test -race -count=1 ./...
narratio_release_go vet ./...
narratio_release_go build ./...
narratio_release_go test -count=1 ./internal/doccheck
narratio_release_go test -count=1 ./internal/config -run '^TestExamplesLoadAndValidate$'
narratio_release_go test -mod=readonly -race -count=1 ./...
narratio_release_go vet -mod=readonly ./...
temporary_assets_dir=$(mktemp -d "${TMPDIR:-/tmp}/narratio-release-candidate.XXXXXX") || narratio_release_fail "$tool_name" 'cannot create temporary asset directory'
case $temporary_assets_dir in