ARTEX - AI autonomous penetration testing system (English translation; upstream: Autumn-27/ARTEX, AGPL-3.0)
Go aiai-agentsautonomous-agentsbug-bountydockergolanglinuxllmmcpnextjspenetration-testingpentestpostgresqlreareactred-teamsecuritysecurity-automationsqlitetypescript
release: build release body from CHANGELOG section
BaaRai1e3c858b4e21
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.ymlindex b9dac1f..ac6e007 100644--- a/.github/workflows/ci.yml+++ b/.github/workflows/ci.yml@@ -63,7 +63,8 @@ jobs:# shellcheck is preinstalled on the ubuntu runners. -S warning: the scripts# currently have only info-level notes (intentional A && B || C chains in# update.sh, an unquoted glob in backup.sh's prune), so fail on warnings.- - run: shellcheck -S warning install.sh update.sh start.sh scripts/backup.sh reset-password.sh+ - run: shellcheck -S warning install.sh update.sh start.sh scripts/backup.sh reset-password.sh scripts/extract-changelog-section.sh scripts/test-extract-changelog-section.sh+ - run: bash scripts/test-extract-changelog-section.shweb:runs-on: ubuntu-latestdiff --git a/.github/workflows/release.yml b/.github/workflows/release.ymlindex 79b07ee..3a47d9e 100644--- a/.github/workflows/release.yml+++ b/.github/workflows/release.yml@@ -82,6 +82,7 @@ jobs:needs: binariesruns-on: ubuntu-lateststeps:+ - uses: actions/checkout@v4 # CHANGELOG.md and the extractor script- uses: actions/download-artifact@v4with:pattern: pkg-*@@ -90,13 +91,24 @@ jobs:- name: Generate checksumsworking-directory: distrun: sha256sum *.zip > SHA256SUMS+ - name: Release body from CHANGELOG.md+ env:+ TAG: ${{ github.ref_name }}+ run: |+ version="${TAG#v}"+ if bash scripts/extract-changelog-section.sh "$version" CHANGELOG.md > "$RUNNER_TEMP/release-body.md"; then+ echo "Release body: CHANGELOG.md section [$version]"+ else+ echo "::warning::CHANGELOG.md has no section [$version]; using the generic release body"+ echo "Release $TAG. See CHANGELOG.md for the list of changes in this release." > "$RUNNER_TEMP/release-body.md"+ fi- uses: softprops/action-gh-release@v2with:files: |dist/*.zipdist/SHA256SUMSgenerate_release_notes: false- body: "See CHANGELOG.md for the list of changes in this release."+ body_path: ${{ runner.temp }}/release-body.md# ④ Multi-arch image → push to Docker Hub (reuses the Linux binaries built by the# binaries job; the image only installs tools + ships the binary; arm64 only needsdiff --git a/scripts/extract-changelog-section.sh b/scripts/extract-changelog-section.shnew file mode 100755index 0000000..7c11a5f--- /dev/null+++ b/scripts/extract-changelog-section.sh@@ -0,0 +1,33 @@+#!/usr/bin/env bash+# Print the body of the CHANGELOG section "## [<version>]": the lines after that+# heading up to (not including) the next "## [" heading, with leading and+# trailing blank lines removed. The version is matched literally (no leading v).+# Exit 1 with nothing on stdout when the section is missing or empty.+#+# Usage: scripts/extract-changelog-section.sh <version> [changelog] (default CHANGELOG.md)+set -euo pipefail++if [ $# -lt 1 ] || [ $# -gt 2 ] || [ -z "$1" ]; then+ echo "usage: $0 <version> [changelog]" >&2+ exit 2+fi+version=$1+changelog=${2:-CHANGELOG.md}++body=$(awk -v head="## [$version]" '+ { sub(/\r$/, "") } # tolerate a CRLF checkout+ index($0, "## [") == 1 {+ if (found) exit+ rest = substr($0, length(head) + 1)+ if (substr($0, 1, length(head)) == head && (rest == "" || rest ~ /^[ \t]/)) { found = 1; next }+ }+ found { print }+' "$changelog")++# Trim leading blank lines ($(...) already drops the trailing ones).+body=$(printf '%s\n' "$body" | sed '/./,$!d')++if [ -z "$body" ]; then+ exit 1+fi+printf '%s\n' "$body"diff --git a/scripts/test-extract-changelog-section.sh b/scripts/test-extract-changelog-section.shnew file mode 100755index 0000000..17a7e16--- /dev/null+++ b/scripts/test-extract-changelog-section.sh@@ -0,0 +1,54 @@+#!/usr/bin/env bash+# Tests scripts/extract-changelog-section.sh against a fake CHANGELOG in a temp dir.+set -euo pipefail++extract="$(cd "$(dirname "$0")" && pwd)/extract-changelog-section.sh"+tmp=$(mktemp -d)+trap 'rm -rf "$tmp"' EXIT++cat > "$tmp/CHANGELOG.md" <<'EOF'+# Changelog++## [1.2.30] - 2030-01-03++Not this one.++## [1.2.3] - 2030-01-02++Summary line.++### Added++- **Thing**: did a thing (#1).++## [1.2.2] - 2030-01-01++- Older entry.+EOF++expected='Summary line.++### Added++- **Thing**: did a thing (#1).'++fail=0++if out=$(bash "$extract" 1.2.3 "$tmp/CHANGELOG.md") && [ "$out" = "$expected" ]; then+ echo "PASS: section [1.2.3] found, body returned exactly"+else+ echo "FAIL: section [1.2.3]; got:"; printf '%s\n' "${out-}"+ fail=1+fi++if out=$(bash "$extract" 9.9.9 "$tmp/CHANGELOG.md"); then+ echo "FAIL: missing section [9.9.9] exited 0; got:"; printf '%s\n' "$out"+ fail=1+elif [ -n "$out" ]; then+ echo "FAIL: missing section [9.9.9] printed output:"; printf '%s\n' "$out"+ fail=1+else+ echo "PASS: missing section [9.9.9] exits non-zero with no output"+fi++exit "$fail"