From 335e1a6cb79d315818758b24137bb94f8dd6d40e Mon Sep 17 00:00:00 2001 From: Ly-sec Date: Mon, 18 Aug 2025 18:15:01 +0200 Subject: [PATCH] Update release.yml --- .github/workflows/release.yml | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index a1d709d..9da0239 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -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