From 7ce71a7801a15da5f7a0037cf266eb27277bc996 Mon Sep 17 00:00:00 2001 From: Vlada Anicic Date: Mon, 2 Dec 2024 15:49:48 +0100 Subject: [PATCH 1/2] Add minor release detection --- .github/workflows/release.yml | 52 +++++++++++++++++++++++++++++++++-- 1 file changed, 49 insertions(+), 3 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index c915d3a5..79613cb8 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -28,6 +28,53 @@ jobs: with: fetch-depth: 0 ref: main + + - name: Minor Release Check + id: minor_release + run: | + version="$INPUT_VERSION" + + # Check if version is in format number.number.number + if ! [[ $version =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then + echo "Invalid version format. It should be in format 'number.number.number'." + exit 1 + fi + + # Extract the third number + IFS='.' read -r -a version_parts <<< "$version" + third_number="${version_parts[2]}" + + # Check if it's a minor release + if [ "$third_number" -eq 0 ]; then + echo "Minor release detected." + echo "is_minor=true" >> $GITHUB_ENV + else + echo "Not a minor release. Skipping branch creation." + echo "is_minor=false" >> $GITHUB_ENV + fi + + - name: Create and Push New Release Branch + if: env.is_minor == 'true' + run: | + version="$INPUT_VERSION" + IFS='.' read -r -a version_parts <<< "$version" + release_branch="${version_parts[0]}.${version_parts[1]}.x" + + git fetch origin + git checkout origin/main + git checkout -b $release_branch + git push origin $release_branch + + - name: Check-out Release Branch + run: | + version="$INPUT_VERSION" + IFS='.' read -r -a version_parts <<< "$version" + release_branch="${version_parts[0]}.${version_parts[1]}.x" + echo "base_branch=${version_parts[0]}.${version_parts[1]}.x" >> $GITHUB_ENV + echo $base_branch + + git checkout $release_branch + git branch - name: Setup Python Environment uses: ./.github/actions/setup-python-env @@ -38,7 +85,6 @@ jobs: run: | git config user.name "rasabot" git config user.email "rasabot@rasa.com" - git checkout -b prepare-release-$INPUT_VERSION poetry run python scripts/release.py --next_version $INPUT_VERSION env: INPUT_VERSION: ${{ github.event.inputs.version }} @@ -47,8 +93,8 @@ jobs: uses: devops-infra/action-pull-request@e66e2ba93519dc63b9884a26e620e2fd0cffab2c # v0.5.5 with: github_token: ${{ env.GITHUB_TOKEN }} - source_branch: prepare-release-${{ env.VERSION }} - target_branch: main + source_branch: prepare-release-${{ env.INPUT_VERSION }} + target_branch: ${{ env.base_branch }} body: "**Automated pull request for Rasa SDK release.**" title: Release ${{ github.event.inputs.version }} env: From d7aa42aa22911a6d5f0e42db697eaf1a219a80b1 Mon Sep 17 00:00:00 2001 From: Vlada Anicic Date: Mon, 2 Dec 2024 15:51:48 +0100 Subject: [PATCH 2/2] Remove hardcoded ref --- .github/workflows/release.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 79613cb8..9721666c 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -27,7 +27,6 @@ jobs: uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 with: fetch-depth: 0 - ref: main - name: Minor Release Check id: minor_release