Update release.yml

This commit is contained in:
Ly-sec
2025-08-18 18:15:01 +02:00
parent 9eea0a5ad1
commit 335e1a6cb7

View File

@@ -16,6 +16,8 @@ jobs:
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0 # needed so git describe/git log can see full history and tags
- name: Create release archive
run: |
@@ -28,17 +30,24 @@ jobs:
- name: Generate release notes
run: |
PREV_TAG=$(git describe --tags --abbrev=0 ${{ github.ref }}^ 2>/dev/null || echo "")
if [ -z "$PREV_TAG" ]; then
RANGE=$(git rev-list --max-parents=0 HEAD)..HEAD
else
RANGE=$PREV_TAG..HEAD
set -euo pipefail
# Find previous tag. Prefer the one before the current tag on the same history; fallback to the next most recent tag.
PREV_TAG=$(git describe --tags --abbrev=0 "${GITHUB_REF}^" 2>/dev/null || true)
if [ -z "${PREV_TAG:-}" ]; then
PREV_TAG=$(git tag --sort=-version:refname | grep -v "^${GITHUB_REF_NAME}$" | head -n1 || true)
fi
echo "# Release ${{ github.ref_name }}" > release_notes.md
if [ -z "${PREV_TAG:-}" ]; then
RANGE="$(git rev-list --max-parents=0 HEAD)..${GITHUB_REF_NAME}"
SINCE_LABEL="project start"
else
RANGE="${PREV_TAG}..${GITHUB_REF_NAME}"
SINCE_LABEL="${PREV_TAG}"
fi
echo "# Release ${GITHUB_REF_NAME}" > release_notes.md
echo "" >> release_notes.md
echo "## Changes since $PREV_TAG" >> release_notes.md
echo "## Changes since ${SINCE_LABEL}" >> release_notes.md
echo "" >> release_notes.md
git log $RANGE --pretty=format:"- %s ([%h](https://github.com/${{ github.repository }}/commit/%H)) by %an" >> release_notes.md
git log ${RANGE} --pretty=format:"- %s ([%h](https://github.com/${GITHUB_REPOSITORY}/commit/%H)) by %an" >> release_notes.md
echo "" >> release_notes.md
- name: Create GitHub Release