From 6cc0cd8a5f8ad76dba9ad03bf5cfa547369a2708 Mon Sep 17 00:00:00 2001 From: Vlada Anicic Date: Mon, 2 Dec 2024 13:43:24 +0100 Subject: [PATCH 1/4] Add workflow dispatch for release workflow --- .../{tag-release.yml => release.yml} | 45 +++++++++++++++++-- 1 file changed, 42 insertions(+), 3 deletions(-) rename .github/workflows/{tag-release.yml => release.yml} (64%) diff --git a/.github/workflows/tag-release.yml b/.github/workflows/release.yml similarity index 64% rename from .github/workflows/tag-release.yml rename to .github/workflows/release.yml index 6a570e7b..3539dad7 100644 --- a/.github/workflows/tag-release.yml +++ b/.github/workflows/release.yml @@ -1,17 +1,56 @@ -name: Tag Release Version +name: Release Workflow + on: + workflow_dispatch: + inputs: + version: + description: 'Version to release' + required: true pull_request: branches: - main - '[0-9]+.[0-9]+.x' types: [closed] - workflow_dispatch: env: COMMIT_EMAIL: sara-tagger@users.noreply.github.com DEFAULT_PYTHON_VERSION: "3.10" + GITHUB_TOKEN: ${{ secrets.RASASDK_GITHUB_TOKEN }} jobs: + prepare-the-release: + if: ${{ github.event_name == 'workflow_dispatch' }} + runs-on: ubuntu-22.04 + steps: + - name: Checkout repository + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + with: + fetch-depth: 0 + ref: main + + - 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" + git checkout -b prepare-release-${{ github.event.inputs.version }} + 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-${{ github.event.inputs.version }} + target_branch: main + body: "**Automated pull request for Rasa SDK release.**" + title: Release ${{ github.event.inputs.version }} + if_merged_tag_release: name: Tag Release Version if: startsWith(github.head_ref, 'prepare-release-') && github.event.pull_request.merged == true @@ -39,7 +78,7 @@ jobs: - name: Load Poetry Cached Libraries ⬇ id: cache-poetry - uses: actions/cache@13aacd865c20de90d75de3b17ebe84f7a17d57d2 #v4.0.0 + uses: actions/cache@13aacd865c20de90d75de3b17ebe84f7a17d57d2 # v4.0.0 with: path: .venv key: ${{ runner.os }}-poetry-${{ env.POETRY_VERSION }}-${{ env.DEFAULT_PYTHON_VERSION }}-${{ hashFiles('**/poetry.lock') }}-${{ secrets.POETRY_CACHE_VERSION }} From 12e5a2b449ee047b4324a1b33de96fcedf9da6f1 Mon Sep 17 00:00:00 2001 From: Vlada Anicic Date: Mon, 2 Dec 2024 13:46:51 +0100 Subject: [PATCH 2/4] Add job name --- .github/workflows/release.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 3539dad7..536f47cb 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -19,6 +19,7 @@ env: jobs: prepare-the-release: + name: Prepare the Release if: ${{ github.event_name == 'workflow_dispatch' }} runs-on: ubuntu-22.04 steps: From 3d21c7cbad77bf7dba7591ede876879d1ac240a7 Mon Sep 17 00:00:00 2001 From: Vlada Anicic Date: Mon, 2 Dec 2024 14:16:08 +0100 Subject: [PATCH 3/4] Fix Semgrep error --- .github/workflows/release.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 536f47cb..c915d3a5 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -38,7 +38,7 @@ jobs: run: | git config user.name "rasabot" git config user.email "rasabot@rasa.com" - git checkout -b prepare-release-${{ github.event.inputs.version }} + 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,10 +47,12 @@ jobs: uses: devops-infra/action-pull-request@e66e2ba93519dc63b9884a26e620e2fd0cffab2c # v0.5.5 with: github_token: ${{ env.GITHUB_TOKEN }} - source_branch: prepare-release-${{ github.event.inputs.version }} + source_branch: prepare-release-${{ env.VERSION }} target_branch: main body: "**Automated pull request for Rasa SDK release.**" title: Release ${{ github.event.inputs.version }} + env: + INPUT_VERSION: ${{ github.event.inputs.version }} if_merged_tag_release: name: Tag Release Version From e7941d7b7e1cc42d25163388416414add7f99eea Mon Sep 17 00:00:00 2001 From: Vlada Anicic Date: Mon, 2 Dec 2024 14:23:51 +0100 Subject: [PATCH 4/4] Add setup pythion env gha --- .github/actions/setup-python-env/action.yml | 49 +++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 .github/actions/setup-python-env/action.yml diff --git a/.github/actions/setup-python-env/action.yml b/.github/actions/setup-python-env/action.yml new file mode 100644 index 00000000..51ff68c5 --- /dev/null +++ b/.github/actions/setup-python-env/action.yml @@ -0,0 +1,49 @@ +name: Setup Python Environment +description: Encapsulates steps for Testing + +inputs: + PYTHON_VERSION: + description: 'Default Python Version' + required: true + +runs: + using: 'composite' + steps: + - name: Set up Python ${{ inputs.PYTHON_VERSION }} 🐍 + id: setup-python + uses: actions/setup-python@0a5c61591373683505ea898e09a3ea4f39ef2b9c # v5.0.0 + with: + python-version: ${{ inputs.PYTHON_VERSION }} + + - name: Read Poetry Version 🔢 + run: | + echo "POETRY_VERSION=$(scripts/poetry-version.sh)" >> $GITHUB_ENV + shell: bash + + # Install & configure poetry + - name: Install Poetry ${{ env.POETRY_VERSION }} + uses: snok/install-poetry@93ada01c735cc8a383ce0ce2ae205a21c415379b # v1.3.4 + with: + version: ${{ env.POETRY_VERSION }} + virtualenvs-create: true + virtualenvs-in-project: true + installer-parallel: true + + # Load cached venv if cache exists + - name: Load cached venv + id: cached-poetry-dependencies + uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2 + with: + path: .venv + key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }} + + - name: Install Dependencies (Linux) 📦 + run: | + make install + shell: bash + + - name: Activate virtualenv + run: | + . .venv/bin/activate + echo PATH=$PATH >> $GITHUB_ENV + shell: bash \ No newline at end of file