Complete rehearsal guidance and integrated verification

This commit is contained in:
2026-12-05 23:48:37 +00:00
parent 3524d8bbb6
commit dd9e177420
23 changed files with 739 additions and 32 deletions

View File

@@ -2,9 +2,8 @@
ReleaseKit is an opinionated Go library and executable for a shared release
process. The Go module, root `releasekit` facade, `buildinfo` runtime package,
local candidate check, source-tag publication API, selected-target build API,
tagged-source delivery API, and the `version`, `check`, `publish`, `build`,
`deliver`, and `ci-deliver` commands are implemented. ReleaseKit's source-only
local candidate check, source-tag publication, selected-target build, tagged
delivery, readiness, and rehearsal APIs and commands are implemented. ReleaseKit's source-only
maintainer procedure and prepared Woodpecker workflow for hosted note-page
delivery are documented. ReleaseKit does not declare binary deliverables.
@@ -14,9 +13,9 @@ explains the v0.5.0 migration from the original Gitea module path.
The [v0.6.0 release note](docs/releases/v0.6.0.md) describes the delivery API
and profile migration.
Release operations can select one Go module within a repository. The repository
root remains the default; a selected module's declared import path and physical
directory determine its complete Git tag and module-local release note. See the
Release operations can select a Go module or a general source directory within a
repository. The repository root remains the default; the selected publication
mode determines the complete Git tag and release-note location. See the
[candidate check](docs/consumers/check.md),
[publication](docs/consumers/publish.md), and
[multi-module example](examples/multi-module/).
@@ -40,8 +39,7 @@ go run ./cmd/releasekit version
```
The local candidate check validates a committed release note, runs the standard
offline Go suite with any selected shared validation checks, and then runs
configured product checks:
offline Go suite when Go is selected, and runs selected shared and product checks:
```sh
go run ./cmd/releasekit check v1.2.3
@@ -62,8 +60,8 @@ failure recovery.
dependencies, upgrades, and CI adoption.
- [Contributor guide](docs/development.md): orientation, validation, and selective
policy reading.
- [CLI contract](docs/cli.md): the `version`, `check`, `publish`, `build`,
`deliver`, and `ci-deliver` commands.
- [CLI contract](docs/cli.md): candidate, publication, delivery, readiness,
rehearsal, and recovery commands.
- [Configuration](docs/config.md): profile fields and child-command settings.
- [Runtime version guidance](docs/consumers/runtime-version.md): how applications
read their embedded version through `buildinfo`.
@@ -71,6 +69,9 @@ failure recovery.
injected application version.
- [Delivery guidance](docs/consumers/delivery.md): deliver tagged source and
report hosted page and asset status.
- [Readiness guidance](docs/consumers/readiness.md) and
[rehearsal guidance](docs/consumers/rehearsal.md): inspect setup and exercise
the tagged delivery workflow with temporary resources.
- [Gitea integration](docs/integrations/gitea.md): hosted release-page
operations and their failure behavior.
- [Candidate check guidance](docs/consumers/check.md): local candidate validation

View File

@@ -0,0 +1,381 @@
package main
import (
"bytes"
"encoding/json"
"fmt"
"io"
"net/http"
"net/http/httptest"
"net/url"
"os"
"os/exec"
"path/filepath"
"runtime"
"strconv"
"strings"
"sync"
"testing"
)
type assembledPage struct {
id int64
tag, commit, title, body string
assets map[string][]byte
}
type assembledForge struct {
mu sync.Mutex
remote string
pages map[string]*assembledPage
nextID int64
}
func (f *assembledForge) serve(w http.ResponseWriter, r *http.Request) {
if r.Header.Get("Authorization") != "token fixture-token" {
http.Error(w, "forbidden", 403)
return
}
const root = "/api/v1/repos/owner/example"
path := r.URL.EscapedPath()
if path == root || path == "/api/v1/repositories/1" {
json.NewEncoder(w).Encode(map[string]any{"id": 1, "name": "example", "full_name": "owner/example", "owner": map[string]string{"login": "owner"}})
return
}
if strings.HasPrefix(path, root+"/tags/") {
tag, err := url.PathUnescape(strings.TrimPrefix(path, root+"/tags/"))
if err != nil {
http.Error(w, "bad tag", 400)
return
}
out, err := exec.Command("git", "--git-dir", f.remote, "rev-parse", "--verify", "refs/tags/"+tag+"^{commit}").Output()
if err != nil {
http.NotFound(w, r)
return
}
json.NewEncoder(w).Encode(map[string]any{"commit": map[string]string{"sha": strings.TrimSpace(string(out))}})
return
}
f.mu.Lock()
defer f.mu.Unlock()
encode := func(p *assembledPage) {
json.NewEncoder(w).Encode(map[string]any{"id": p.id, "tag_name": p.tag, "target_commitish": p.commit, "name": p.title, "body": p.body, "html_url": "http://" + r.Host + "/release", "draft": false, "prerelease": false})
}
if strings.HasPrefix(path, root+"/releases/tags/") {
tag, _ := url.PathUnescape(strings.TrimPrefix(path, root+"/releases/tags/"))
p := f.pages[tag]
if p == nil {
http.NotFound(w, r)
return
}
encode(p)
return
}
if path == root+"/releases" && r.Method == http.MethodPost {
var request struct {
Tag string `json:"tag_name"`
Commit string `json:"target_commitish"`
Title string `json:"name"`
Body string `json:"body"`
}
if err := json.NewDecoder(r.Body).Decode(&request); err != nil {
http.Error(w, "bad request", 400)
return
}
f.nextID++
p := &assembledPage{id: f.nextID, tag: request.Tag, commit: request.Commit, title: request.Title, body: request.Body, assets: map[string][]byte{}}
f.pages[p.tag] = p
encode(p)
return
}
if strings.HasPrefix(path, root+"/releases/") {
remainder := strings.TrimPrefix(path, root+"/releases/")
parts := strings.Split(remainder, "/")
id, _ := strconv.ParseInt(parts[0], 10, 64)
var page *assembledPage
for _, candidate := range f.pages {
if candidate.id == id {
page = candidate
break
}
}
if page == nil {
http.NotFound(w, r)
return
}
if len(parts) == 1 {
if r.Method == http.MethodDelete {
delete(f.pages, page.tag)
w.WriteHeader(204)
return
}
encode(page)
return
}
if len(parts) == 2 && parts[1] == "assets" {
if r.Method == http.MethodGet {
list := []map[string]any{}
for name, data := range page.assets {
list = append(list, map[string]any{"id": len(list) + 1, "name": name, "size": len(data), "browser_download_url": fmt.Sprintf("http://%s/files/%d/%s", r.Host, page.id, url.PathEscape(name))})
}
json.NewEncoder(w).Encode(list)
return
}
file, _, err := r.FormFile("attachment")
if err != nil {
http.Error(w, "bad upload", 400)
return
}
data, err := io.ReadAll(file)
file.Close()
if err != nil {
http.Error(w, "read upload", 500)
return
}
name := r.URL.Query().Get("name")
page.assets[name] = data
json.NewEncoder(w).Encode(map[string]any{"id": len(page.assets), "name": name, "size": len(data)})
return
}
}
if strings.HasPrefix(path, "/files/") {
parts := strings.SplitN(strings.TrimPrefix(path, "/files/"), "/", 2)
if len(parts) != 2 {
http.NotFound(w, r)
return
}
id, _ := strconv.ParseInt(parts[0], 10, 64)
name, _ := url.PathUnescape(parts[1])
for _, p := range f.pages {
if p.id == id {
if content, ok := p.assets[name]; ok {
w.Write(content)
return
}
}
}
http.NotFound(w, r)
return
}
http.NotFound(w, r)
}
type assembledCI struct {
mu sync.Mutex
t *testing.T
remote, binary, tag, commit string
log []byte
jobErr error
executed bool
}
func (ci *assembledCI) serve(w http.ResponseWriter, r *http.Request) {
if r.Header.Get("Authorization") != "Bearer wood-token" {
http.Error(w, "forbidden", 403)
return
}
switch r.URL.Path {
case "/api/repos/42":
fmt.Fprint(w, `{"id":42}`)
return
case "/api/repos/42/pipelines":
if r.URL.Query().Get("page") != "1" {
fmt.Fprint(w, `[]`)
return
}
ref := r.URL.Query().Get("ref")
if !strings.HasPrefix(ref, "refs/tags/releasekit-test/") {
fmt.Fprint(w, `[]`)
return
}
ci.mu.Lock()
defer ci.mu.Unlock()
if !ci.executed {
ci.tag = strings.TrimPrefix(ref, "refs/tags/")
ci.runJob()
}
status := "success"
if ci.jobErr != nil {
status = "failure"
}
json.NewEncoder(w).Encode([]map[string]any{{"id": 10, "number": 11, "event": "tag", "ref": ref, "commit": ci.commit, "status": status}})
return
case "/api/repos/42/pipelines/11":
ci.mu.Lock()
defer ci.mu.Unlock()
status := "success"
if ci.jobErr != nil {
status = "failure"
}
json.NewEncoder(w).Encode(map[string]any{"id": 10, "number": 11, "event": "tag", "ref": "refs/tags/" + ci.tag, "commit": ci.commit, "status": status, "workflows": []any{map[string]any{"id": 12, "name": "delivery", "state": status, "children": []any{map[string]any{"id": 13, "name": "deliver", "state": status}}}}})
return
case "/api/repos/42/logs/11/13/download":
ci.mu.Lock()
defer ci.mu.Unlock()
w.Write(ci.log)
return
default:
http.NotFound(w, r)
}
}
func (ci *assembledCI) runJob() {
ci.executed = true
command := exec.Command("git", "--git-dir", ci.remote, "rev-parse", "--verify", "refs/tags/"+ci.tag+"^{commit}")
commit, err := command.Output()
if err != nil {
ci.jobErr = err
return
}
ci.commit = strings.TrimSpace(string(commit))
checkout := filepath.Join(ci.t.TempDir(), "job")
command = exec.Command("git", "clone", "--no-checkout", "--local", ci.remote, checkout)
if out, err := command.CombinedOutput(); err != nil {
ci.jobErr = fmt.Errorf("clone job checkout: %w: %s", err, out)
return
}
command = exec.Command("git", "checkout", "--detach", ci.commit)
command.Dir = checkout
if out, err := command.CombinedOutput(); err != nil {
ci.jobErr = fmt.Errorf("checkout job: %w: %s", err, out)
return
}
command = exec.Command(ci.binary, "ci-deliver", "--repo", checkout, "--prepared", "--commit", ci.commit, ci.tag)
command.Dir = checkout
command.Env = append(os.Environ(), "RELEASEKIT_GITEA_TOKEN=fixture-token", "GOTOOLCHAIN=local", "GOPROXY=off", "GOSUMDB=off")
ci.log, ci.jobErr = command.CombinedOutput()
}
func TestAssembledPublicationAndRehearsalWorkflows(t *testing.T) {
root := cliRepositoryRoot(t)
binary := buildWorkflowCLI(t, root)
for _, test := range []struct {
name, version string
goEnabled, explicit, binary bool
}{
{name: "legacy-module", version: "v1.2.3", goEnabled: true},
{name: "go-application-source", version: "v2.0.0", goEnabled: true, explicit: true},
{name: "calendar-binary", version: "2026-12-05", goEnabled: true, explicit: true, binary: true},
{name: "configuration", version: "2026-12-05", explicit: true},
} {
t.Run(test.name, func(t *testing.T) {
repo := filepath.Join(t.TempDir(), "product")
if err := os.Mkdir(repo, 0700); err != nil {
t.Fatal(err)
}
cliGitRun(t, repo, "init", "--initial-branch=main")
cliGitRun(t, repo, "config", "user.name", "ReleaseKit Test")
cliGitRun(t, repo, "config", "user.email", "releasekit@example.test")
cliGitRun(t, repo, "config", "commit.gpgsign", "false")
remote := filepath.Join(t.TempDir(), "origin.git")
cliGitRun(t, repo, "init", "--bare", remote)
cliGitRun(t, repo, "remote", "add", "origin", remote)
state := &assembledForge{remote: remote, pages: map[string]*assembledPage{}}
forgeServer := httptest.NewServer(http.HandlerFunc(state.serve))
defer forgeServer.Close()
runner := &assembledCI{t: t, remote: remote, binary: binary}
ciServer := httptest.NewServer(http.HandlerFunc(runner.serve))
defer ciServer.Close()
writeRepositoryFile(t, repo, ".gitignore", ".releasekit/\n")
writeRepositoryFile(t, repo, "docs/releases/"+test.version+".md", "# Example "+test.version+"\n\nRelease note.\n")
if test.goEnabled {
module := "module example.com/fixture\n\ngo 1.27.0\n"
main := "package fixture\n"
if test.binary {
module += "\nrequire go.maximumdirect.net/releasekit v0.0.0\n\nreplace go.maximumdirect.net/releasekit => " + strconv.Quote(root) + "\n"
main = `package main
import ("fmt"; "os"; "go.maximumdirect.net/releasekit/buildinfo")
func main() { if len(os.Args)==2 && os.Args[1]=="version" {fmt.Println("fixture",buildinfo.Version())} }
`
}
writeRepositoryFile(t, repo, "go.mod", module)
writeRepositoryFile(t, repo, "main.go", main)
if test.binary {
command := exec.Command("go", "mod", "tidy")
command.Dir = repo
command.Env = append(os.Environ(), "GOTOOLCHAIN=local", "GOPROXY=off", "GOSUMDB=off", "GOWORK=off")
if out, err := command.CombinedOutput(); err != nil {
t.Fatalf("prepare binary module: %v: %s", err, out)
}
}
} else {
writeRepositoryFile(t, repo, "config.yaml", "enabled: true\n")
writeRepositoryFile(t, repo, "config.json", `{"enabled":true}`)
}
profile := map[string]any{"product": "Example", "delivery": map[string]any{"forge": "gitea", "base_url": forgeServer.URL, "owner": "owner", "repository": "example", "credentials": map[string]any{"local": map[string]any{"token_file": ".releasekit/forge-token"}, "ci": map[string]any{"token_environment_variable": "RELEASEKIT_GITEA_TOKEN"}}}, "rehearsal": map[string]any{"woodpecker": map[string]any{"base_url": ciServer.URL, "repository_id": 42, "workflow": "delivery", "step": "deliver", "token_file": ".releasekit/ci-token"}}}
if test.explicit {
profile["source"] = map[string]any{}
if test.goEnabled {
profile["go"] = map[string]any{}
}
}
if strings.HasPrefix(test.version, "2026-") {
profile["version"] = map[string]any{"format": "date"}
}
if test.binary {
profile["build"] = map[string]any{"main_package": ".", "binary_name": "fixture", "targets": []string{runtime.GOOS + "/" + runtime.GOARCH}}
}
encoded, err := json.Marshal(profile)
if err != nil {
t.Fatal(err)
}
writeRepositoryFile(t, repo, "releasekit.json", string(encoded))
cliGitRun(t, repo, "add", "--all")
cliGitRun(t, repo, "commit", "-m", "prepare release")
cliGitRun(t, repo, "push", "origin", "HEAD:refs/heads/main")
writeRepositoryFile(t, repo, ".releasekit/forge-token", "fixture-token\n")
writeRepositoryFile(t, repo, ".releasekit/ci-token", "wood-token\n")
t.Setenv("RELEASEKIT_GITEA_TOKEN", "fixture-token")
call := func(args ...string) (int, string, string) {
t.Helper()
var output, diagnostics bytes.Buffer
code := run(t.Context(), args, &output, &diagnostics)
return code, output.String(), diagnostics.String()
}
if code, out, diag := call("validate", "--repo", repo, "--operation", "rehearsal", "--json"); code != 0 {
t.Fatalf("readiness status=%d output=%s diagnostics=%s", code, out, diag)
}
if code, out, diag := call("check", "--repo", repo, test.version); code != 0 {
t.Fatalf("check status=%d output=%s diagnostics=%s", code, out, diag)
}
if code, out, diag := call("publish", "--repo", repo, test.version); code != 0 {
t.Fatalf("publish status=%d output=%s diagnostics=%s", code, out, diag)
}
commit := cliGitOutput(t, repo, "rev-parse", "HEAD")
if code, out, diag := call("ci-deliver", "--repo", repo, "--prepared", "--commit", commit, test.version); code != 0 {
t.Fatalf("production delivery status=%d output=%s diagnostics=%s", code, out, diag)
}
code, out, diag := call("test", "--repo", repo, "--timeout", "30s", "--cleanup-timeout", "10s", "--json")
if code != 0 {
runner.mu.Lock()
jobErr, log := runner.jobErr, string(runner.log)
runner.mu.Unlock()
t.Fatalf("rehearsal status=%d output=%s diagnostics=%s job error=%v job log=%s", code, out, diag, jobErr, log)
}
var report rehearsalDocument
if err := json.Unmarshal([]byte(out), &report); err != nil || report.Verification != "complete" || report.Cleanup != "complete" || report.RecordPath == "" {
t.Fatalf("report=%+v error=%v output=%s", report, err, out)
}
if test.binary && (report.Scope != "page-and-assets" || len(report.Artifacts) != 2) {
t.Fatalf("binary report=%+v", report)
}
if !test.binary && (report.Scope != "page" || len(report.Artifacts) != 0) {
t.Fatalf("page report=%+v", report)
}
if code, out, diag = call("test-resume", "--record", report.RecordPath, "--json"); code != 0 {
t.Fatalf("saved recovery status=%d output=%s diagnostics=%s", code, out, diag)
}
state.mu.Lock()
_, productionExists := state.pages[test.version]
_, diagnosticExists := state.pages[report.Tag]
state.mu.Unlock()
if !productionExists || diagnosticExists {
t.Fatalf("production page present=%t diagnostic page present=%t", productionExists, diagnosticExists)
}
if output, err := exec.Command("git", "--git-dir", remote, "rev-parse", "--verify", "refs/tags/"+report.Tag).CombinedOutput(); err == nil {
t.Fatalf("diagnostic tag remains: %s", output)
}
if output, err := exec.Command("git", "--git-dir", remote, "rev-parse", "--verify", "refs/tags/"+test.version).CombinedOutput(); err != nil {
t.Fatalf("production tag missing: %v: %s", err, output)
}
})
}
}

View File

@@ -175,6 +175,10 @@ func publicationOffersRecovery(phase releasekit.PublicationPhase) bool {
}
func publicationRecoveryCommand(recordPath string) (string, error) {
return executableRecoveryCommand(recordPath, "reconcile")
}
func executableRecoveryCommand(recordPath, command string) (string, error) {
executable, err := os.Executable()
if err != nil {
return "", fmt.Errorf("find current executable: %w", err)
@@ -191,7 +195,7 @@ func publicationRecoveryCommand(recordPath string) (string, error) {
if err != nil {
return "", fmt.Errorf("resolve publication record path: %w", err)
}
return shellQuote(executable) + " reconcile --record " + shellQuote(recordPath), nil
return shellQuote(executable) + " " + command + " --record " + shellQuote(recordPath), nil
}
func shellQuote(argument string) string {

View File

@@ -7,7 +7,6 @@ import (
"fmt"
"io"
"net/http"
"strings"
"go.maximumdirect.net/releasekit"
"go.maximumdirect.net/releasekit/cmd/releasekit/internal/cli"
@@ -227,10 +226,25 @@ func writeRehearsalReport(output io.Writer, invocation cli.Invocation, result re
}
}
if doc.RecordPath != "" {
quoted := "'" + strings.ReplaceAll(doc.RecordPath, "'", `'\''`) + "'"
if _, err := fmt.Fprintf(output, "record: %s\nresume: releasekit test-resume --record %s\ncleanup: releasekit test-cleanup --record %s\n", doc.RecordPath, quoted, quoted); err != nil {
quoted := shellQuote(doc.RecordPath)
resume := "releasekit test-resume --record " + quoted
cleanup := "releasekit test-cleanup --record " + quoted
handoff, handoffErr := executableRecoveryCommand(doc.RecordPath, "test-resume")
if handoffErr == nil {
resume = handoff
cleanup, handoffErr = executableRecoveryCommand(doc.RecordPath, "test-cleanup")
if handoffErr != nil {
cleanup = "releasekit test-cleanup --record " + quoted
}
}
if _, err := fmt.Fprintf(output, "record: %s\nresume: %s\ncleanup: %s\n", doc.RecordPath, resume, cleanup); err != nil {
return err
}
if handoffErr != nil {
if _, err := fmt.Fprintln(output, "Use a supported ReleaseKit executable if the current Go-run executable is temporary."); err != nil {
return err
}
}
}
return nil
}

View File

@@ -5,7 +5,9 @@ import (
"encoding/json"
"errors"
"os"
"os/exec"
"path/filepath"
"runtime"
"strings"
"testing"
"time"
@@ -81,6 +83,23 @@ func TestCleanupCommandSelectsExplicitRecordAndReportsSeparateOutcome(t *testing
if status != 1 || !strings.Contains(output.String(), `"cleanup":"complete"`) {
t.Fatalf("resume status=%d output=%s diagnostics=%s", status, &output, &diagnostics)
}
if runtime.GOOS != "windows" {
binary := buildWorkflowCLI(t, cliRepositoryRoot(t))
command := exec.Command(binary, "test-cleanup", "--record", store.Path)
text, err := command.CombinedOutput()
if err != nil {
t.Fatalf("built cleanup: %v: %s", err, text)
}
handoff := outputLineValue(string(text), "cleanup: ")
if !strings.Contains(handoff, shellQuote(binary)) {
t.Fatalf("cleanup handoff does not select executable: %s", text)
}
command = exec.Command("sh", "-c", handoff)
command.Dir = t.TempDir()
if result, err := command.CombinedOutput(); err != nil {
t.Fatalf("run cleanup handoff: %v: %s", err, result)
}
}
}
func TestRehearsalExitStatusPreservesObservedOutcomes(t *testing.T) {

View File

@@ -1,6 +1,6 @@
# Command line
ReleaseKit currently provides eight commands. The exit statuses below belong
The exit statuses below belong
to the native executable. `go run` examples are convenient for source execution,
but the Go driver maps a nonzero child exit status to 1. Use the built executable
or `./scripts/release` for publication when distinct statuses are needed.
@@ -368,3 +368,40 @@ consumers without a declared
ReleaseKit module dependency can use the separately installed-tool command.
See the [delivery guide](consumers/delivery.md#woodpecker-tag-workflows) for
compatible Go environments, retries, and preparation details.
## Rehearsal and recovery
```sh
releasekit test [--repo DIR] [--config FILE] [--ref REF] [--record-dir DIR] [--timeout DURATION] [--cleanup-timeout DURATION] [--json]
releasekit test-resume --record FILE [--token-file FILE] [--woodpecker-token-file FILE] [--timeout DURATION] [--cleanup-timeout DURATION] [--json]
releasekit test-cleanup --record FILE [--token-file FILE] [--woodpecker-token-file FILE] [--cleanup-timeout DURATION] [--json]
```
`test` captures `HEAD` or `--ref`, reads the profile from that commit, and
pushes a temporary annotated diagnostic tag. It observes the selected
Woodpecker delivery step, verifies its recorded page and artifact evidence,
and attempts cleanup only after matching CI runs are quiescent. It does not
require a clean checkout, choose a production version, or cancel CI. The
observation timeout defaults to 30 minutes; `--timeout 0` waits until the
context is canceled. Cleanup defaults to two minutes and its timeout must be
positive.
The command reports the exact private record path. Recovery always requires
that explicit path; it never selects a newest attempt. Local credentials come
from the recorded commit's profile unless file overrides are supplied. With
both overrides, recovery can load credentials without the recorded profile;
the checkout remains necessary for Git operations. `test-resume` observes and
then cleans; `test-cleanup` reports cleanup independently of prior verification.
Human output uses the current durable executable in its recovery commands when
available. If it was a temporary Go-run executable, use a supported ReleaseKit
tool with the same record after that executable disappears.
The [rehearsal guide](consumers/rehearsal.md) covers permissions and the limits
of the result.
With `--json`, each command emits one `schema_version: 1` object with safe
identity, workflow, build, verification and cleanup outcomes, resource links,
remaining resources and diagnostics. Status 0 means verification and cleanup
succeeded for `test` or `test-resume`, or cleanup succeeded for `test-cleanup`.
Status 2 denotes usage, configuration or required input failure before effects;
1 denotes a known failure or reporting error; 3 denotes unresolved CI or
remote state or pending cleanup. An error can accompany useful partial results.

View File

@@ -21,8 +21,10 @@ The current profile fields are:
| `validation` | No | Optional shared checks selected by ReleaseKit. |
| `build` | No | Optional main package, binary name, and selected `GOOS/GOARCH` target strings. |
| `delivery` | No | Optional selected forge and destination fields for tagged-source delivery. |
| `readiness` | No | Optional explicit files to check during readiness. |
| `rehearsal` | No | Diagnostic selector and Woodpecker observation settings, required for a rehearsal. |
`module_dir` names the selected module's physical location in the repository;
When Go is selected, `module_dir` names the module's physical location;
ReleaseKit reads its declared import path from that module's own `go.mod`. The
physical directory and declared path are distinct: a declared `/v2` module can
live either at `integrations/core` or `integrations/core/v2`, while both use the
@@ -45,6 +47,13 @@ facade's `Check`, `Publish`, `Build`, and `Deliver` and the CLI candidate and
delivery commands use the selected format. See the [command reference](cli.md)
for invocation details.
After its selected prefix, `semver` accepts stable `MAJOR.MINOR.PATCH` with
no leading zeroes in numeric components. `date` accepts `YYYY-MM-DD` or
`YYYY-MM-DD.R` with a valid Gregorian date and positive, unpadded revision;
the first release has no suffix. `year-month` accepts `YYYY.MM.R`, with a
two-digit month and a required nonnegative, unpadded revision. Years range
from 0001 through 9999. ReleaseKit preserves the selected identifier spelling.
Each check requires a nonempty `args` array whose first element names the
executable. Arguments are passed directly to the child process; ReleaseKit does
not parse a shell command string. Select a shell explicitly when a check needs
@@ -221,8 +230,9 @@ delivery-permission deficiency. It does not guarantee later release or asset
writes. Local artifact size and digest checks follow preflight and still finish
before hosted writes.
Credential loading runs only for `deliver` and `ci-deliver`. `check`, `publish`,
and `build` do not read the token file or require a token. The CLI passes the
`validate` loads only credentials for selected operations. `test` and recovery
commands load their selected local credentials; `check`, `publish`, and `build`
do not read a delivery token. The CLI passes the
resolved value explicitly to the library operation. `ci-deliver` checks the
destination before downloading application dependencies for a binary build;
the later delivery performs a fresh check. Page-only CI relies on delivery's

View File

@@ -30,6 +30,8 @@ go mod tidy
```
Select a release that implements the API, profile, and workflow you are adopting.
The [next-release migration draft](../roadmap/next-release-migration.md) covers
the new source selections, credential contexts, and rehearsal workflow.
The vanity module path starts with v0.5.0. Versions through v0.4.2 declare the
original module path and use their corresponding historical instructions.
The module-release interface requires a release containing that feature;

View File

@@ -49,6 +49,8 @@ source and the same HEAD before and after compilation; binary delivery requires
that fact. This observation is not a source snapshot or attestation guarantee.
An explicit `Source` with `GoEnabled` can select general source publication and
a calendar format or a product major independent of the module import path.
The optional [rehearsal](rehearsal.md) uses its own diagnostic version and
verifies temporary artifacts through the actual CI delivery job.
Go commands run from `ModuleDir`, so `MainPackage` is interpreted within that
module. The default output directory is `<module>/dist`; a relative `OutputDir`

View File

@@ -49,6 +49,9 @@ needs no `go.mod` or Go toolchain, and its automatic file inputs include nested
`go.mod` files as data. The candidate reports its source scope and selection;
module fields are empty when Go is disabled.
An optional [rehearsal](rehearsal.md) checks the tagged CI delivery workflow
independently of this local candidate validation.
When Go is selected, ReleaseKit runs one `go test -mod=readonly -count=1 ./...` suite from the
selected module directory with the available compatible local Go toolchain.
Set `Validation.Go.Race` to run that

View File

@@ -17,6 +17,9 @@ mode. The profile or API request selects the physical source directory. The opti
before any build or hosted request. Page-only source delivery does not require a
Go module or compiler.
The optional [rehearsal](rehearsal.md) runs this delivery machinery in the
tag-triggered CI job with a diagnostic identity and read-back verification.
## CI preparation
Use `PrepareTaggedCheckout` when a disposable CI checkout must be verified

View File

@@ -35,6 +35,10 @@ For general source publication, set `Source` as described in the
[candidate check guide](check.md#local-candidate-check). `PublicationResult`
also reports the selected source directory and capabilities.
Publication does not require a hosted delivery rehearsal. The optional
[rehearsal](rehearsal.md) uses separately recorded temporary resources and does
not change the production tag's completion or immutability rules.
The optional `ValidationSpec.SharedFiles` selects additional committed files
for enabled file checks. Its nil and empty-slice behavior is described in the
[candidate check guide](check.md#local-candidate-check).

View File

@@ -44,6 +44,7 @@ check makes the command unsuccessful; an offline omission alone does not. Status
2 reports usage, configuration, or required-input errors; status 1 reports
other failures, cancellation, or output failure. Actual CI secret injection
requires a job or rehearsal result and is not established by local readiness.
See the [rehearsal guide](rehearsal.md) for that separate live diagnostic.
The Go facade's `Validate` accepts explicit selections and tokens and returns a
`ValidationReport` with a `ReadinessError` when selected checks fail. The CLI

View File

@@ -0,0 +1,69 @@
# Rehearse tagged delivery
A rehearsal exercises the real tag-triggered Woodpecker delivery workflow before
choosing a production version. It creates a temporary diagnostic tag and page,
verifies the job's page and any binary and checksum contents, and removes only
recorded diagnostic resources after CI is quiescent. Routine `publish` remains
complete when its production source tag is confirmed; rehearsal is an optional,
explicit diagnostic.
Configure `delivery` with both local and CI credential selections. Configure
`rehearsal.woodpecker` with the CI server URL, its numeric repository ID, the
exact workflow and delivery step names, and a separate local Woodpecker API
token file. The `rehearsal.selector` defaults to `root`; multi-product
repositories select the corresponding maintained mapping row. The
[configuration reference](../config.md) defines the fields. The
[root workflow](../../examples/woodpecker/tag-delivery.yml),
[self-bootstrap workflow](../../examples/woodpecker/releasekit-source-delivery.yml),
[multi-product example](../../examples/multi-module/README.md), and
[source-only example](../../examples/source-only/README.md) show the dispatch
and CI secret injection.
The local forge credential must be able to read and delete the diagnostic
release and its assets, the CI delivery credential must be able to create them,
and native Git authentication must permit creating and deleting the diagnostic tag. The separate Woodpecker credential needs read
access to the repository, pipelines, workflows, steps, and logs. CI must inject
the configured delivery token into the actual tagged job; local readiness
cannot establish that injection. Keep local token files private and ignored by
Git. Do not register them as CI secrets through ReleaseKit.
```sh
releasekit validate --operation rehearsal
releasekit test --json
releasekit test --ref HEAD~1 --timeout 45m
```
The selected profile must be committed in the checkout at the captured commit.
The branch, index, and worktree need not be a final release candidate and are
not changed by capture. The diagnostic version and tag identify a random
attempt; neither is a production release identifier. The actual CI job builds
and delivers through the selected profile, then reads back its page and declared
assets while build output remains available. A page-only profile generates no
binary artifacts.
The output separates workflow execution, build, hosted verification, and
cleanup. It records a private attempt under the Git common directory, or in an
explicit ignored/private `--record-dir`. If observation fails or cleanup cannot
establish quiescence, retain the exact printed record and use:
```sh
releasekit test-resume --record /path/to/attempt.json
releasekit test-cleanup --record /path/to/attempt.json
```
Recovery reads the committed profile selected by the record, using current local
credential files. `--token-file` and `--woodpecker-token-file` override those
paths. The library's `Rehearse`, `ResumeRehearsal`, and `CleanupRehearsal`
accept credentials explicitly and do not load ambient tokens. Their result and
error may both contain useful information. `RehearsalTimeout` values use the
same nanosecond units as `time.Duration`; a zero observation timeout waits for
context cancellation, and a zero cleanup timeout selects the two-minute default.
Cleanup rechecks every matching pipeline and the recorded tag and page identity.
An active or unobservable job, missing pipeline evidence, or a conflicting
resource leaves cleanup pending or reports a conflict. Cancellation stops local
observation and does not cancel the CI job. A fresh bounded cleanup context may
still clean resources when quiescence is established. CI history, notifications,
webhooks, and later operator-initiated reruns are outside the cleanup result.
See the [record and result formats](../integrations/rehearsal-records.md) for
transport and retained evidence.

View File

@@ -9,6 +9,13 @@ publication and version selection, diagnostic version, and full tag. A
16-byte random attempt ID is represented by 32 lowercase hexadecimal digits;
the tag and injected version include the same ID.
The manifest fields are `schema_version`, `attempt_id`, `selector`, `commit`,
`profile_path`, `profile_sha256`, `source_dir`, `go_enabled`, optional
`module_path`, `publication_mode`, `version_format`, `version_prefix`,
`diagnostic_version`, and `tag`. The diagnostic ref has the form
`releasekit-test/<selector>/<attempt-id>`; the injected version is
`releasekit-test-<attempt-id>`.
The manifest is verified against the actual annotated tag target, the event
commit, the selected dispatch row, the exact committed profile bytes, and the
normalized selection decoded from those bytes. The tag namespace alone is not
@@ -17,8 +24,7 @@ captured commit rather than the current working tree.
Private attempt records use `format_version: 1` and retain the manifest, Git
endpoint and remote, forge and Woodpecker destinations, planned page and asset
identities,
tag object, observed resource IDs, timestamps, and outcomes. They do not store
identities, tag object, observed resource IDs, timestamps, and outcomes. They do not store
resolved forge or Woodpecker tokens. Endpoints and paths may themselves contain
sensitive information, so treat records as private. By default they are stored
under the Git common directory in `releasekit/rehearsals/<attempt-id>.json`.
@@ -44,6 +50,13 @@ and rejects malformed, conflicting, or mismatched evidence without echoing the
raw log. The page and declared assets are read back before managed build output
is removed.
The result uses the manifest fields plus `scope` (`page` or
`page-and-assets`), `build`, `delivery`, `verification`, `page_id`,
`artifacts` entries with `name`, `size`, and `sha256`, and optional safe
`diagnostics`. A successful result requires complete delivery and verification
and a positive page ID. For asset scope it also requires the planned artifacts,
including the checksum manifest.
The start coordinator records tag creation and push intent before dispatch. It
keeps matching pipeline numbers, workflow and step observations, the job result,
and partial outcomes in the selected attempt record. A timeout or cancellation

View File

@@ -7,14 +7,16 @@ two Go facades and a command-line interface:
working setup and read-only access, `Check` validates
one local candidate, `Publish` validates and publishes its exact annotated
source tag, `Build` compiles selected application targets, and `Deliver`
delivers a tagged note page and any declared assets. `PrepareTaggedCheckout`
delivers a tagged note page and any declared assets. `Rehearse`,
`ResumeRehearsal`, and `CleanupRehearsal` coordinate explicitly recorded
temporary diagnostics. `PrepareTaggedCheckout`
and `PrepareBuildDependencies` provide explicit local CI preparation.
- `buildinfo` is the small runtime facade. `Version` reports the injected
application version, the main-module version when available, or `dev`.
- `cmd/releasekit` is the executable interface. Its `version`, `validate`, `check`,
`publish`, `reconcile`, `publication-attempts`, `build`, `deliver`, and
`ci-deliver` commands adapt profiles and command output to the supported
library operations.
`publish`, `reconcile`, `publication-attempts`, `build`, `deliver`,
`ci-deliver`, `test`, `test-resume`, and `test-cleanup` commands adapt
profiles and command output to the supported library operations.
See the [CLI contract](../cli.md), [configuration reference](../config.md),
[candidate check guide](../consumers/check.md),
@@ -22,7 +24,8 @@ See the [CLI contract](../cli.md), [configuration reference](../config.md),
[publication record format](../integrations/publication-records.md),
[build guide](../consumers/build.md),
[delivery guide](../consumers/delivery.md),
[readiness guide](../consumers/readiness.md), and
[readiness guide](../consumers/readiness.md),
[rehearsal guide](../consumers/rehearsal.md), and
[runtime version guide](../consumers/runtime-version.md) for task-oriented use.
Go declarations and GoDoc remain the owners of exact exported contracts.

View File

@@ -13,6 +13,12 @@ when the intended annotated tag is successfully
pushed, or when one exact-object recovery query confirms that the push
succeeded. CI and consumer installation are not completion checks.
An optional [delivery rehearsal](consumers/rehearsal.md) exercises the same
tagged CI workflow with temporary diagnostic resources before a release. It is
not a publication gate. Configure the committed profile's Woodpecker settings
and separate local token before invoking it, and retain any reported record
until cleanup is resolved.
## Prepare a candidate
For local hosted-page delivery, save a Gitea personal access token in

View File

@@ -781,6 +781,18 @@ selection, and CI secret source selection.
## Stage 15: Complete documentation and integrated verification
**Completed:** Canonical guides, integration formats, package inventory, the
maintainer procedure, and an unnumbered migration draft describe the delivered
behavior and the pre-release pin convention. Four assembled offline fixtures
cover legacy Go modules, Go application source releases, calendar-version
binaries, and YAML/JSON-only sources through readiness, candidate checking,
publication, delivery, diagnostic verification, cleanup, and saved recovery.
Compiled facade checks cover the new rehearsal operations. The offline
`go test ./...` suite, `go run ./internal/apicheck`, shell syntax and local-link
checks, and race tests for the facade, CLI, rehearsal, Woodpecker, Git, and
Gitea packages pass. A live consumer rehearsal and the next release remain
subsequent operator work.
1. Update canonical configuration, CLI, GoDoc, consumer adoption/check/build/
publication/delivery guides, integration schemas, internal inventory, and
maintainer runbook as their behavior lands. Add focused readiness/rehearsal

View File

@@ -0,0 +1,58 @@
# Next release migration draft
The next ReleaseKit release number is not yet assigned. This is migration
preparation for that release, not a published release note. Select and publish
a compatible ReleaseKit version before replacing the illustrative `v0.10.0`
pins in source-only examples. Until then, exercise the current source with the
local fixtures described in [development guidance](../development.md).
## Credentials and readiness
Move the former `delivery.token_file` to
`delivery.credentials.local.token_file`, and move `delivery.token_env` to
`delivery.credentials.ci.token_environment_variable`. Keep existing CI secret
names and job environment variable names where possible. A CI declaration with
no variable name defaults to `RELEASEKIT_DELIVERY_TOKEN`; it does not fall back
to the local token file. Local `deliver` and `test` use the local selection,
while `ci-deliver` uses the CI environment. `validate --context ci` explicitly
selects CI credentials for readiness.
For a live rehearsal, configure a separate local Woodpecker API token, numeric
repository ID, exact workflow and step, and selector in `rehearsal`. Grant the
local forge and Git credentials the diagnostic deletion permissions they need;
the CI secret still needs delivery write access. The [rehearsal guide](../consumers/rehearsal.md)
describes the evidence boundary and retained CI history, notifications, and
webhook effects.
## Source and version selection
Profiles omitting all of `source`, `go`, `publication`, and `version` retain
legacy Go-module publication and prefixed stable SemVer. A non-null selection
object selects the explicit model: declare `go: {}` to retain Go checks or
builds, choose `publication.mode: "go-module"` only for module publication,
and otherwise use general `source` publication. A source-only profile can use
`source: {}` without an application `go.mod`. The [configuration reference](../config.md)
owns defaults, physical directories, tag prefixes, and identifier grammars.
Source publication can select stable SemVer, Gregorian `date`, or `year-month`
identifiers. Source tags use the selected physical source prefix by default;
Go module publication retains declared path-major compatibility. Applications
can release a product major or calendar identifier independently of the Go
module path when using source publication. Update release-note paths and
workflow tag filters to match the chosen format.
## Tools, workflows, and recovery
Commit the installed-tool `.releasekit-version` pin for a source-only product,
or select a tool dependency in each Go module. Upgrade the tool and tagged CI
workflow together. The maintained multi-product selector uses four columns:
selector, production tag pattern, tool module directory, and profile path; `-`
selects the installed pinned tool. Add the diagnostic tag filter and ensure its
selector maps to the same committed profile as production delivery.
Regenerate old build receipts with the current `build` command before using
`deliver --assets`; receipts bind source selection and artifact identity.
Existing publication records remain explicit inputs to `reconcile` and do not
become rehearsal records. Rehearsal recovery similarly requires the exact
attempt record and supports explicit credential-file overrides. Neither recovery
path selects an attempt automatically.

View File

@@ -74,11 +74,41 @@ func checkRepository(ctx context.Context, dir string) error {
if violations := checkValidationTypes(pkg); len(violations) != 0 {
return fmt.Errorf("facade %s has invalid validation diagnostics:\n %s", path, strings.Join(violations, "\n "))
}
if violations := checkRehearsalAPI(pkg); len(violations) != 0 {
return fmt.Errorf("facade %s has invalid rehearsal contracts:\n %s", path, strings.Join(violations, "\n "))
}
}
}
return nil
}
func checkRehearsalAPI(pkg *types.Package) []string {
var violations []string
for _, name := range []string{"RehearsalRequest", "RehearsalRecoveryRequest", "RehearsalResult", "RehearsalError", "RehearsalTimeout", "RehearsalJob", "RehearsalWorkflow", "RehearsalArtifact"} {
object, ok := pkg.Scope().Lookup(name).(*types.TypeName)
if !ok || !namedTypeIs(object.Type(), pkg.Path(), name) {
violations = append(violations, fmt.Sprintf("missing facade-owned type %s", name))
}
}
for _, item := range []struct{ name, request string }{{"Rehearse", "RehearsalRequest"}, {"ResumeRehearsal", "RehearsalRecoveryRequest"}, {"CleanupRehearsal", "RehearsalRecoveryRequest"}} {
function, ok := pkg.Scope().Lookup(item.name).(*types.Func)
if !ok {
violations = append(violations, "missing facade operation "+item.name)
continue
}
signature, ok := function.Type().(*types.Signature)
if !ok || signature.Params().Len() != 2 || signature.Results().Len() != 2 || !namedTypeIs(signature.Params().At(0).Type(), "context", "Context") || !namedTypeIs(signature.Params().At(1).Type(), pkg.Path(), item.request) || !namedTypeIs(signature.Results().At(0).Type(), pkg.Path(), "RehearsalResult") || !types.Identical(signature.Results().At(1).Type(), types.Universe.Lookup("error").Type()) {
violations = append(violations, "invalid facade operation "+item.name)
}
}
return violations
}
func namedTypeIs(typ types.Type, packagePath, name string) bool {
named, ok := types.Unalias(typ).(*types.Named)
return ok && named.Obj().Pkg() != nil && named.Obj().Pkg().Path() == packagePath && named.Obj().Name() == name
}
func checkValidationTypes(pkg *types.Package) []string {
var violations []string
for _, name := range []string{"ValidationCheck", "ValidationFinding", "FileSizeMeasurement", "ValidationError"} {

View File

@@ -279,3 +279,29 @@ func TestCommandInternalCompositionPreservesLibraryBoundaries(t *testing.T) {
})
}
}
func TestRehearsalOperationsRequireFacadeOwnedRequestsAndResults(t *testing.T) {
valid := `package facade
import "context"
type RehearsalRequest struct{}
type RehearsalRecoveryRequest struct{}
type RehearsalResult struct{}
type RehearsalError struct{}
type RehearsalTimeout int64
type RehearsalJob struct{}
type RehearsalWorkflow struct{}
type RehearsalArtifact struct{}
func Rehearse(context.Context, RehearsalRequest) (RehearsalResult,error) {return RehearsalResult{},nil}
func ResumeRehearsal(context.Context, RehearsalRecoveryRequest) (RehearsalResult,error) {return RehearsalResult{},nil}
func CleanupRehearsal(context.Context, RehearsalRecoveryRequest) (RehearsalResult,error) {return RehearsalResult{},nil}
`
pkg := typecheck(t, token.NewFileSet(), modulePath, valid)
if violations := checkRehearsalAPI(pkg); len(violations) != 0 {
t.Fatalf("valid facade: %v", violations)
}
changed := strings.Replace(valid, "func CleanupRehearsal(context.Context, RehearsalRecoveryRequest)", "func CleanupRehearsal(context.Context, RehearsalRequest)", 1)
pkg = typecheck(t, token.NewFileSet(), modulePath, changed)
if violations := checkRehearsalAPI(pkg); !strings.Contains(strings.Join(violations, "\n"), "invalid facade operation CleanupRehearsal") {
t.Fatalf("violations=%v", violations)
}
}

View File

@@ -441,5 +441,5 @@ func hasVerifiedEvidence(attempt Attempt) bool {
return false
}
result, err := ReadResult(bytes.NewReader(frame), attempt.Manifest)
return err == nil && result.Verification == "complete" && matchesPlannedAssets(attempt.PlannedAssets, result.Artifacts)
return err == nil && result.Verification == "complete" && (attempt.PageID == 0 || attempt.PageID == result.PageID) && matchesPlannedAssets(attempt.PlannedAssets, result.Artifacts)
}

View File

@@ -22,8 +22,10 @@ type RehearsalTimeout time.Duration
// Source, Build, and the CI credential declaration must correspond to that
// profile; the CLI verifies this binding before calling the facade.
type RehearsalRequest struct {
RepositoryDir string
Ref string
// RepositoryDir may name any directory in the checkout. Ref defaults to HEAD.
RepositoryDir string
Ref string
// ProfilePath must identify a file in Ref within the repository.
ProfilePath string
ModuleDir string
Source *SourceSpec
@@ -35,8 +37,11 @@ type RehearsalRequest struct {
RequiredFiles []string
Destination DeliveryDestination
Woodpecker WoodpeckerObservation
CIConfigured bool
RecordDir string
// CIConfigured asserts that the supplied selection declares CI delivery credentials.
// Rehearse also checks the committed profile for that declaration.
CIConfigured bool
// RecordDir overrides the Git-common-directory private record location.
RecordDir string
// ObservationTimeout zero observes until the context is canceled.
ObservationTimeout RehearsalTimeout
// CleanupTimeout is reserved for the independent cleanup operation; zero uses its default.
@@ -64,6 +69,8 @@ type RehearsalArtifact struct {
}
// RehearsalResult retains partial outcomes and the explicit recovery record.
// Workflow, Build, Verification, and Cleanup describe independent observations;
// an error can accompany a partially or completely successful outcome.
type RehearsalResult struct {
AttemptID, Tag, Commit, ProfilePath, ProfileSHA256 string
Selector, SourceDir, DiagnosticVersion, Scope string
@@ -80,7 +87,7 @@ type RehearsalResult struct {
Diagnostics []string
}
// RehearsalError preserves the underlying failure or cancellation.
// RehearsalError preserves the underlying failure or cancellation with Unwrap.
type RehearsalError struct{ Err error }
func (err *RehearsalError) Error() string { return "rehearsal: " + err.Err.Error() }
@@ -122,7 +129,9 @@ func Rehearse(ctx context.Context, request RehearsalRequest) (RehearsalResult, e
}
// RehearsalRecoveryRequest selects one saved attempt and supplies current
// credentials explicitly. Destinations come from the saved attempt.
// credentials explicitly. Destinations come from the saved attempt; no record
// is selected automatically. Zero observation timeout waits for cancellation,
// and zero cleanup timeout selects the bounded default.
type RehearsalRecoveryRequest struct {
RecordPath string
DeliveryToken string