Update release.yml
This commit is contained in:
parent
9eea0a5ad1
commit
335e1a6cb7
1 changed files with 17 additions and 8 deletions
25
.github/workflows/release.yml
vendored
25
.github/workflows/release.yml
vendored
|
|
@ -16,6 +16,8 @@ jobs:
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
fetch-depth: 0 # needed so git describe/git log can see full history and tags
|
||||||
|
|
||||||
- name: Create release archive
|
- name: Create release archive
|
||||||
run: |
|
run: |
|
||||||
|
|
@ -28,17 +30,24 @@ jobs:
|
||||||
|
|
||||||
- name: Generate release notes
|
- name: Generate release notes
|
||||||
run: |
|
run: |
|
||||||
PREV_TAG=$(git describe --tags --abbrev=0 ${{ github.ref }}^ 2>/dev/null || echo "")
|
set -euo pipefail
|
||||||
if [ -z "$PREV_TAG" ]; then
|
# Find previous tag. Prefer the one before the current tag on the same history; fallback to the next most recent tag.
|
||||||
RANGE=$(git rev-list --max-parents=0 HEAD)..HEAD
|
PREV_TAG=$(git describe --tags --abbrev=0 "${GITHUB_REF}^" 2>/dev/null || true)
|
||||||
else
|
if [ -z "${PREV_TAG:-}" ]; then
|
||||||
RANGE=$PREV_TAG..HEAD
|
PREV_TAG=$(git tag --sort=-version:refname | grep -v "^${GITHUB_REF_NAME}$" | head -n1 || true)
|
||||||
fi
|
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 "" >> release_notes.md
|
||||||
echo "## Changes since $PREV_TAG" >> release_notes.md
|
echo "## Changes since ${SINCE_LABEL}" >> release_notes.md
|
||||||
echo "" >> 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
|
echo "" >> release_notes.md
|
||||||
|
|
||||||
- name: Create GitHub Release
|
- name: Create GitHub Release
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue