Created
January 11, 2020 02:18
-
-
Save keymon/31b33420243f5cfaa52f054ba3ead351 to your computer and use it in GitHub Desktop.
Release binaries to github using hub
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -e -o pipefail -u | |
if [ "$#" -lt 1 ]; then | |
echo "Attaches files to the latest tag in github" 1>&2 | |
echo "Usage: $0 [files...]" 1>&2 | |
exit 1 | |
fi | |
last_pr="$(git rev-list --min-parents=2 --max-count=1 HEAD)" | |
previous_pr="$(git rev-list --min-parents=2 --max-count=2 HEAD | sed -n '2p')" | |
last_tag="$(git describe --abbrev=0 --tags )" | |
pr_title="$(git show --pretty=format:%B "${last_pr}" | sed -n '3p')" | |
release_body="$( | |
git log ${previous_pr}..HEAD --pretty=format:' - %h %s' | grep -v 'chore:' | grep -v "Merge pull request" | |
)" | |
tmpfile="$(mktemp)" | |
trap 'rm -f ${tmpfile:-foo}' EXIT | |
cat > "${tmpfile}" <<EOF | |
${pr_title} | |
${release_body} | |
EOF | |
args="" | |
for i in $@; do | |
args="$args -a $i" | |
done | |
if hub release | grep -q "^${last_tag}\$"; then | |
hub release delete "${last_tag}" | |
fi | |
hub release create -F "${tmpfile}" ${args} "${last_tag}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment