Wire rehearsal commands and tagged workflows
This commit is contained in:
1
examples/multi-module/.gitignore
vendored
Normal file
1
examples/multi-module/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
.releasekit/
|
||||
1
examples/multi-module/.releasekit-version
Normal file
1
examples/multi-module/.releasekit-version
Normal file
@@ -0,0 +1 @@
|
||||
v0.10.0
|
||||
@@ -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.
|
||||
|
||||
4
examples/multi-module/configuration/config.json
Normal file
4
examples/multi-module/configuration/config.json
Normal file
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"service": "example",
|
||||
"enabled": true
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
# Example Configuration 2026-12-05
|
||||
|
||||
Initial configuration release.
|
||||
@@ -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
|
||||
|
||||
|
@@ -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
|
||||
|
||||
@@ -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"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
25
examples/multi-module/releasekit-config.json
Normal file
25
examples/multi-module/releasekit-config.json
Normal 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"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
46
examples/multi-module/scripts/releasekit-tool
Executable file
46
examples/multi-module/scripts/releasekit-tool
Executable 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"
|
||||
@@ -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; }
|
||||
|
||||
@@ -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}"
|
||||
|
||||
Reference in New Issue
Block a user