Skip to content

Commit

Permalink
Derive CHANGELOG_HEADER_LINES programmatically
Browse files Browse the repository at this point in the history
From current CHANGELOG.md , instead of keeping it a fixed number of lines.
  • Loading branch information
pallavisontakke committed Sep 3, 2024
1 parent b0c7cc2 commit c624ef4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
7 changes: 4 additions & 3 deletions scripts/release/create_minor_release_PR_commit.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ set -eu
# Folder, where we have cloned repositories' sources
SOURCES_DIR="sources"

CHANGELOG_HEADER_LINES="6"

GH_USERNAME=$(gh auth status | grep 'Logged in to' |cut -d ' ' -f 9)

FORK_DIR="$GH_USERNAME-timescaledb"
Expand Down Expand Up @@ -93,8 +91,11 @@ cd ~/"$SOURCES_DIR"/"$FORK_DIR"
echo "---- Editing the CHANGELOG.md file with the contents of CHANGELOG_"$NEW_VERSION".md file. ----"

cd ~/"$SOURCES_DIR"/"$FORK_DIR"
RELEASE_NOTE_START=$(grep -n $CURRENT_VERSION CHANGELOG.md | cut -d ':' -f 1 | head -1)
CHANGELOG_HEADER_LINES=$((RELEASE_NOTE_START - 1))

mv CHANGELOG.md CHANGELOG.md.tmp
head -n 6 CHANGELOG.md.tmp > CHANGELOG.md
head -n $CHANGELOG_HEADER_LINES CHANGELOG.md.tmp > CHANGELOG.md
cat ~/CHANGELOG_"$NEW_VERSION".md >> CHANGELOG.md
CHANGELOG_LENGTH=$(wc -l CHANGELOG.md.tmp | cut -d ' ' -f 5)
CHANGELOG_ENTRIES=$((CHANGELOG_LENGTH-CHANGELOG_HEADER_LINES))
Expand Down
7 changes: 4 additions & 3 deletions scripts/release/create_release_PR_commit.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ set -eu
# Folder, where we have cloned repositories' sources
SOURCES_DIR="sources"

CHANGELOG_HEADER_LINES="6"

GH_USERNAME=$(gh auth status | grep 'Logged in to' |cut -d ' ' -f 9)

FORK_DIR="$GH_USERNAME-timescaledb"
Expand Down Expand Up @@ -96,8 +94,11 @@ cd ~/"$SOURCES_DIR"/"$FORK_DIR"
echo "---- Editing the CHANGELOG.md file with the contents of CHANGELOG_"$NEW_VERSION".md file. ----"

cd ~/"$SOURCES_DIR"/"$FORK_DIR"
RELEASE_NOTE_START=$(grep -n $CURRENT_VERSION CHANGELOG.md | cut -d ':' -f 1 | head -1)
CHANGELOG_HEADER_LINES=$((RELEASE_NOTE_START - 1))

mv CHANGELOG.md CHANGELOG.md.tmp
head -n 6 CHANGELOG.md.tmp > CHANGELOG.md
head -n $CHANGELOG_HEADER_LINES CHANGELOG.md.tmp > CHANGELOG.md
cat ~/CHANGELOG_"$NEW_VERSION".md >> CHANGELOG.md
CHANGELOG_LENGTH=$(wc -l CHANGELOG.md.tmp | cut -d ' ' -f 5)
CHANGELOG_ENTRIES=$((CHANGELOG_LENGTH-CHANGELOG_HEADER_LINES))
Expand Down

0 comments on commit c624ef4

Please sign in to comment.