Add pinned tools for source-only releases
This commit is contained in:
1
examples/source-only/.gitignore
vendored
Normal file
1
examples/source-only/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
.releasekit/
|
||||
1
examples/source-only/.releasekit-version
Normal file
1
examples/source-only/.releasekit-version
Normal file
@@ -0,0 +1 @@
|
||||
v0.10.0
|
||||
31
examples/source-only/.woodpecker/delivery.yml
Normal file
31
examples/source-only/.woodpecker/delivery.yml
Normal file
@@ -0,0 +1,31 @@
|
||||
when:
|
||||
- event: tag
|
||||
ref: refs/tags/20*
|
||||
|
||||
steps:
|
||||
- name: deliver
|
||||
image: golang:1.27.4-bookworm
|
||||
environment:
|
||||
# Woodpecker stores releasekit_gitea_token and injects this job variable.
|
||||
RELEASEKIT_GITEA_TOKEN:
|
||||
from_secret: releasekit_gitea_token
|
||||
commands:
|
||||
- |
|
||||
set -eu
|
||||
test -n "$${CI_COMMIT_TAG}"
|
||||
test -n "$${CI_COMMIT_SHA}"
|
||||
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}")
|
||||
expected_commit=$(git rev-parse --verify "$${CI_COMMIT_SHA}^{commit}")
|
||||
if [ "$${tag_commit}" != "$${expected_commit}" ]; then
|
||||
printf 'Tag %s resolves to commit %s; event %s resolves to commit %s\n' \
|
||||
"$${CI_COMMIT_TAG}" "$${tag_commit}" "$${CI_COMMIT_SHA}" "$${expected_commit}" >&2
|
||||
exit 1
|
||||
fi
|
||||
git checkout --detach "$${tag_commit}"
|
||||
test "$(git rev-parse HEAD)" = "$${expected_commit}"
|
||||
test -z "$(git status --porcelain --untracked-files=all)"
|
||||
export GOWORK=off GOTOOLCHAIN=local
|
||||
tool=$("$${CI_WORKSPACE}/scripts/releasekit-tool")
|
||||
"$${tool}" ci-deliver --repo "$${CI_WORKSPACE}" --prepared --commit "$${expected_commit}" "$${CI_COMMIT_TAG}"
|
||||
38
examples/source-only/README.md
Normal file
38
examples/source-only/README.md
Normal file
@@ -0,0 +1,38 @@
|
||||
# Source-only configuration example
|
||||
|
||||
This example releases JSON configuration without a Go module. Copy its files
|
||||
into a repository, set the product and forge destination in `releasekit.json`,
|
||||
and select a published ReleaseKit version that supports source-only calendar
|
||||
releases in `.releasekit-version`. The committed `v0.10.0` value illustrates
|
||||
the pin syntax only: it predates this feature and must be replaced before use.
|
||||
The release that first supplies these interfaces has not yet been assigned a
|
||||
version.
|
||||
|
||||
Install a local Go toolchain and Git. `scripts/releasekit-tool` reads the single
|
||||
stable module version in the repository-root pin, installs the host executable
|
||||
under the ignored `.releasekit/tools` directory, and prints its absolute path.
|
||||
The private installation is reusable; installation can use the network, while
|
||||
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
|
||||
`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`.
|
||||
|
||||
After preparing a committed release note and authoritative `main`, run:
|
||||
|
||||
```sh
|
||||
./scripts/releasekit validate
|
||||
./scripts/release 2026-12-05
|
||||
```
|
||||
|
||||
The second command publishes the source tag. The [delivery workflow](.woodpecker/delivery.yml)
|
||||
checks out and verifies the event tag before reading its committed pin. It
|
||||
installs the same version for the host and invokes `ci-deliver`; page delivery
|
||||
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.
|
||||
4
examples/source-only/config.json
Normal file
4
examples/source-only/config.json
Normal file
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"service": "example",
|
||||
"enabled": true
|
||||
}
|
||||
3
examples/source-only/docs/releases/2026-12-05.md
Normal file
3
examples/source-only/docs/releases/2026-12-05.md
Normal file
@@ -0,0 +1,3 @@
|
||||
# Example Configuration 2026-12-05
|
||||
|
||||
Publish the initial configuration.
|
||||
16
examples/source-only/releasekit.json
Normal file
16
examples/source-only/releasekit.json
Normal file
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"product": "Example Configuration",
|
||||
"source": {},
|
||||
"version": {"format": "date"},
|
||||
"validation": {"forbidden_files": [".releasekit/gitea-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"}
|
||||
}
|
||||
}
|
||||
}
|
||||
5
examples/source-only/scripts/release
Executable file
5
examples/source-only/scripts/release
Executable file
@@ -0,0 +1,5 @@
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
script_dir=$(CDPATH= cd "$(dirname "$0")" && pwd)
|
||||
repository=$(git -C "$script_dir" rev-parse --show-toplevel)
|
||||
exec "$script_dir/releasekit" publish --repo "$repository" "$@"
|
||||
6
examples/source-only/scripts/releasekit
Executable file
6
examples/source-only/scripts/releasekit
Executable file
@@ -0,0 +1,6 @@
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
export GOWORK=off GOTOOLCHAIN=local
|
||||
script_dir=$(CDPATH= cd "$(dirname "$0")" && pwd)
|
||||
tool=$("$script_dir/releasekit-tool")
|
||||
exec "$tool" "$@"
|
||||
46
examples/source-only/scripts/releasekit-tool
Executable file
46
examples/source-only/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"
|
||||
Reference in New Issue
Block a user