Wire rehearsal commands and tagged workflows

This commit is contained in:
2026-12-05 23:35:52 +00:00
parent 8caeeb3d78
commit 3524d8bbb6
32 changed files with 831 additions and 47 deletions

1
examples/multi-module/.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
.releasekit/

View File

@@ -0,0 +1 @@
v0.10.0

View File

@@ -1,7 +1,7 @@
# Multi-module release example
This example maps selectors and complete event tags to a physical Go module
directory and a repository-root profile. The library derives the release tag
directory or installed tool and a repository-root profile. The library derives the release tag
from the selected module declaration and physical location; the table only
selects the corresponding profile and checkout directory.
@@ -15,8 +15,9 @@ minimum.
## Select the release tool
The module files are setup skeletons. Set `RELEASEKIT_TOOL_VERSION` to a released
ReleaseKit version at or after the v0.5.0 vanity-path migration, then register
that tool in each consumer module before running the launcher or workflow:
ReleaseKit version that supports the selected source and rehearsal features,
then register that tool in each consumer module before running the launcher or
workflow. The next compatible release has not yet been assigned a version:
```sh
: "${RELEASEKIT_TOOL_VERSION:?Select a ReleaseKit release with module-release support}"
@@ -38,11 +39,12 @@ support and migration from earlier versions.
1. Local selector.
2. Shell pattern matched against a complete event tag.
3. Repository-relative physical module directory (`.` means the root module).
3. Repository-relative tool module directory (`.` means the root module); `-` selects the installed tool from `.releasekit-version`.
4. Repository-relative profile path.
The checked-in patterns are `v[01].*`, `integrations/ckconfig/v*`, and
`integrations/core/v2.*`. The helper passes pattern text to the shell's `case`
The checked-in patterns are `v[01].*`, `integrations/ckconfig/v*`,
`integrations/core/v2.*`, and `configuration/20*`. Diagnostic tags select
the same row by their embedded selector. The helper passes pattern text to the shell's `case`
matcher without `eval`. A tag must match exactly one row; missing and ambiguous
matches are configuration errors. Module and profile paths may contain spaces.
The `core-v2` row places the Go module physically under `integrations/core/v2`
@@ -68,9 +70,15 @@ Then select a module and semantic version with the shared launcher:
./release.sh root v1.2.3
./release.sh ckconfig v1.2.3
./release.sh core-v2 v2.1.0
./release.sh config 2026-12-05
```
The launcher copies the selected module's `go.mod` and `go.sum` to temporary
For a source-only row, the launcher installs the pinned tool with
`scripts/releasekit-tool` and passes the selected profile without interpreting
`-` as a source directory. The checked-in `v0.10.0` pin illustrates syntax
only and must be replaced with the first compatible released version.
For Go rows, the launcher copies the selected module's `go.mod` and `go.sum` to temporary
alternate module files outside the checkout, resolves ReleaseKit from that
module's local dependency selection, adds the CLI tool declaration to that
temporary copy, and prepares its dependencies. It invokes the tool by its full
@@ -93,10 +101,9 @@ outside the checkout, and runs the selected ReleaseKit tool by its full package
path. It passes `ci-deliver --prepared`, the mapped profile, and the expected
physical module to the tool.
The `core-v2` profile demonstrates binary delivery; the other profiles are
page-only. Before enabling the workflow, configure each selected profile's
`delivery` object with `"forge": "gitea"`, its `base_url`, owner, repository,
and `"credentials": {"ci": {"token_environment_variable": "RELEASEKIT_GITEA_TOKEN"}}`,
then add the Woodpecker repository secret
page-only. Before enabling the workflow, replace the example forge and Woodpecker
destinations and repository ID in each profile. Configure separate local forge
and Woodpecker token files, then add the Woodpecker repository secret
`releasekit_gitea_token`; the workflow exposes it as
`RELEASEKIT_GITEA_TOKEN` only in the delivery step.
@@ -154,3 +161,13 @@ These commands use the repository-root profile paths even when invoked from a
child module. The core profile also verifies the native binary and injected
version. Prepared dependencies allow this verification with `GOPROXY=off` and
`GOSUMDB=off`.
For an optional live rehearsal, select the corresponding tool and profile:
```sh
"$(./scripts/releasekit-tool)" test --config releasekit-config.json
go -C integrations/ckconfig tool go.maximumdirect.net/releasekit/cmd/releasekit test --config releasekit-ckconfig.json
```
A diagnostic ref contains the row selector and is verified against the
committed profile after bootstrap.

View File

@@ -0,0 +1,4 @@
{
"service": "example",
"enabled": true
}

View File

@@ -0,0 +1,3 @@
# Example Configuration 2026-12-05
Initial configuration release.

View File

@@ -1,4 +1,5 @@
# selector<TAB>tag pattern<TAB>module directory<TAB>profile path
# selector<TAB>tag pattern<TAB>tool module directory<TAB>profile path
root v[01].* . releasekit-root.json
ckconfig integrations/ckconfig/v* integrations/ckconfig releasekit-ckconfig.json
core-v2 integrations/core/v2.* integrations/core/v2 releasekit-core-v2.json
config configuration/20* - releasekit-config.json
1 # selector<TAB>tag pattern<TAB>module directory<TAB>profile path # selector<TAB>tag pattern<TAB>tool module directory<TAB>profile path
2 root root
3 ckconfig ckconfig
4 core-v2 core-v2
5 config

View File

@@ -19,6 +19,11 @@ trap 'rm -rf "$bootstrap_dir"' EXIT
tab=$(printf '\t')
IFS="$tab" read -r selected_selector tag_pattern module_dir profile_path < "$selection_file"
if [ "$module_dir" = - ]; then
tool=$("$script_dir/scripts/releasekit-tool")
"$tool" publish --repo "$repository_dir" --config "$profile_path" "$version"
exit $?
fi
module_path=$repository_dir
if [ "$module_dir" != . ]; then
module_path=$repository_dir/$module_dir

View File

@@ -1,4 +1,28 @@
{
"product": "Example Consumer Integration",
"module_dir": "integrations/ckconfig"
"module_dir": "integrations/ckconfig",
"delivery": {
"forge": "gitea",
"base_url": "https://gitea.example",
"owner": "example",
"repository": "multi-product",
"credentials": {
"local": {
"token_file": ".releasekit/gitea-token"
},
"ci": {
"token_environment_variable": "RELEASEKIT_GITEA_TOKEN"
}
}
},
"rehearsal": {
"selector": "ckconfig",
"woodpecker": {
"base_url": "https://ci.example",
"repository_id": 42,
"workflow": "delivery",
"step": "deliver",
"token_file": ".releasekit/woodpecker-token"
}
}
}

View File

@@ -0,0 +1,25 @@
{
"product": "Example Configuration",
"source": {"dir": "configuration"},
"version": {"format": "date"},
"delivery": {
"forge": "gitea",
"base_url": "https://gitea.example",
"owner": "example",
"repository": "multi-product",
"credentials": {
"local": {"token_file": ".releasekit/gitea-token"},
"ci": {"token_environment_variable": "RELEASEKIT_GITEA_TOKEN"}
}
},
"rehearsal": {
"selector": "config",
"woodpecker": {
"base_url": "https://ci.example",
"repository_id": 42,
"workflow": "delivery",
"step": "deliver",
"token_file": ".releasekit/woodpecker-token"
}
}
}

View File

@@ -4,6 +4,32 @@
"build": {
"main_package": ".",
"binary_name": "core",
"targets": ["linux/amd64"]
"targets": [
"linux/amd64"
]
},
"delivery": {
"forge": "gitea",
"base_url": "https://gitea.example",
"owner": "example",
"repository": "multi-product",
"credentials": {
"local": {
"token_file": ".releasekit/gitea-token"
},
"ci": {
"token_environment_variable": "RELEASEKIT_GITEA_TOKEN"
}
}
},
"rehearsal": {
"selector": "core-v2",
"woodpecker": {
"base_url": "https://ci.example",
"repository_id": 42,
"workflow": "delivery",
"step": "deliver",
"token_file": ".releasekit/woodpecker-token"
}
}
}

View File

@@ -1,4 +1,28 @@
{
"product": "Example Consumer",
"module_dir": "."
"module_dir": ".",
"delivery": {
"forge": "gitea",
"base_url": "https://gitea.example",
"owner": "example",
"repository": "multi-product",
"credentials": {
"local": {
"token_file": ".releasekit/gitea-token"
},
"ci": {
"token_environment_variable": "RELEASEKIT_GITEA_TOKEN"
}
}
},
"rehearsal": {
"selector": "root",
"woodpecker": {
"base_url": "https://ci.example",
"repository_id": 42,
"workflow": "delivery",
"step": "deliver",
"token_file": ".releasekit/woodpecker-token"
}
}
}

View File

@@ -0,0 +1,46 @@
#!/bin/sh
# Install the selected host tool once and print its durable absolute path.
set -eu
umask 077
script_dir=$(CDPATH= cd "$(dirname "$0")" && pwd)
repository=$(git -C "$script_dir" rev-parse --show-toplevel)
pin=$repository/.releasekit-version
if [ ! -r "$pin" ]; then
printf 'ReleaseKit tool pin is unreadable: %s\n' "$pin" >&2
exit 2
fi
if version=$(LC_ALL=C awk '
{ gsub(/[[:space:]]+/, " "); for (i = 1; i <= NF; i++) { value = $i; count++ } }
END {
if (count != 1 || value !~ /^v(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)$/) exit 1
print value
}
' "$pin"); then :; else
printf 'ReleaseKit tool pin must contain one stable module version, such as v0.10.0: %s\n' "$pin" >&2
exit 2
fi
export GOWORK=off GOTOOLCHAIN=local
host_os=$(go env GOHOSTOS)
host_arch=$(go env GOHOSTARCH)
case $host_os in
windows) executable=releasekit.exe ;;
*) executable=releasekit ;;
esac
tool_dir=$repository/.releasekit/tools/$version/$host_os-$host_arch
tool=$tool_dir/$executable
if [ ! -x "$tool" ]; then
mkdir -p "$tool_dir"
temporary=$(mktemp -d "$tool_dir/.install.XXXXXX")
trap 'rm -rf "$temporary"' EXIT
trap 'exit 1' HUP INT TERM
if GOBIN=$temporary GOOS=$host_os GOARCH=$host_arch go install "go.maximumdirect.net/releasekit/cmd/releasekit@$version"; then :; else
status=$?
exit "$status"
fi
if [ ! -x "$temporary/$executable" ]; then
printf 'ReleaseKit installation produced no executable\n' >&2
exit 1
fi
mv "$temporary/$executable" "$tool"
fi
printf '%s\n' "$tool"

View File

@@ -14,6 +14,22 @@ case "$mode" in
*) usage ;;
esac
# A diagnostic ref carries its dispatch selector before the tool is available.
if [ "$mode" = tag ]; then
case "$value" in
releasekit-test/*)
diagnostic=${value#releasekit-test/}
selector=${diagnostic%%/*}
attempt=${diagnostic#*/}
case "$diagnostic" in */*) ;; *) echo "invalid diagnostic tag" >&2; exit 2 ;; esac
case "$attempt" in *[!0-9a-f]*|'') echo "invalid diagnostic attempt" >&2; exit 2 ;; esac
[ "${#attempt}" -eq 32 ] && [ -n "$selector" ] || { echo "invalid diagnostic tag" >&2; exit 2; }
mode=selector
value=$selector
;;
esac
fi
script_dir=$(CDPATH= cd "$(dirname "$0")" && pwd)
mapping=${RELEASEKIT_MODULE_MAP:-$script_dir/release-modules.tsv}
[ -f "$mapping" ] || { echo "module map not found: $mapping" >&2; exit 2; }

View File

@@ -5,6 +5,8 @@ when:
- refs/tags/v[01].*
- refs/tags/integrations/ckconfig/v*
- refs/tags/integrations/core/v2.*
- refs/tags/configuration/20*
- refs/tags/releasekit-test/*/*
steps:
- name: deliver
@@ -37,6 +39,11 @@ steps:
"$${CI_WORKSPACE}/select-module.sh" tag "$${CI_COMMIT_TAG}" > "$${selection_file}"
tab=$(printf '\t')
IFS="$${tab}" read -r selector tag_pattern module_dir profile_path < "$${selection_file}"
if [ "$${module_dir}" = - ]; then
tool=$("$${CI_WORKSPACE}/scripts/releasekit-tool")
"$${tool}" ci-deliver --repo "$${CI_WORKSPACE}" --config "$${profile_path}" --prepared --commit "$${expected_commit}" "$${CI_COMMIT_TAG}"
exit $?
fi
module_path="$${CI_WORKSPACE}"
if [ "$${module_dir}" != . ]; then
module_path="$${CI_WORKSPACE}/$${module_dir}"

View File

@@ -23,5 +23,14 @@
"token_environment_variable": "RELEASEKIT_GITEA_TOKEN"
}
}
},
"rehearsal": {
"woodpecker": {
"base_url": "https://ci.example",
"repository_id": 42,
"workflow": "delivery",
"step": "deliver",
"token_file": ".releasekit/woodpecker-token"
}
}
}

View File

@@ -14,5 +14,14 @@
"token_environment_variable": "RELEASEKIT_GITEA_TOKEN"
}
}
},
"rehearsal": {
"woodpecker": {
"base_url": "https://ci.example",
"repository_id": 42,
"workflow": "delivery",
"step": "deliver",
"token_file": ".releasekit/woodpecker-token"
}
}
}

View File

@@ -1,6 +1,9 @@
when:
- event: tag
ref: refs/tags/20*
ref:
include:
- refs/tags/20*
- refs/tags/releasekit-test/root/*
steps:
- name: deliver
@@ -14,6 +17,7 @@ steps:
set -eu
test -n "$${CI_COMMIT_TAG}"
test -n "$${CI_COMMIT_SHA}"
case "$${CI_COMMIT_TAG}" in releasekit-test/root/*) ;; releasekit-test/*) echo 'Unknown diagnostic selector' >&2; exit 2 ;; esac
git check-ref-format "refs/tags/$${CI_COMMIT_TAG}"
git fetch origin "refs/tags/$${CI_COMMIT_TAG}:refs/tags/$${CI_COMMIT_TAG}"
tag_commit=$(git rev-parse --verify "refs/tags/$${CI_COMMIT_TAG}^{commit}")

View File

@@ -16,8 +16,9 @@ candidate validation remains offline. The launcher honors configured Go proxy,
checksum, and cache settings and disables automatic toolchain downloads and
workspace discovery. Update only the pin to select another tool version.
Save the local forge token in `.releasekit/gitea-token` with owner-only
permissions. The ignore rule keeps it out of ordinary commits; the optional
Save the local forge token in `.releasekit/gitea-token` and the separate
Woodpecker API token in `.releasekit/woodpecker-token` with owner-only
permissions. Set the Woodpecker URL and numeric repository ID in the profile. The ignore rule keeps it out of ordinary commits; the optional
`validation.forbidden_files` check rejects a candidate that includes that
path. Configure the Woodpecker stored secret `releasekit_gitea_token`, which the
workflow injects as the CI job variable `RELEASEKIT_GITEA_TOKEN`.
@@ -36,3 +37,7 @@ is separate from successful source publication. `scripts/releasekit` forwards
other CLI commands, including recovery commands, to the installed executable.
The publication failure output identifies the durable executable and exact
attempt record to use after the original launcher exits.
After configuring both tokens, `./scripts/releasekit test` runs the optional
live diagnostic through the same tagged delivery workflow and records cleanup
evidence for explicit recovery.

View File

@@ -1,16 +1,36 @@
{
"product": "Example Configuration",
"source": {},
"version": {"format": "date"},
"validation": {"forbidden_files": [".releasekit/gitea-token"]},
"version": {
"format": "date"
},
"validation": {
"forbidden_files": [
".releasekit/gitea-token",
".releasekit/woodpecker-token"
]
},
"delivery": {
"forge": "gitea",
"base_url": "https://gitea.example",
"owner": "example",
"repository": "configuration",
"credentials": {
"local": {"token_file": ".releasekit/gitea-token"},
"ci": {"token_environment_variable": "RELEASEKIT_GITEA_TOKEN"}
"local": {
"token_file": ".releasekit/gitea-token"
},
"ci": {
"token_environment_variable": "RELEASEKIT_GITEA_TOKEN"
}
}
},
"rehearsal": {
"woodpecker": {
"base_url": "https://ci.example",
"repository_id": 42,
"workflow": "delivery",
"step": "deliver",
"token_file": ".releasekit/woodpecker-token"
}
}
}

View File

@@ -1,6 +1,9 @@
when:
- event: tag
ref: refs/tags/v*
ref:
include:
- refs/tags/v*
- refs/tags/releasekit-test/root/*
steps:
- name: deliver
@@ -14,6 +17,7 @@ steps:
set -eu
test -n "$${CI_COMMIT_TAG}"
test -n "$${CI_COMMIT_SHA}"
case "$${CI_COMMIT_TAG}" in releasekit-test/root/*) ;; releasekit-test/*) echo 'Unknown diagnostic selector' >&2; exit 2 ;; esac
git check-ref-format "refs/tags/$${CI_COMMIT_TAG}"
git fetch origin "refs/tags/$${CI_COMMIT_TAG}:refs/tags/$${CI_COMMIT_TAG}"
tag_commit=$(git rev-parse --verify "refs/tags/$${CI_COMMIT_TAG}^{commit}")

View File

@@ -4,7 +4,10 @@ matrix:
when:
- event: tag
ref: refs/tags/v*
ref:
include:
- refs/tags/v*
- refs/tags/releasekit-test/root/*
steps:
- name: deliver
@@ -18,6 +21,7 @@ steps:
set -eu
test -n "$${CI_COMMIT_TAG}"
test -n "$${CI_COMMIT_SHA}"
case "$${CI_COMMIT_TAG}" in releasekit-test/root/*) ;; releasekit-test/*) echo 'Unknown diagnostic selector' >&2; exit 2 ;; esac
git check-ref-format "refs/tags/$${CI_COMMIT_TAG}"
git fetch origin "refs/tags/$${CI_COMMIT_TAG}:refs/tags/$${CI_COMMIT_TAG}"
tag_commit=$(git rev-parse --verify "refs/tags/$${CI_COMMIT_TAG}^{commit}")