Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 40 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -266,13 +266,50 @@ jobs:
run: |
set -euo pipefail
tag="${GITHUB_REF_NAME}"
previous_tag="$(git describe --tags --abbrev=0 "${tag}^" 2>/dev/null || true)"
previous_tag="$(git describe --tags --abbrev=0 --match '[0-9]*.[0-9]*.[0-9]*' --exclude '*[!0-9.]*' "${tag}^" 2>/dev/null || true)"
range="${tag}"
if [ -n "${previous_tag}" ]; then
range="${previous_tag}..${tag}"
fi

changes="$(git log --format='- %s (%an)' "${range}")"
release_author() {
local name="$1"
local email="$2"
local nickname=""

case "${email}" in
*+*@users.noreply.github.com)
nickname="${email#*+}"
nickname="${nickname%@users.noreply.github.com}"
;;
*@users.noreply.github.com)
nickname="${email%@users.noreply.github.com}"
;;
sam@rmcreative.ru)
nickname="samdark"
;;
pamparam83@gmail.com)
nickname="pamparam83"
;;
*)
if [[ "${name}" != *" "* ]]; then
nickname="${name}"
else
nickname="${email%@*}"
fi
;;
esac

nickname="${nickname//[^[:alnum:]_.-]/-}"
printf '@%s' "${nickname:-unknown}"
}

changes_file="$(mktemp)"
while IFS=$'\t' read -r subject name email; do
author="$(release_author "${name}" "${email}")"
printf -- '- %s (%s)\n' "${subject}" "${author}" >> "${changes_file}"
done < <(git log --format='%s%x09%an%x09%ae' "${range}")

image="${REGISTRY}/${IMAGE_NAME}:${tag}"

{
Expand All @@ -288,7 +325,7 @@ jobs:
if [ -n "${previous_tag}" ]; then
printf 'Changes since %s:\n\n' "${previous_tag}"
fi
printf '%s\n' "${changes}"
cat "${changes_file}"
} > release-notes.md

- name: Create draft release with assets
Expand Down
24 changes: 24 additions & 0 deletions tests/Unit/Packaging/ConfigurationPackagingTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,30 @@ public function documentationWorkflowUsesNightlyBinaryAfterPackageWorkflow(): vo
self::assertStringNotContainsString('--user=root', $workflow);
}

#[Test]
public function releaseWorkflowBuildsNotesFromPreviousStableReleaseTag(): void
{
$workflow = file_get_contents(dirname(__DIR__, 3) . '/.github/workflows/release.yml');
self::assertIsString($workflow);

self::assertStringContainsString("tags:\n - '*.*.*'", $workflow);
self::assertStringContainsString(
"git describe --tags --abbrev=0 --match '[0-9]*.[0-9]*.[0-9]*' --exclude '*[!0-9.]*' \"\${tag}^\"",
$workflow,
);
Comment on lines +366 to +369

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in 9b4fd56: the regression test now expects the --exclude '*[!0-9.]*' guard in addition to the version-like --match pattern.

self::assertStringContainsString('release_author() {', $workflow);
self::assertStringContainsString('*+*@users.noreply.github.com)', $workflow);
self::assertStringContainsString('sam@rmcreative.ru)', $workflow);
self::assertStringContainsString('nickname="samdark"', $workflow);
self::assertStringContainsString('pamparam83@gmail.com)', $workflow);
self::assertStringContainsString('nickname="pamparam83"', $workflow);
self::assertStringContainsString("git log --format='%s%x09%an%x09%ae'", $workflow);
self::assertStringNotContainsString('repos/${GITHUB_REPOSITORY}/commits/${commit}', $workflow);
self::assertStringNotContainsString("git log --format='- %s (%an)'", $workflow);
self::assertStringNotContainsString('git describe --tags --abbrev=0 "${tag}^"', $workflow);
self::assertStringContainsString('Changes since %s:', $workflow);
}

#[Test]
public function cloudflareDeploymentVerifiesDownloadedBinaryChecksum(): void
{
Expand Down
Loading