mirror of
https://github.com/wekan/wekan.git
synced 2026-11-26 20:45:07 -05:00
The release job failed before running a line of its script:
##[error]An error occurred trying to start process /usr/bin/bash with
working directory /home/runner/work/wekan/wekan. Argument list too long
Nothing in the step was wrong. The notes are the whole newest CHANGELOG
section - prepare measured them at 172,458 characters - and they reached
the step as env: CHANGELOG. Linux caps a SINGLE argv/envp string at
MAX_ARG_STRLEN, 128 KiB, so execve refused to start the shell at all. Both
bundles had built and verified; the release, and every job that needs it -
snap, docker, AppImage, the Windows and macOS bundles - never happened.
The environment was itself the fix for the previous failure: interpolated
inline as ${{ }} the notes become part of the shell SOURCE, so a backtick
in any `code` span runs as a command, which is how v10.59 published nothing
and printed "Incorrect: command not found". One shape is unsafe, the other
does not scale, and this release was big enough to find the second wall.
So the notes stop being a shell value at all. releases/release-notes.sh
prints the CHANGELOG section for a version, reading the file itself and
taking its arguments from the environment inside a QUOTED heredoc; the jobs
append its stdout to release-notes.md. Only file paths are passed around,
which has no size limit and leaves the text as data no shell ever parses.
prepare keeps the validation - a missing section is still cheap to fix
there - but no longer publishes the text as a job output, because an output
nobody can safely consume is a trap for the next person. The release job
and the notes-rewrite job check out ref: main, the same ref prepare read.
The guard test is rewritten around the new shape: no changelog job output,
no CHANGELOG in an env:, no interpolation into a script, and the extraction
script is what all three consumers run. It kept passing through this
failure, because it only knew about the injection.
Thanks to xet7 !
77 lines
2.9 KiB
Bash
Executable File
77 lines
2.9 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Print the CHANGELOG.md section that is this release's notes, to stdout.
|
|
#
|
|
# Usage: releases/release-notes.sh <version> [changelog-file]
|
|
#
|
|
# WHY THIS IS A FILE-TO-FILE PATH AND NEVER A VARIABLE
|
|
#
|
|
# The notes are the whole newest CHANGELOG section - 172,458 characters for
|
|
# v10.92 - and there are two ways to hand a string that size to a shell step,
|
|
# both of which have already broken a release:
|
|
#
|
|
# * Inline `${{ needs.prepare.outputs.changelog }}` inside a `run:` block.
|
|
# GitHub substitutes it into the shell SOURCE before bash parses it, so every
|
|
# `code` span's backtick runs as a command. v10.59 died with "Incorrect:
|
|
# command not found" and published nothing.
|
|
#
|
|
# * Through the ENVIRONMENT - `env: CHANGELOG: ${{ … }}` then "$CHANGELOG" -
|
|
# which fixed the backticks and then hit a harder wall. Linux caps a SINGLE
|
|
# argv/envp string at MAX_ARG_STRLEN, 128 KiB, and the notes passed it:
|
|
# v10.92's release job failed before running a line of the script, with
|
|
# "An error occurred trying to start process '/usr/bin/bash' … Argument list
|
|
# too long". Nothing in the step is wrong; execve refuses to start it.
|
|
#
|
|
# So the notes never become an argument, an environment variable or a job
|
|
# output. They are read from CHANGELOG.md in the workspace and written to a
|
|
# file, and only file PATHS are passed around - which has no size limit, and
|
|
# leaves the text as data that no shell ever parses.
|
|
set -euo pipefail
|
|
|
|
VERSION="${1:-}"
|
|
CHANGELOG_FILE="${2:-CHANGELOG.md}"
|
|
|
|
if [ -z "$VERSION" ]; then
|
|
echo "usage: releases/release-notes.sh <version> [changelog-file]" >&2
|
|
exit 2
|
|
fi
|
|
if [ ! -r "$CHANGELOG_FILE" ]; then
|
|
echo "::error::release-notes: cannot read $CHANGELOG_FILE" >&2
|
|
exit 1
|
|
fi
|
|
|
|
# Prefer a version-specific "# v<version> …" section; otherwise the topmost
|
|
# "# Upcoming/Upcomig WeKan ® release" one. The python reads the file itself and
|
|
# writes to stdout, so the notes never pass through the shell.
|
|
NOTES_FILE="$(mktemp)"
|
|
trap 'rm -f "$NOTES_FILE"' EXIT
|
|
|
|
VERSION="$VERSION" CHANGELOG_FILE="$CHANGELOG_FILE" python3 - > "$NOTES_FILE" <<'PYEOF'
|
|
import os
|
|
import re
|
|
import sys
|
|
|
|
version = os.environ["VERSION"]
|
|
with open(os.environ["CHANGELOG_FILE"], encoding="utf-8") as f:
|
|
content = f.read()
|
|
|
|
patterns = [
|
|
rf"(# v{re.escape(version)} .*?)(?=\n# v[0-9]|\Z)",
|
|
r"(# Upcom\w* WeKan.*?)(?=\n# v[0-9]|\Z)",
|
|
]
|
|
for pat in patterns:
|
|
m = re.search(pat, content, re.DOTALL)
|
|
if m:
|
|
print(m.group(1).strip())
|
|
sys.exit(0)
|
|
# Neither section exists. Print nothing; the caller turns that into an error
|
|
# with a message that says what to add, rather than publishing an empty release.
|
|
sys.exit(0)
|
|
PYEOF
|
|
|
|
if [ ! -s "$NOTES_FILE" ] || [ -z "$(tr -d '[:space:]' < "$NOTES_FILE")" ]; then
|
|
echo "::error::release-notes: $CHANGELOG_FILE has no '# v$VERSION …' section and no '# Upcoming WeKan (R) release' section, so the release would have no notes. Add the section and re-run." >&2
|
|
exit 1
|
|
fi
|
|
|
|
cat "$NOTES_FILE"
|