diff --git a/.github/workflows/minor_release.yaml b/.github/workflows/minor_release.yaml new file mode 100644 index 00000000000..d5504e4baa6 --- /dev/null +++ b/.github/workflows/minor_release.yaml @@ -0,0 +1,56 @@ +name: Minor release +on: + workflow_dispatch: + +# The workflow needs the permission to push branches +permissions: + contents: write + +jobs: + minor-release: + name: Minor release + 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: Set env var NEW_VERSION + run: echo "NEW_VERSION=$(head -1 version.config | cut -d ' ' -f 3 | cut -d '-' -f 1)" >> $GITHUB_ENV + - name: Test env var NEW_VERSION + run: echo $NEW_VERSION + + - name: Set env var RELEASE_BRANCH + run: echo "RELEASE_BRANCH="${${{ env.NEW_VERSION }}/%.0/.x}"" >> $GITHUB_ENV + - name: Test env var RELEASE_BRANCH + run: echo $RELEASE_BRANCH + + - 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 main + + - 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: | + git remote --verbose + scripts/release/create_minor_release_PR_commit.sh ${{ env. RELEASE_BRANCH }} diff --git a/scripts/release/create_minor_release_PR_commit.sh b/scripts/release/create_minor_release_PR_commit.sh index f33ab479fc3..1f9c45d7c64 100755 --- a/scripts/release/create_minor_release_PR_commit.sh +++ b/scripts/release/create_minor_release_PR_commit.sh @@ -2,11 +2,10 @@ 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 +16,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 +30,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 +37,21 @@ 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/$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" +BASE_BRANCH="$1" +RELEASE_PR_BRANCH="$RELEASE_PR_BRANCH-to-$BASE_BRANCH" + +echo "final BASE_BRANCH is $BASE_BRANCH" +echo "RELEASE_PR_BRANCH is $RELEASE_PR_BRANCH" -echo "---- Creating release branch $RELEASE_PR_BRANCH from $RELEASE_BRANCH, on the fork ----" +echo "---- Creating release branch $RELEASE_PR_BRANCH from $BASE_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/"$BASE_BRANCH" git branch git pull && git diff HEAD @@ -129,6 +132,15 @@ done cd .. + +if [[ "$BASE_BRANCH" = "main" ]]; 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 diff --git a/scripts/release/create_minor_release_branch.sh b/scripts/release/create_minor_release_branch.sh index 3945943395d..881ca96e475 100755 --- a/scripts/release/create_minor_release_branch.sh +++ b/scripts/release/create_minor_release_branch.sh @@ -2,11 +2,9 @@ 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 ----" @@ -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"