Skip to content

Commit

Permalink
Merge pull request #1152 from RasaHQ/INFRA-1118-release-workflow-auto…
Browse files Browse the repository at this point in the history
…mation

[INFRA-1118] Add workflow dispatch for release workflow
  • Loading branch information
rasa-aadlv authored Dec 2, 2024
2 parents fe817e7 + e7941d7 commit f1e8b13
Show file tree
Hide file tree
Showing 2 changed files with 94 additions and 3 deletions.
49 changes: 49 additions & 0 deletions .github/actions/setup-python-env/action.yml
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -1,17 +1,59 @@
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: [email protected]
DEFAULT_PYTHON_VERSION: "3.10"
GITHUB_TOKEN: ${{ secrets.RASASDK_GITHUB_TOKEN }}

jobs:
prepare-the-release:
name: 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 "[email protected]"
git checkout -b prepare-release-$INPUT_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-${{ 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
if: startsWith(github.head_ref, 'prepare-release-') && github.event.pull_request.merged == true
Expand Down Expand Up @@ -39,7 +81,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 }}
Expand Down

0 comments on commit f1e8b13

Please sign in to comment.