diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index c915d3a5..9721666c 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -27,7 +27,53 @@ jobs: uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 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 +84,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 +92,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: