From 76254abc5a7676d5e2dfd8270e3c31c11f1f4d1b Mon Sep 17 00:00:00 2001 From: Friedrich Wilken Date: Thu, 8 Feb 2024 12:40:46 +0100 Subject: [PATCH 1/4] fix get-version-from-release-branch-reusable.yml --- .../get-version-from-release-branch-reusable.yml | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/.github/workflows/get-version-from-release-branch-reusable.yml b/.github/workflows/get-version-from-release-branch-reusable.yml index 40a1811..532fef8 100644 --- a/.github/workflows/get-version-from-release-branch-reusable.yml +++ b/.github/workflows/get-version-from-release-branch-reusable.yml @@ -35,11 +35,15 @@ jobs: MINOR: ${{ env.MINOR }} run: | TAGS=$(git tag -l "$MAJOR.$MINOR.*") - if [[ -z $TAGS ]]; then - PATCH=0 + if [[ -n $TAGS ]]; then + # -n tests for a non-zero-length string + LAST_PATCH=$(echo "$TAGS" | cut -d '.' -f 3 | sort -n | tail -n 1) + PATCH=$((LAST_PATCH + 1)) else - PATCH=$(( $(echo $TAGS | cut -d '.' -f 3 | sort -n | tail -n 1) + 1)) + # If TAGS is empty, PATCH defaults to 0 + PATCH=0 fi - VERSION="${MAJOR}.${MINOR}.${PATCH:-0}" + VERSION="${MAJOR}.${MINOR}.${PATCH}" + echo "version: ${VERSION}" echo "VERSION=${VERSION}" >> $GITHUB_OUTPUT exit 0 From ae078f4340d8c9512d280d0906d245f59aac1580 Mon Sep 17 00:00:00 2001 From: Friedrich Wilken Date: Thu, 8 Feb 2024 12:41:23 +0100 Subject: [PATCH 2/4] revert breaking changes to create_changelog.sh --- hack/scripts/create_changelog.sh | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/hack/scripts/create_changelog.sh b/hack/scripts/create_changelog.sh index 7955691..1b9aa17 100755 --- a/hack/scripts/create_changelog.sh +++ b/hack/scripts/create_changelog.sh @@ -1,5 +1,8 @@ #!/usr/bin/env bash +# Optional args need to be handled before 'set -o nonset'. +PREVIOUS_RELEASE=$3 # for testability + # Error handling. set -o nounset # treat unset variables as an error and exit immediately. set -o errexit # exit immediately when a command fails. @@ -7,15 +10,18 @@ set -E # needs to be set if we want the ERR trap set -o pipefail # prevents errors in a pipeline from being masked RELEASE_TAG=$1 +REPOSITORY=$2 -REPOSITORY=${REPOSITORY:-kyma-project/eventing-manager} GITHUB_URL=https://api.github.com/repos/${REPOSITORY} GITHUB_AUTH_HEADER="Authorization: token ${GH_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 the previous release was not passed, we will +if [ "${PREVIOUS_RELEASE}" == "" ]; then + # 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) +fi # Generate the changelog in the CHANGELOG.md. echo "## What has changed" >>${CHANGELOG_FILE} @@ -30,7 +36,7 @@ git log "${PREVIOUS_RELEASE}"..HEAD --pretty=tformat:"%h" --reverse | while read 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 \ @@ -51,3 +57,6 @@ 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 the NEW_CONTRIB file. +rm ${NEW_CONTRIB} || true From c3d8b3304622898fd33fdc488ee4a45ee03cfe54 Mon Sep 17 00:00:00 2001 From: Friedrich Wilken Date: Thu, 8 Feb 2024 13:35:33 +0100 Subject: [PATCH 3/4] add newlines under headlines --- hack/scripts/create_changelog.sh | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/hack/scripts/create_changelog.sh b/hack/scripts/create_changelog.sh index 1b9aa17..303cc36 100755 --- a/hack/scripts/create_changelog.sh +++ b/hack/scripts/create_changelog.sh @@ -25,6 +25,7 @@ fi # Generate the changelog in the CHANGELOG.md. echo "## What has changed" >>${CHANGELOG_FILE} +echo "" >>${CHANGELOG_FILE} # Iterate over all commits since the previous release. git log "${PREVIOUS_RELEASE}"..HEAD --pretty=tformat:"%h" --reverse | while read -r commit; do @@ -46,6 +47,7 @@ join -v2 \ # Add new contributors to the 'new contributors' section of the changelog. if [ -s ${NEW_CONTRIB} ]; then echo -e "\n## New contributors" >>${CHANGELOG_FILE} + echo "" >>${CHANGELOG_FILE} while read -r user; do REF_PR=$(grep "@${user}" ${CHANGELOG_FILE} | head -1 | grep -o " (#[0-9]\+)" || true) if [ -n "${REF_PR}" ]; then #reference found @@ -57,6 +59,3 @@ 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 the NEW_CONTRIB file. -rm ${NEW_CONTRIB} || true From 49a68e80f6234f983dd6475a61ea40e4713b85c2 Mon Sep 17 00:00:00 2001 From: Friedrich Wilken Date: Thu, 8 Feb 2024 13:45:36 +0100 Subject: [PATCH 4/4] add nicer newlines --- hack/scripts/create_changelog.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hack/scripts/create_changelog.sh b/hack/scripts/create_changelog.sh index 303cc36..aa7990c 100755 --- a/hack/scripts/create_changelog.sh +++ b/hack/scripts/create_changelog.sh @@ -25,7 +25,7 @@ fi # Generate the changelog in the CHANGELOG.md. echo "## What has changed" >>${CHANGELOG_FILE} -echo "" >>${CHANGELOG_FILE} +echo >>${CHANGELOG_FILE} # add newline # Iterate over all commits since the previous release. git log "${PREVIOUS_RELEASE}"..HEAD --pretty=tformat:"%h" --reverse | while read -r commit; do @@ -47,7 +47,7 @@ join -v2 \ # Add new contributors to the 'new contributors' section of the changelog. if [ -s ${NEW_CONTRIB} ]; then echo -e "\n## New contributors" >>${CHANGELOG_FILE} - echo "" >>${CHANGELOG_FILE} + echo >>${CHANGELOG_FILE} # add newline while read -r user; do REF_PR=$(grep "@${user}" ${CHANGELOG_FILE} | head -1 | grep -o " (#[0-9]\+)" || true) if [ -n "${REF_PR}" ]; then #reference found