From 05bbfce4ff989128aee2b87248b6b60cf5c207c2 Mon Sep 17 00:00:00 2001 From: Pallavi Sontakke Date: Fri, 10 Jan 2025 15:12:26 +0530 Subject: [PATCH 1/4] Add a GitHub workflow file To create minor release PR commit. Change to no more use a fork, but a branch directly. Prefix release branch , as it'll be a normal branch on timescaledb now. --- .../create_minor_release_PR_commit.yaml | 32 +++++++++++++++++ .../release/create_minor_release_PR_commit.sh | 34 +++++++++++++++---- 2 files changed, 59 insertions(+), 7 deletions(-) create mode 100644 .github/workflows/create_minor_release_PR_commit.yaml diff --git a/.github/workflows/create_minor_release_PR_commit.yaml b/.github/workflows/create_minor_release_PR_commit.yaml new file mode 100644 index 00000000000..53abfbf92dc --- /dev/null +++ b/.github/workflows/create_minor_release_PR_commit.yaml @@ -0,0 +1,32 @@ +name: Backport Bug Fixes +on: + workflow_dispatch: + +# The workflow needs the permission to push branches +permissions: + contents: write + +jobs: + create-minor-release-PR-commit: + name: Create minor release PR commit + runs-on: ubuntu-latest + + steps: + - name: Install Linux Dependencies + run: | + sudo apt-get update + sudo apt-get install pip + + - name: Install Python Dependencies + run: | + pip install PyGithub requests + + - name: Checkout TimescaleDB + uses: actions/checkout@v4 + + - name: Run the Backport Script + env: + GITHUB_TOKEN: ${{ secrets.ORG_AUTOMATION_TOKEN }} + run: | + git remote --verbose + scripts/release/create_minor_release_PR_commit.sh diff --git a/scripts/release/create_minor_release_PR_commit.sh b/scripts/release/create_minor_release_PR_commit.sh index f33ab479fc3..fee050602c2 100755 --- a/scripts/release/create_minor_release_PR_commit.sh +++ b/scripts/release/create_minor_release_PR_commit.sh @@ -2,11 +2,12 @@ set -eu # Folder, where we have cloned repositories' sources -SOURCES_DIR="sources" +SOURCES_DIR="timescaledb" GH_USERNAME=$(gh auth status | grep 'Logged in to' |cut -d ' ' -f 9) -FORK_DIR="$GH_USERNAME-timescaledb" +#folder-name +FORK_DIR="timescaledb" echo "---- Deriving the release related versions from main ----" @@ -17,6 +18,8 @@ NEW_PATCH_VERSION="0" NEW_VERSION=$(head -1 version.config | cut -d ' ' -f 3 | cut -d '-' -f 1) RELEASE_BRANCH="${NEW_VERSION/%.$NEW_PATCH_VERSION/.x}" CURRENT_VERSION=$(tail -1 version.config | cut -d ' ' -f 3) +CURRENT_MINOR_VERSION=$(echo $NEW_VERSION | cut -d '.' -f 2) +NEW_MINOR_VERSION=$((CURRENT_MINOR_VERSION + 1)) cd sql/updates for f in ./* @@ -29,7 +32,6 @@ done LAST_VERSION=$(echo "$LAST_UPDATE_FILE" |cut -d '-' -f 1 |cut -d '/' -f 2) echo "CURRENT_VERSION is $CURRENT_VERSION" -#echo "LAST_UPDATE_FILE is $LAST_UPDATE_FILE" echo "LAST_VERSION is $LAST_VERSION" echo "RELEASE_BRANCH is $RELEASE_BRANCH" echo "NEW_VERSION is $NEW_VERSION" @@ -37,18 +39,27 @@ cd ~/"$SOURCES_DIR"/"$FORK_DIR" # Derived Variables -#RELEASE_PR_BRANCH="release-$NEW_VERSION-$RELEASE_BRANCH" -RELEASE_PR_BRANCH="release-$NEW_VERSION" +RELEASE_PR_BRANCH="release/release-$NEW_VERSION" UPDATE_FILE="$CURRENT_VERSION--$NEW_VERSION.sql" DOWNGRADE_FILE="$NEW_VERSION--$CURRENT_VERSION.sql" LAST_UPDATE_FILE="$LAST_VERSION--$CURRENT_VERSION.sql" LAST_DOWNGRADE_FILE="$CURRENT_VERSION--$LAST_VERSION.sql" +RELEASE_BRANCH_EXISTS=$(git branch -a |grep -c "origin/$RELEASE_BRANCH"|cut -d ' ' -f 1) + +if [[ $RELEASE_BRANCH_EXISTS == '0' ]]; then + echo "git branch '$RELEASE_BRANCH' does not exist in the remote repository, yet" + echo "We want to raise this PR against main" + RELEASE_BRANCH="main" + RELEASE_PR_BRANCH="$RELEASE_PR_BRANCH-main" +fi + +echo "final RELEASE_BRANCH is $RELEASE_BRANCH" +echo "RELEASE_PR_BRANCH is $RELEASE_PR_BRANCH" echo "---- Creating release branch $RELEASE_PR_BRANCH from $RELEASE_BRANCH, on the fork ----" -git checkout -b "$RELEASE_PR_BRANCH" upstream/"$RELEASE_BRANCH" -#git checkout -b "$RELEASE_PR_BRANCH" upstream/main +git checkout -b "$RELEASE_PR_BRANCH" origin/"$RELEASE_BRANCH" git branch git pull && git diff HEAD @@ -129,6 +140,15 @@ done cd .. + +if [[ $RELEASE_BRANCH_EXISTS == '0' ]]; then + echo "---- Modifying version.config to the new versions , if current PR is for main----" + sed -i.bak "s/${NEW_VERSION}/${NEW_VERSION}-dev/g" version.config + sed -i.bak "s/${CURRENT_MINOR_VERSION}/${NEW_MINOR_VERSION}/g" version.config + sed -i.bak "s/${CURRENT_VERSION}/${NEW_VERSION}/g" version.config + rm version.config.bak +fi + git diff HEAD --name-only From 74587263b3a4fe4b591d328151add16db59939aa Mon Sep 17 00:00:00 2001 From: Pallavi Sontakke Date: Mon, 13 Jan 2025 10:49:32 +0530 Subject: [PATCH 2/4] Add a GitHub workflow file To create minor release branch. --- .../create_minor_release_PR_commit.yaml | 4 +-- .../create_minor_release_branch.yaml | 32 +++++++++++++++++++ .../release/create_minor_release_branch.sh | 4 +-- 3 files changed, 36 insertions(+), 4 deletions(-) create mode 100644 .github/workflows/create_minor_release_branch.yaml diff --git a/.github/workflows/create_minor_release_PR_commit.yaml b/.github/workflows/create_minor_release_PR_commit.yaml index 53abfbf92dc..caa5a2b69cf 100644 --- a/.github/workflows/create_minor_release_PR_commit.yaml +++ b/.github/workflows/create_minor_release_PR_commit.yaml @@ -1,4 +1,4 @@ -name: Backport Bug Fixes +name: Create minor release PR commit on: workflow_dispatch: @@ -24,7 +24,7 @@ jobs: - name: Checkout TimescaleDB uses: actions/checkout@v4 - - name: Run the Backport Script + - name: Run the minor-release PR creation Script env: GITHUB_TOKEN: ${{ secrets.ORG_AUTOMATION_TOKEN }} run: | diff --git a/.github/workflows/create_minor_release_branch.yaml b/.github/workflows/create_minor_release_branch.yaml new file mode 100644 index 00000000000..55b47d1998c --- /dev/null +++ b/.github/workflows/create_minor_release_branch.yaml @@ -0,0 +1,32 @@ +name: Create minor release branch +on: + workflow_dispatch: + +# The workflow needs the permission to push branches +permissions: + contents: write + +jobs: + create-minor-release-branch: + name: Create minor release branch + runs-on: ubuntu-latest + + steps: + - name: Install Linux Dependencies + run: | + sudo apt-get update + sudo apt-get install pip + + - name: Install Python Dependencies + run: | + pip install PyGithub requests + + - name: Checkout TimescaleDB + uses: actions/checkout@v4 + + - name: Run the minor-release branch creation Script + env: + GITHUB_TOKEN: ${{ secrets.ORG_AUTOMATION_TOKEN }} + run: | + git remote --verbose + scripts/release/create_minor_release_branch.sh diff --git a/scripts/release/create_minor_release_branch.sh b/scripts/release/create_minor_release_branch.sh index 3945943395d..33975dcd274 100755 --- a/scripts/release/create_minor_release_branch.sh +++ b/scripts/release/create_minor_release_branch.sh @@ -2,11 +2,11 @@ set -eu # Folder, where we have cloned repositories' sources -SOURCES_DIR="sources" +SOURCES_DIR="timescaledb" GH_USERNAME=$(gh auth status | grep 'Logged in to' |cut -d ' ' -f 9) -FORK_DIR="$GH_USERNAME-timescaledb" +FORK_DIR="timescaledb" echo "---- Deriving the release related versions from main ----" From 01c617f70b142a05b39261fb5ec8ae84809d80e3 Mon Sep 17 00:00:00 2001 From: Pallavi Sontakke Date: Mon, 13 Jan 2025 11:36:35 +0530 Subject: [PATCH 3/4] Remove unused variable Adjust script to work without fork, directly. --- scripts/release/create_minor_release_PR_commit.sh | 2 -- scripts/release/create_minor_release_branch.sh | 6 ++---- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/scripts/release/create_minor_release_PR_commit.sh b/scripts/release/create_minor_release_PR_commit.sh index fee050602c2..df90a117e5b 100755 --- a/scripts/release/create_minor_release_PR_commit.sh +++ b/scripts/release/create_minor_release_PR_commit.sh @@ -4,8 +4,6 @@ set -eu # Folder, where we have cloned repositories' sources SOURCES_DIR="timescaledb" -GH_USERNAME=$(gh auth status | grep 'Logged in to' |cut -d ' ' -f 9) - #folder-name FORK_DIR="timescaledb" diff --git a/scripts/release/create_minor_release_branch.sh b/scripts/release/create_minor_release_branch.sh index 33975dcd274..881ca96e475 100755 --- a/scripts/release/create_minor_release_branch.sh +++ b/scripts/release/create_minor_release_branch.sh @@ -4,8 +4,6 @@ set -eu # Folder, where we have cloned repositories' sources SOURCES_DIR="timescaledb" -GH_USERNAME=$(gh auth status | grep 'Logged in to' |cut -d ' ' -f 9) - FORK_DIR="timescaledb" echo "---- Deriving the release related versions from main ----" @@ -25,6 +23,6 @@ echo "NEW_VERSION is $NEW_VERSION" echo "---- Creating the version branch from main ----" git fetch --all -git checkout -b "$RELEASE_BRANCH" upstream/main -git push upstream "$RELEASE_BRANCH":"$RELEASE_BRANCH" +git checkout -b "$RELEASE_BRANCH" origin/main +git push origin "$RELEASE_BRANCH":"$RELEASE_BRANCH" From 45e4d6892f0f0671589a5d4dd68c91f02d174a84 Mon Sep 17 00:00:00 2001 From: Pallavi Sontakke Date: Tue, 14 Jan 2025 18:48:26 +0530 Subject: [PATCH 4/4] Merge workflows into a single one for minor release. For better understanding: - Edit names of steps in the workflow - Edit branch names in the script --- .../create_minor_release_branch.yaml | 32 ------------------- ...ease_PR_commit.yaml => minor_release.yaml} | 22 ++++++++++--- .../release/create_minor_release_PR_commit.sh | 4 +-- 3 files changed, 20 insertions(+), 38 deletions(-) delete mode 100644 .github/workflows/create_minor_release_branch.yaml rename .github/workflows/{create_minor_release_PR_commit.yaml => minor_release.yaml} (51%) diff --git a/.github/workflows/create_minor_release_branch.yaml b/.github/workflows/create_minor_release_branch.yaml deleted file mode 100644 index 55b47d1998c..00000000000 --- a/.github/workflows/create_minor_release_branch.yaml +++ /dev/null @@ -1,32 +0,0 @@ -name: Create minor release branch -on: - workflow_dispatch: - -# The workflow needs the permission to push branches -permissions: - contents: write - -jobs: - create-minor-release-branch: - name: Create minor release branch - runs-on: ubuntu-latest - - steps: - - name: Install Linux Dependencies - run: | - sudo apt-get update - sudo apt-get install pip - - - name: Install Python Dependencies - run: | - pip install PyGithub requests - - - name: Checkout TimescaleDB - uses: actions/checkout@v4 - - - name: Run the minor-release branch creation Script - env: - GITHUB_TOKEN: ${{ secrets.ORG_AUTOMATION_TOKEN }} - run: | - git remote --verbose - scripts/release/create_minor_release_branch.sh diff --git a/.github/workflows/create_minor_release_PR_commit.yaml b/.github/workflows/minor_release.yaml similarity index 51% rename from .github/workflows/create_minor_release_PR_commit.yaml rename to .github/workflows/minor_release.yaml index caa5a2b69cf..4755e4e40aa 100644 --- a/.github/workflows/create_minor_release_PR_commit.yaml +++ b/.github/workflows/minor_release.yaml @@ -1,4 +1,4 @@ -name: Create minor release PR commit +name: Minor release on: workflow_dispatch: @@ -7,8 +7,8 @@ permissions: contents: write jobs: - create-minor-release-PR-commit: - name: Create minor release PR commit + minor-release: + name: Minor release runs-on: ubuntu-latest steps: @@ -24,7 +24,21 @@ jobs: - name: Checkout TimescaleDB uses: actions/checkout@v4 - - name: Run the minor-release PR creation Script + - name: Create PR to main branch for minor release + env: + GITHUB_TOKEN: ${{ secrets.ORG_AUTOMATION_TOKEN }} + run: | + git remote --verbose + scripts/release/create_minor_release_PR_commit.sh + + - name: Create release branch for minor release + env: + GITHUB_TOKEN: ${{ secrets.ORG_AUTOMATION_TOKEN }} + run: | + git remote --verbose + scripts/release/create_minor_release_branch.sh + + - name: Create PR to release branch for minor release env: GITHUB_TOKEN: ${{ secrets.ORG_AUTOMATION_TOKEN }} run: | diff --git a/scripts/release/create_minor_release_PR_commit.sh b/scripts/release/create_minor_release_PR_commit.sh index df90a117e5b..e9d750273aa 100755 --- a/scripts/release/create_minor_release_PR_commit.sh +++ b/scripts/release/create_minor_release_PR_commit.sh @@ -37,7 +37,7 @@ cd ~/"$SOURCES_DIR"/"$FORK_DIR" # Derived Variables -RELEASE_PR_BRANCH="release/release-$NEW_VERSION" +RELEASE_PR_BRANCH="release/$NEW_VERSION" UPDATE_FILE="$CURRENT_VERSION--$NEW_VERSION.sql" DOWNGRADE_FILE="$NEW_VERSION--$CURRENT_VERSION.sql" LAST_UPDATE_FILE="$LAST_VERSION--$CURRENT_VERSION.sql" @@ -49,7 +49,7 @@ if [[ $RELEASE_BRANCH_EXISTS == '0' ]]; then echo "git branch '$RELEASE_BRANCH' does not exist in the remote repository, yet" echo "We want to raise this PR against main" RELEASE_BRANCH="main" - RELEASE_PR_BRANCH="$RELEASE_PR_BRANCH-main" + RELEASE_PR_BRANCH="$RELEASE_PR_BRANCH-to-main" fi echo "final RELEASE_BRANCH is $RELEASE_BRANCH"