Skip to content

Commit

Permalink
Merge branch 'release-fixes'
Browse files Browse the repository at this point in the history
* release-fixes:
  MISC: mknews.sh: print latest NEWS.md version with `misc/mknews.sh --version`
  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
  MISC: mknews.sh: for release tags, copy news section from NEWS.md

Signed-off-by: Tim Janik <timj@gnu.org>
  • Loading branch information
tim-janik committed Sep 7, 2023
2 parents e4007d4 + 3db0bb1 commit d8465fd
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 20 deletions.
13 changes: 8 additions & 5 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down
46 changes: 31 additions & 15 deletions misc/mknews.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit d8465fd

Please sign in to comment.