yq/scripts/publish.sh

41 lines
1.1 KiB
Bash
Raw Normal View History

2017-09-25 01:10:57 +00:00
#!/bin/bash
GITHUB_TOKEN="${GITHUB_TOKEN:?missing required input \'GITHUB_TOKEN\'}"
CURRENT="$(git describe --tags --abbrev=0)"
PREVIOUS="$(git describe --tags --abbrev=0 --always "${CURRENT}"^)"
OWNER="mikefarah"
2018-05-07 06:40:23 +00:00
REPO="yq"
2017-09-25 01:10:57 +00:00
release() {
mapfile -t logs < <(git log --pretty=oneline --abbrev-commit "${PREVIOUS}".."${CURRENT}")
description="$(printf '%s\n' "${logs[@]}")"
github-release release \
--user "$OWNER" \
--repo "$REPO" \
--tag "$CURRENT" \
--description "$description" ||
github-release edit \
--user "$OWNER" \
--repo "$REPO" \
--tag "$CURRENT" \
--description "$description"
}
upload() {
mapfile -t files < <(find ./build -mindepth 1 -maxdepth 1)
for file in "${files[@]}"; do
BINARY=$(basename "${file}")
echo "--> ${BINARY}"
github-release upload \
--user "$OWNER" \
--repo "$REPO" \
--tag "$CURRENT" \
--name "${BINARY}" \
--file "$file"
done
}
release
upload