git-secret/.ci/github_release_script.sh

40 lines
1.0 KiB
Bash
Raw Normal View History

2021-05-06 11:51:06 +00:00
#!/usr/bin/env sh
set -e
# Installing additional deps:
apk add --no-cache curl jq
2019-03-17 16:23:34 +00:00
# https://gist.github.com/Jaskaranbir/d5b065173b3a6f164e47a542472168c1
2021-05-06 11:51:06 +00:00
USER="$(echo "$GITHUB_REPOSITORY" | cut -d "/" -f1)"
PROJECT="$(echo "$GITHUB_REPOSITORY" | cut -d "/" -f2)"
2019-03-17 16:23:34 +00:00
2021-05-06 12:48:16 +00:00
LAST_RELEASE_TAG=$(curl \
2021-05-06 11:51:06 +00:00
--header "authorization: Bearer $GITHUB_TOKEN" \
2021-05-06 12:48:16 +00:00
--url "https://api.github.com/repos/$GITHUB_REPOSITORY/releases/latest" \
| jq .tag_name | sed 's/"//g'
)
2019-03-17 16:23:34 +00:00
echo "LAST_RELEASE_TAG=$LAST_RELEASE_TAG"
2021-05-06 14:47:41 +00:00
if [ "$LAST_RELEASE_TAG" = 'null' ]; then
# Most likely, we are facing rate-limiting problems,
# just try again later.
exit 1
fi
2019-03-17 16:23:34 +00:00
2021-05-06 11:51:06 +00:00
NEW_CHANGELOG='CHANGELOG-RELEASE.md'
2021-05-06 12:48:16 +00:00
2021-05-06 11:51:06 +00:00
# Generate new CHANGELOG.md with just the last changes
2019-03-17 16:23:34 +00:00
github_changelog_generator \
2021-05-06 11:51:06 +00:00
--user "$USER" \
--project "$PROJECT" \
2021-05-03 11:04:02 +00:00
--token "$GITHUB_OAUTH_TOKEN" \
2021-05-06 11:51:06 +00:00
--since-tag "$LAST_RELEASE_TAG" \
2021-05-06 16:42:54 +00:00
--max-issues 100 \
2021-05-06 16:18:13 +00:00
--no-issues \
--release-branch 'master' \
2021-05-06 11:51:06 +00:00
--token "$GITHUB_TOKEN" \
--output "$NEW_CHANGELOG"
echo 'Done! Changelog:'
cat "$NEW_CHANGELOG"