From 90e91629ade80dc82d8e366e17c51d3adc3a3951 Mon Sep 17 00:00:00 2001 From: Vlada Anicic Date: Thu, 26 Dec 2024 12:12:25 +0100 Subject: [PATCH] Support dev and rc releases in release workflow --- .github/workflows/dev-release.yml | 58 ------------------------------- .github/workflows/release.yml | 47 ++++++++++++++++++------- 2 files changed, 34 insertions(+), 71 deletions(-) delete mode 100644 .github/workflows/dev-release.yml diff --git a/.github/workflows/dev-release.yml b/.github/workflows/dev-release.yml deleted file mode 100644 index 41d5ccf8..00000000 --- a/.github/workflows/dev-release.yml +++ /dev/null @@ -1,58 +0,0 @@ -name: DEV Release Workflow - -on: - workflow_dispatch: - inputs: - version: - description: 'Version to release' - required: true - base-branch: - description: 'Base branch' - required: true - -env: - COMMIT_EMAIL: sara-tagger@users.noreply.github.com - DEFAULT_PYTHON_VERSION: "3.10" - GITHUB_TOKEN: ${{ secrets.RASASDK_GITHUB_TOKEN }} - -jobs: - prepare-dev-release: - name: Prepare DEV Release - if: ${{ github.event_name == 'workflow_dispatch' }} - runs-on: ubuntu-24.04 - steps: - - name: Checkout repository - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - with: - fetch-depth: 0 - - - name: Check-out base branch - run: | - git checkout $BASE_BRANCH - git branch - env: - BASE_BRANCH: ${{ github.event.inputs.base-branch }} - - - name: Setup Python Environment - uses: ./.github/actions/setup-python-env - with: - PYTHON_VERSION: ${{ env.DEFAULT_PYTHON_VERSION }} - - - name: Prepare the release - run: | - git config user.name "rasabot" - git config user.email "rasabot@rasa.com" - poetry run python scripts/release.py --next_version $INPUT_VERSION - env: - INPUT_VERSION: ${{ github.event.inputs.version }} - - - name: Create pull request - uses: devops-infra/action-pull-request@e66e2ba93519dc63b9884a26e620e2fd0cffab2c # v0.5.5 - with: - github_token: ${{ env.GITHUB_TOKEN }} - 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: - INPUT_VERSION: ${{ github.event.inputs.version }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 96935bcc..2368ede5 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -6,6 +6,11 @@ on: version: description: 'Version to release' required: true + fromMain: + description: 'Release from main?' + type: boolean + required: true + default: false pull_request: branches: - main @@ -17,6 +22,7 @@ env: DEFAULT_PYTHON_VERSION: "3.10" GITHUB_TOKEN: ${{ secrets.RASASDK_GITHUB_TOKEN }} INPUT_VERSION: ${{ github.event.inputs.version }} + RELEASE_FOM_MAIN: ${{ github.event.inputs.fromMain }} jobs: prepare-the-release: @@ -29,23 +35,32 @@ jobs: with: fetch-depth: 0 - - name: Minor Release Check - id: minor_release + - name: Dev or RC Release - Check if this is DEV or RC release + id: dev_or_rc_check 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 + # Check if version contains 'dev' or 'rc' + if [[ "$version" == *"dev"* || "$version" == *"rc"* ]]; then + echo "Dev or RC release detected." + echo "is_dev=true" >> $GITHUB_ENV + else + echo "Not a Dev or RC release." + echo "is_dev=false" >> $GITHUB_ENV fi - + + - name: Minor Release - Check if this is a minor release + if: env.is_dev == 'false' + id: minor_release + run: | + version="$INPUT_VERSION" + # 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 + + # Check if third number is equivalent to 0 and no trailing chars + if [[ "$third_number" =~ ^0$ ]]; then echo "Minor release detected." echo "is_minor=true" >> $GITHUB_ENV else @@ -53,8 +68,8 @@ jobs: echo "is_minor=false" >> $GITHUB_ENV fi - - name: Create and Push New Release Branch - if: env.is_minor == 'true' + - name: Minor Release - Create and push new minor release branch + if: ${{ env.is_minor == 'true' && env.is_dev == 'false' }} run: | version="$INPUT_VERSION" IFS='.' read -r -a version_parts <<< "$version" @@ -65,7 +80,8 @@ jobs: git checkout -b $release_branch git push origin $release_branch - - name: Check-out Release Branch + - name: Check-out .x branch + if: env.RELEASE_FOM_MAIN == 'false' run: | version="$INPUT_VERSION" IFS='.' read -r -a version_parts <<< "$version" @@ -76,6 +92,11 @@ jobs: git checkout $release_branch git branch + - name: Check-out main branch + if: env.RELEASE_FOM_MAIN == 'true' + run: | + git checkout main + - name: Setup Python Environment uses: ./.github/actions/setup-python-env with: