Skip to content

Commit

Permalink
Add a GitHub workflow file
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
pallavisontakke committed Jan 13, 2025
1 parent 62e6235 commit aaa5706
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 7 deletions.
32 changes: 32 additions & 0 deletions .github/workflows/create_minor_release_PR_commit.yaml
Original file line number Diff line number Diff line change
@@ -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
34 changes: 27 additions & 7 deletions scripts/release/create_minor_release_PR_commit.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 ----"

Expand All @@ -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 ./*
Expand All @@ -29,26 +32,34 @@ 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"
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

Expand Down Expand Up @@ -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


Expand Down

0 comments on commit aaa5706

Please sign in to comment.