git-secret/.ci/github_release_script.sh

33 lines
851 B
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 11:51:06 +00:00
LAST_RELEASE_TAG=$(curl \
--header "authorization: Bearer $GITHUB_TOKEN" \
--url "https://api.github.com/repos/$GITHUB_REPOSITORY/releases/latest" \
2>/dev/null | jq .tag_name | sed 's/"//g'
)
2019-03-17 16:23:34 +00:00
echo "LAST_RELEASE_TAG=$LAST_RELEASE_TAG"
2021-05-06 11:51:06 +00:00
NEW_CHANGELOG='CHANGELOG-RELEASE.md'
2019-03-17 16:23:34 +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" \
--token "$GITHUB_TOKEN" \
--output "$NEW_CHANGELOG"
echo 'Done! Changelog:'
cat "$NEW_CHANGELOG"