Skip to content

Commit 1819a39

Browse files
committed
Use gh in publish
1 parent aa24b55 commit 1819a39

File tree

1 file changed

+39
-15
lines changed

1 file changed

+39
-15
lines changed

publish

Lines changed: 39 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,46 @@
11
#! /bin/bash
22

3+
set -u
34
set -e
5+
6+
dry_run=
7+
if [[ "$1" == '-n' || "$1" == '--dry-run' ]]
8+
then
9+
dry_run=echo
10+
fi
11+
12+
generate_release_notes() {
13+
OLDIFS="$IFS"
14+
IFS=$'\n' changelog=( $(git-log-from-last-tag) )
15+
IFS="$OLDIFS"
16+
for l in "${changelog[@]}"
17+
do
18+
[[ "$l" == 'Bump' ]] && continue
19+
printf '%s\n' "$l"
20+
done
21+
}
22+
423
blue=$(tput setaf 32)
524
sgr0=$(tput sgr0)
625
eval $(grep version setup.py | sed 's/,$//')
726
tag="v$version"
8-
git tag "$tag" || printf 'WARNING: tag "%s" already exists\n' "$tag"
9-
git push --tags
10-
printf 'Next steps:\n'
11-
printf '1. Create new release on Github using tag=%s title=%s\n' "v$version" "v$version"
12-
printf ' url: %s%s%s\n' "${blue}" 'https://github.com/dtmilano/AndroidViewClient/releases/new' "${sgr0}"
13-
printf '\n'
14-
OLDIFS="$IFS"
15-
IFS=$'\n' changelog=( $(git-log-from-last-tag) )
16-
IFS="$OLDIFS"
17-
for l in "${changelog[@]}"
18-
do
19-
printf '%s\n' "$l"
20-
done
21-
printf '\n'
22-
printf '2. Github Actions kicks off automatically to release new version\n'
27+
title="v$version"
28+
$dry_run git tag "$tag" || printf 'WARNING: tag "%s" already exists\n' "$tag"
29+
$dry_run git push --tags
30+
if which -s gh
31+
then
32+
release_notes=$(mktemp)
33+
generate_release_notes > "$release_notes"
34+
$dry_run gh release create --title "$title" --notes-file "$release_notes" "$tag"
35+
printf '\nNext steps:\n'
36+
step=1
37+
else
38+
printf '\nNext steps:\n'
39+
printf '1. Create new release on Github using tag=%s title=%s\n' "$tag" "$title"
40+
printf ' url: %s%s%s\n' "${blue}" 'https://github.com/dtmilano/AndroidViewClient/releases/new' "${sgr0}"
41+
printf '\n'
42+
generate_release_notes
43+
step=2
44+
fi
45+
46+
printf '%d. Github Actions kicks off automatically to release new version\n' "$step"

0 commit comments

Comments
 (0)