Repository navigation
Expand file tree
/
Copy pathrelease-notes.sh
More file actions
96 lines (86 loc) · 3.24 KB
/
Copy pathrelease-notes.sh
File metadata and controls
96 lines (86 loc) · 3.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#!/usr/bin/env bash
set -Eeuo pipefail
if (($# != 6)); then
printf 'Usage: %s CONTAINER_VERSION CHANNEL IMAGE DIGEST DOCKER_TAG UPDATE_CHANNEL_ALIASES\n' "$0" >&2
exit 2
fi
container_version="$1"
channel="$2"
image="$3"
digest="$4"
docker_tag="$5"
update_channel_aliases="$6"
changelog_path="${CONTAINER_CHANGELOG_PATH:-CHANGELOG.md}"
repository="${GITHUB_REPOSITORY:-Crosis47/tmodloader}"
commit="${GITHUB_SHA:-local}"
github_release_tag="$docker_tag"
case "$channel" in
stable|preview) ;;
*)
printf '[!!] Channel must be stable or preview: %s\n' "$channel" >&2
exit 1
;;
esac
case "$update_channel_aliases" in
true|false) ;;
*)
printf '[!!] UPDATE_CHANNEL_ALIASES must be true or false.\n' >&2
exit 1
;;
esac
[[ -s "$changelog_path" ]] || {
printf '[!!] Changelog not found: %s\n' "$changelog_path" >&2
exit 1
}
section="$(awk -v version="$container_version" '
{ sub(/\r$/, "") }
/^## / {
if (capture) {
exit
}
if ($2 == version || $2 == "[" version "]") {
capture = 1
print
}
next
}
capture && !/^\[[^]]+\]:/ { print }
' "$changelog_path")"
release_date="$(head -n 1 <<< "$section" | awk '{print $4}')"
changes="$(tail -n +2 <<< "$section")"
if ! grep -q '[^[:space:]]' <<< "$changes"; then
printf '[!!] CHANGELOG.md has no section for container version %s.\n' "$container_version" >&2
exit 1
fi
if ! [[ "$release_date" =~ ^[0-9]{4}-[0-9]{2}-[0-9]{2}$ ]]; then
printf '[!!] Changelog release %s requires an ISO date (YYYY-MM-DD).\n' "$container_version" >&2
exit 1
fi
if [[ "$update_channel_aliases" != "true" ]]; then
channel_tags="not moved by this manual build"
elif [[ "$channel" == "stable" ]]; then
channel_tags="\`latest\`"
else
channel_tags="\`preview\`"
fi
printf '## [%s](https://github.com/%s/releases/tag/%s) - %s\n%s\n\n' \
"$github_release_tag" "$repository" "$github_release_tag" "$release_date" "$changes"
printf '<details>\n<summary>Images, validation, and source</summary>\n\n'
printf 'Container **v%s** installs the newest supported tModLoader release on the **%s** channel at first startup. Runtime files persist in `/data`; no game runtime is bundled.\n\n' \
"$container_version" "$channel"
printf '### Published images\n\n'
printf -- '- GitHub Release tag: `%s`\n' "$github_release_tag"
printf -- '- Version tag: `%s:%s`\n' "$image" "$docker_tag"
printf -- '- Moving channel tag(s): %s\n' "$channel_tags"
printf -- '- Immutable tested digest: `%s@%s`\n\n' "$image" "$digest"
printf '```bash\ndocker pull %s:%s\n```\n\n' "$image" "$docker_tag"
printf '### Validation\n\n'
printf 'The candidate digest passed Bash and configuration regression tests, '
printf 'a real dedicated-server startup and healthcheck, command injection, '
printf 'graceful shutdown, password-leak detection, and persistent-log verification '
printf 'on both linux/amd64 and linux/arm64 before these tags were assigned.\n\n'
printf 'Native executable architecture and live Workshop download/cache reuse were also verified.\n\n'
printf '### Upstream and source\n\n'
printf -- '- [Container source at %s](https://github.com/%s/tree/%s)\n' \
"$commit" "$repository" "$commit"
printf '\n</details>\n'