From 9dfb0918512270ee566cb75d7f0d0e1c7e0d742d Mon Sep 17 00:00:00 2001 From: Tim Janik Date: Wed, 6 Sep 2023 21:35:20 +0200 Subject: [PATCH 1/3] MISC: mknews.sh: for release tags, copy news section from NEWS.md Signed-off-by: Tim Janik --- misc/mknews.sh | 40 ++++++++++++++++++++++++++-------------- 1 file changed, 26 insertions(+), 14 deletions(-) diff --git a/misc/mknews.sh b/misc/mknews.sh index 4c27f829..5f409be9 100755 --- a/misc/mknews.sh +++ b/misc/mknews.sh @@ -23,18 +23,30 @@ fetch_news_version() # fetch_news_version {1|2} } # Produce assets/NEWS.md -CURRENT_VERSION=$("${ABSPATHSCRIPT%/*}"/version.sh | (read v h d && echo $v)) -NEWS_TAG="v$(fetch_news_version 1)" -echo "## Anklang $CURRENT_VERSION" -echo -echo 'Development version - may contain bugs or compatibility issues.' -echo -echo '``````````````````````````````````````````````````````````````````````````````````````' -git log --pretty='%s # %cd %an %h%n%w(0,4,4)%b' \ - --reverse \ - --first-parent --date=short "$NEWS_TAG..HEAD" | - sed -e '/^\s*Signed-off-by:.*<.*@.*>/d' | - sed '/^\s*$/{ N; /^\s*\n\s*$/D }' -echo '``````````````````````````````````````````````````````````````````````````````````````' -echo +# When generating news for release tags... +if RELEASETAG=$(git describe --match='v[0-9]*.[0-9]*.[0-9]*' --exact-match 2>/dev/null) ; then + # Copy release version news section from NEWS.md + SEDSEC1=" + 0,/^##?\s/n; # Read ahead until first heading + /^##?\s/Q; # Quit processing before printing second heading + " + sed -re "$SEDSEC1" < NEWS.md | + sed -z 's/\n\+$/\n/' # Strip newlines at EOF +else + # Generate pre-release news from git history + CURRENT_VERSION=$("${ABSPATHSCRIPT%/*}"/version.sh | (read v h d && echo $v)) + NEWS_TAG="v$(fetch_news_version 1)" + echo "## Anklang $CURRENT_VERSION" + echo + echo 'Development version - may contain bugs or compatibility issues.' + echo + echo '``````````````````````````````````````````````````````````````````````````````````````' + git log --pretty='%s # %cd %an %h%n%w(0,4,4)%b' \ + --reverse \ + --first-parent --date=short "$NEWS_TAG..HEAD" | + sed -e '/^\s*Signed-off-by:.*<.*@.*>/d' | + sed '/^\s*$/{ N; /^\s*\n\s*$/D }' + echo '``````````````````````````````````````````````````````````````````````````````````````' + echo +fi From ea5b283781405b75c1144fcf36ad04f243771571 Mon Sep 17 00:00:00 2001 From: Tim Janik Date: Wed, 6 Sep 2023 21:34:09 +0200 Subject: [PATCH 2/3] GITHUB: workflows/release.yml: set prerelease:false for annotated tags Fix actions/checkout@v3 and actions/checkout@v4 messing up the annotation of the currently fetched tag, even with fetch-depth:0, see: actions/checkout#290 Signed-off-by: Tim Janik --- .github/workflows/release.yml | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 997ea522..8fca04f8 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -13,12 +13,15 @@ jobs: Release-Build-and-Upload: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - - - name: Fetch Repository Tags + - uses: actions/checkout@v4 + with: + fetch-depth: 0 # Fetch history and all (annotated) tags + - name: Fetch Tag + id: fetchtag run: | + git fetch -f --tags # Fix actions/checkout messing up annotation of the fetched tag: actions/checkout#290 + echo "ISPRERELEASE=$(test tag != $(git cat-file -t $GITHUB_REF_NAME) && echo true || echo false)" >> "$GITHUB_OUTPUT" misc/version.sh - git fetch --unshallow git describe --tags --exact-match 2>/dev/null || git describe git cat-file -t $GITHUB_REF_NAME @@ -38,7 +41,7 @@ jobs: uses: softprops/action-gh-release@v1 if: startsWith(github.ref, 'refs/tags/') with: - prerelease: true + prerelease: ${{ steps.fetchtag.outputs.ISPRERELEASE }} files: assets/* body_path: assets.txt From 3db0bb123f8bbc573e34da79f7ab80af46f0b29c Mon Sep 17 00:00:00 2001 From: Tim Janik Date: Wed, 6 Sep 2023 21:37:12 +0200 Subject: [PATCH 3/3] MISC: mknews.sh: print latest NEWS.md version with `misc/mknews.sh --version` Signed-off-by: Tim Janik --- misc/mknews.sh | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/misc/mknews.sh b/misc/mknews.sh index 5f409be9..66627da1 100755 --- a/misc/mknews.sh +++ b/misc/mknews.sh @@ -21,8 +21,13 @@ fetch_news_version() # fetch_news_version {1|2} " sed -nre "$SEDSCRIPT" "${ABSPATHSCRIPT%/*}"/../NEWS.md } +NEWS_TAG="v$(fetch_news_version 1)" -# Produce assets/NEWS.md +# Just print topmost NEWS.md version +test " ${1:-}" == " --version" && { + echo "$NEWS_TAG" + exit 0 +} # When generating news for release tags... if RELEASETAG=$(git describe --match='v[0-9]*.[0-9]*.[0-9]*' --exact-match 2>/dev/null) ; then @@ -36,7 +41,6 @@ if RELEASETAG=$(git describe --match='v[0-9]*.[0-9]*.[0-9]*' --exact-match 2>/de else # Generate pre-release news from git history CURRENT_VERSION=$("${ABSPATHSCRIPT%/*}"/version.sh | (read v h d && echo $v)) - NEWS_TAG="v$(fetch_news_version 1)" echo "## Anklang $CURRENT_VERSION" echo echo 'Development version - may contain bugs or compatibility issues.'