Skip to content

Commit a07fa3d

Browse files
committed
.github/workflows/gh-release.sh: add script to create github releases
.github/workflows/gh-release.sh: add recent git log for prereleases .github/workflows/gh-release.sh: script to create github releases .github/workflows/testing.yml: fix release title Signed-off-by: Tim Janik <timj@gnu.org>
1 parent a738119 commit a07fa3d

File tree

2 files changed

+77
-1
lines changed

2 files changed

+77
-1
lines changed

.github/workflows/gh-release.sh

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
#!/usr/bin/env bash
2+
# This Source Code Form is licensed MPL-2.0: http://mozilla.org/MPL/2.0
3+
set -Eeuo pipefail && SCRIPTNAME=${0##*/} && die() { [ -z "$*" ] || echo "$SCRIPTNAME: $*" >&2; exit 127 ; }
4+
5+
# Usage: gh-release.sh [-x] <TITLE>
6+
TITLE=
7+
while test $# -ne 0 ; do
8+
case "$1" in \
9+
-x) set -x ;;
10+
-*) die "unknown options" ;;
11+
*) TITLE="$1" ;;
12+
esac
13+
shift
14+
done
15+
test ! -z "$TITLE" || die "missing project title"
16+
17+
# Artifacts
18+
ARTIFACTS=./artifacts/
19+
test -d $ARTIFACTS || die "missing release artifacts"
20+
21+
# Release version from current tag
22+
VV=$(git describe --tags --match='v[0-9]*.[0-9]*.[0-9]*' --exact-match 2>/dev/null ||
23+
git describe --match='v[0-9]*.[0-9]*.[0-9]*' 2>/dev/null) || die "missing current version tag"
24+
V="${VV#v}"
25+
TITLE="$TITLE $V"
26+
27+
# NEWS, extract first entry
28+
F_NOTES=
29+
if grep -s -m1 '^#' NEWS.md | grep -qE "\bv?${V//./\\.}($|[^a-z0-9-])" ; then
30+
sed -rn '/^##? / { p; :BEGIN ; n ; /^##? /q ; p ; bBEGIN ; }' NEWS.md > $ARTIFACTS/.notes
31+
F_NOTES="-F $ARTIFACTS/.notes"
32+
else # grab recent git log
33+
LAST=$(git describe --match='v[0-9]*.[0-9]*.[0-9]*' HEAD^ | sed 's/-[0-9]\+-g[0-9a-f]\+$//') && (
34+
echo "# $TITLE"
35+
echo
36+
echo 'Development version - may contain bugs or compatibility issues.'
37+
echo
38+
echo '``````````````````````````````````````````````````````````````````````````````````````'
39+
git log --pretty='%s # %cd %an %h%n%w(0,4,4)%b' \
40+
--first-parent --date=short "$LAST..HEAD" |
41+
sed -e '/^\s*Signed-off-by:.*<.*@.*>/d' |
42+
sed '/^\s*$/{ N; /^\s*\n\s*$/D }'
43+
echo '``````````````````````````````````````````````````````````````````````````````````````'
44+
echo ) > $ARTIFACTS/.notes &&
45+
F_NOTES="-F $ARTIFACTS/.notes"
46+
fi
47+
48+
# PRERELEASE for lightweight tag
49+
KIND=--prerelease
50+
51+
# DRAFT release for annotated tag
52+
git tag -l --format='%(objecttype)' "$VV" | grep -q '^tag' && {
53+
KIND= # immediate release
54+
KIND=--draft
55+
}
56+
57+
# INFO
58+
echo "TITLE: $TITLE"
59+
echo "CURRENT_TAG: $VV"
60+
echo "VERSION: $V"
61+
echo "ARTIFACTS:" &&
62+
ls -l ${F_NOTES#-F} $ARTIFACTS/*
63+
64+
# Create Github release for remote tag
65+
set -x
66+
gh release create \
67+
--title "$TITLE" \
68+
$F_NOTES \
69+
--generate-notes \
70+
$KIND \
71+
--verify-tag \
72+
"$VV" \
73+
$ARTIFACTS/* </dev/null
74+
75+
# Related links:
76+
# https://cli.github.com/manual/gh_help_environment

.github/workflows/testing.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ jobs:
5858
with: { path: ./artifacts, merge-multiple: true }
5959
- run: ls -alR artifacts/
6060
- run: |
61-
.github/workflows/gh-release.sh "Anklang"
61+
.github/workflows/gh-release.sh "JJ-FZF"
6262
6363
Ping-IRC:
6464
if: always()

0 commit comments

Comments
 (0)