Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add GitHub workflow files #7585

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions .github/workflows/minor_release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
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: 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: |
git remote --verbose
scripts/release/create_minor_release_PR_commit.sh
36 changes: 27 additions & 9 deletions scripts/release/create_minor_release_PR_commit.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 ----"

Expand All @@ -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 ./*
Expand All @@ -29,26 +30,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/$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
Copy link
Member

@akuzm akuzm Jan 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So this script can also create the release branch? I think that for ease of understanding, we should choose one of these options:

  1. make this script create the branch if it doesn't exist, and remove the small script that only handles branch creation
  2. keep the small script for branch creation, but remove it from this one, and make it require the branch to be already created.

I think if the branch can be created by two different scripts, it might become confusing, especially since they can diverge subtly.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This script does not create the release branch. It checks if the release branch is created.

If release-branch exists:

  • it creates Release PR on the release-branch, adjusting versions.

If release-branch does not exist:

  • it creates Changelog+post-release PR on main branch, adjusting versions accordingly.

i.e. overall through this action, we want to create 2 PRs & 1 release-branch, for each minor release.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, I think I understand. Can we make this depend on the argument instead? I.e. if you pass it "main" as an argument, it creates the PR to main branch, and if you pass the name of the release branch, it creates a PR to there. This will make it easier to retry any of the steps, i.e. if the release branch was created, but the PR to main failed for some reason, and we need to create it again.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if [[ $RELEASE_BRANCH_EXISTS == '0' ]]; then
if [[ $RELEASE_BRANCH_EXISTS -eq 0 ]]; then

Nit.

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-to-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 +138,15 @@ done

cd ..


if [[ $RELEASE_BRANCH_EXISTS == '0' ]]; then
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if [[ $RELEASE_BRANCH_EXISTS == '0' ]]; then
if [[ $RELEASE_BRANCH_EXISTS -eq 0 ]]; then

Nit.

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
10 changes: 4 additions & 6 deletions scripts/release/create_minor_release_branch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 ----"

Expand All @@ -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"

Loading