From 1740a9c971b1faa87989d07284f18d871b359b5a Mon Sep 17 00:00:00 2001 From: Friedrich Wilken Date: Mon, 18 Dec 2023 18:14:09 +0100 Subject: [PATCH] clean and format code --- .github/workflows/create-release.yaml | 12 +------ scripts/create_changelog.sh | 47 ++++++++++++--------------- 2 files changed, 22 insertions(+), 37 deletions(-) diff --git a/.github/workflows/create-release.yaml b/.github/workflows/create-release.yaml index 07c937b4..5c16b55b 100644 --- a/.github/workflows/create-release.yaml +++ b/.github/workflows/create-release.yaml @@ -4,7 +4,7 @@ on: workflow_dispatch: inputs: name: - description: 'Release name' + description: "Release name" default: "" required: true @@ -28,11 +28,6 @@ jobs: - name: Verify run: ./scripts/verify-status.sh ${{ github.ref_name }} - # run-unit-tests: - # name: Unit tests - # needs: verify-head-status - # uses: "./.github/workflows/run-unit-tests.yaml" - create-draft: name: Create draft release needs: verify-head-status @@ -65,11 +60,6 @@ jobs: outputs: release_id: ${{ steps.create-draft.outputs.release_id }} - # devOps-Insights: - # name: DevOps Insights - # needs: [verify-head-status, create-draft, run-unit-tests] - # uses: "./.github/workflows/metrics.yaml" - publish-release: name: Publish release needs: [verify-head-status, create-draft] diff --git a/scripts/create_changelog.sh b/scripts/create_changelog.sh index afce1ad5..7bb28cf5 100755 --- a/scripts/create_changelog.sh +++ b/scripts/create_changelog.sh @@ -15,42 +15,37 @@ GITHUB_URL=https://api.github.com/repos/${REPOSITORY} GITHUB_AUTH_HEADER="Authorization: token ${GITHUB_TOKEN}" CHANGELOG_FILE="CHANGELOG.md" -if [ "${PREVIOUS_RELEASE}" == "" ] -then - PREVIOUS_RELEASE=$(git describe --tags --abbrev=0) +if [ "${PREVIOUS_RELEASE}" == "" ]; then + PREVIOUS_RELEASE=$(git describe --tags --abbrev=0) fi -echo "## What has changed" >> ${CHANGELOG_FILE} +echo "## What has changed" >>${CHANGELOG_FILE} -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} - fi +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} + fi done NEW_CONTRIB=$$.new 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} - -if [ -s ${NEW_CONTRIB} ] -then - echo -e "\n## New contributors" >> ${CHANGELOG_FILE} - while read -r user - do - REF_PR=$(grep "@${user}" ${CHANGELOG_FILE} | head -1 | grep -o " (#[0-9]\+)" || true) - if [ -n "${REF_PR}" ] #reference found - then - REF_PR=" in ${REF_PR}" - fi - echo "* @${user} made first contribution${REF_PR}" >> ${CHANGELOG_FILE} - done <${NEW_CONTRIB} + <(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} + +if [ -s ${NEW_CONTRIB} ]; then + echo -e "\n## New contributors" >>${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 + REF_PR=" in ${REF_PR}" + fi + echo "* @${user} made first contribution${REF_PR}" >>${CHANGELOG_FILE} + done <${NEW_CONTRIB} fi -echo -e "\n**Full changelog**: https://github.com/$REPOSITORY/compare/${PREVIOUS_RELEASE}...${RELEASE_TAG}" >> ${CHANGELOG_FILE} +echo -e "\n**Full changelog**: https://github.com/$REPOSITORY/compare/${PREVIOUS_RELEASE}...${RELEASE_TAG}" >>${CHANGELOG_FILE} # cleanup rm ${NEW_CONTRIB} || echo "cleaned up"