Skip to content

Commit

Permalink
use old create_changelog.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
friedrichwilken committed Feb 8, 2024
1 parent 302370e commit 3720d1f
Showing 1 changed file with 13 additions and 15 deletions.
28 changes: 13 additions & 15 deletions hack/scripts/create_changelog.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#!/usr/bin/env bash

# Error handling.
PREVIOUS_RELEASE=$2 # for testability

# standard bash error handling
set -o nounset # treat unset variables as an error and exit immediately.
set -o errexit # exit immediately when a command fails.
set -E # needs to be set if we want the ERR trap
Expand All @@ -10,34 +12,28 @@ RELEASE_TAG=$1

REPOSITORY=${REPOSITORY:-kyma-project/eventing-manager}
GITHUB_URL=https://api.github.com/repos/${REPOSITORY}
GITHUB_AUTH_HEADER="Authorization: token ${GH_TOKEN}"
GITHUB_AUTH_HEADER="Authorization: token ${GITHUB_TOKEN}"
CHANGELOG_FILE="CHANGELOG.md"

# The git describe --tag --abbrev=0 command is used to find the most recent tag that is reachable from a commit.
# The --tag option tells git describe to consider any tag found in the refs/tags namespace, enabling matching a lightweight (non-annotated) tag.
PREVIOUS_RELEASE=$(git describe --tags --abbrev=0)
if [ "${PREVIOUS_RELEASE}" == "" ]; then
PREVIOUS_RELEASE=$(git describe --tags --abbrev=0)
fi

# Generate the changelog in the CHANGELOG.md.
echo "## What has changed" >>${CHANGELOG_FILE}

# Iterate over all commits since the previous release.
git log "${PREVIOUS_RELEASE}"..HEAD --pretty=tformat:"%h" --reverse | while read -r commit; do
# If the author of the commit is not kyma-bot, append the commit message to the changelog.
git log ${PREVIOUS_RELEASE}..HEAD --pretty=tformat:"%h" --reverse | while read -r commit; do
COMMIT_AUTHOR=$(curl -H "${GITHUB_AUTH_HEADER}" -sS "${GITHUB_URL}/commits/${commit}" | jq -r '.author.login')
if [ "${COMMIT_AUTHOR}" != "kyma-bot" ]; then
git show -s "${commit}" --format="* %s by @${COMMIT_AUTHOR}" >>${CHANGELOG_FILE}
git show -s ${commit} --format="* %s by @${COMMIT_AUTHOR}" >>${CHANGELOG_FILE}
fi
done

# Create a new contibutors file (with a unique name based on the process ID of the current shell).
NEW_CONTRIB=$$.authors
NEW_CONTRIB=$$.new

# Find unique authors who contributed since the last release, but not before it, and add them to the NEW_CONTRIB file.
join -v2 \
<(curl -H "${GITHUB_AUTH_HEADER}" -sS "${GITHUB_URL}/compare/$(git rev-list --max-parents=0 HEAD)...${PREVIOUS_RELEASE}" | jq -r '.commits[].author.login' | sort -u) \
<(curl -H "${GITHUB_AUTH_HEADER}" -sS "${GITHUB_URL}/compare/${PREVIOUS_RELEASE}...HEAD" | jq -r '.commits[].author.login' | sort -u) >${NEW_CONTRIB}

# Add new contributors to the 'new contributors' section of the changelog.
if [ -s ${NEW_CONTRIB} ]; then
echo -e "\n## New contributors" >>${CHANGELOG_FILE}
while read -r user; do
Expand All @@ -49,5 +45,7 @@ if [ -s ${NEW_CONTRIB} ]; then
done <${NEW_CONTRIB}
fi

# Append link to the full-changelog this changelog.
echo -e "\n**Full changelog**: https://github.com/$REPOSITORY/compare/${PREVIOUS_RELEASE}...${RELEASE_TAG}" >>${CHANGELOG_FILE}

# cleanup
rm ${NEW_CONTRIB} || echo "cleaned up"

0 comments on commit 3720d1f

Please sign in to comment.