feat: unify release steps

This commit is contained in:
eric
2026-03-04 07:25:54 +01:00
parent 9f2e1b512b
commit 40d0464f61
3 changed files with 341 additions and 351 deletions

View File

@@ -1,13 +1,11 @@
# release.nix
{
pkgs,
# Source of truth is always $ROOT_DIR/VERSION.
# Format:
# line 1: X.Y.Z
# line 2: CHANNEL (stable|alpha|beta|rc|internal|...)
# line 3: N (prerelease number, 0 for stable)
postVersion ? "",
versionFiles ? [ ],
release ? [ ],
# Unified list, processed in declaration order:
# { file = "path/to/file"; content = "..."; } — write file
# { run = "shell snippet..."; } — run script
channels ? [
"alpha"
"beta"
@@ -19,24 +17,28 @@
let
channelList = pkgs.lib.concatStringsSep " " channels;
versionFilesScript = pkgs.lib.concatMapStrings (f: ''
mkdir -p "$(dirname "${f.path}")"
${f.content} > "${f.path}"
log "Generated version file: ${f.path}"
'') versionFiles;
releaseScript = pkgs.lib.concatMapStrings (
entry:
if entry ? file then
''
mkdir -p "$(dirname "${entry.file}")"
cat > "${entry.file}" << NIXEOF
${entry.content}
NIXEOF
log "Generated version file: ${entry.file}"
''
else if entry ? run then
''
${entry.run}
''
else
builtins.throw "release entry must have either 'file' or 'run'"
) release;
script =
builtins.replaceStrings
[
"__CHANNEL_LIST__"
"__VERSION_FILES__"
"__POST_VERSION__"
]
[
channelList
versionFilesScript
postVersion
]
[ "__CHANNEL_LIST__" "__RELEASE_STEPS__" "__POST_VERSION__" ]
[ channelList releaseScript postVersion ]
(builtins.readFile ./release.sh);
in
pkgs.writeShellApplication {