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 diff --git a/misc/mknews.sh b/misc/mknews.sh index 4c27f829..66627da1 100755 --- a/misc/mknews.sh +++ b/misc/mknews.sh @@ -21,20 +21,36 @@ fetch_news_version() # fetch_news_version {1|2} " sed -nre "$SEDSCRIPT" "${ABSPATHSCRIPT%/*}"/../NEWS.md } - -# 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 +# 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 + # 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)) + 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