-
Notifications
You must be signed in to change notification settings - Fork 232
179 lines (152 loc) · 6.29 KB
/
release.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
name: Release Workflow
on:
workflow_dispatch:
inputs:
version:
description: 'Version to release'
required: true
fromMain:
description: 'Release from main'
type: boolean
required: true
default: false
pull_request:
branches:
- main
- '[0-9]+.[0-9]+.x'
types: [closed]
env:
COMMIT_EMAIL: [email protected]
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:
name: Prepare the 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: Dev or RC Release - Check if this is DEV or RC release
id: dev_or_rc_check
run: |
version="$INPUT_VERSION"
# 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 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
echo "Not a minor release. Skipping branch creation."
echo "is_minor=false" >> $GITHUB_ENV
fi
- 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"
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 .x branch
if: env.RELEASE_FOM_MAIN == 'false'
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: Check-out main branch
if: env.RELEASE_FOM_MAIN == 'true'
run: |
git checkout main
echo "base_branch=main" >> $GITHUB_ENV
echo $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 "[email protected]"
poetry run python scripts/release.py --next_version $INPUT_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 }}
if_merged_tag_release:
name: Tag Release Version
if: startsWith(github.head_ref, 'prepare-release-') && github.event.pull_request.merged == true
runs-on: ubuntu-24.04
steps:
- name: Checkout git repository 🕝
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
with:
token: ${{ secrets.RELEASE_TAGGER_PAT }}
- name: Set up Python ${{ env.DEFAULT_PYTHON_VERSION }} 🐍
uses: actions/setup-python@0a5c61591373683505ea898e09a3ea4f39ef2b9c # v5.0.0
with:
python-version: ${{ env.DEFAULT_PYTHON_VERSION }}
- name: Read Poetry Version 🔢
run: |
echo "POETRY_VERSION=$(scripts/poetry-version.sh)" >> $GITHUB_ENV
shell: bash
- name: Install poetry 🦄
uses: Gr1N/setup-poetry@15821dc8a61bc630db542ae4baf6a7c19a994844 # v8
with:
poetry-version: ${{ env.POETRY_VERSION }}
- name: Load Poetry Cached Libraries ⬇
id: cache-poetry
uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.0.0
with:
path: .venv
key: ${{ runner.os }}-poetry-${{ env.POETRY_VERSION }}-${{ env.DEFAULT_PYTHON_VERSION }}-${{ hashFiles('**/poetry.lock') }}-${{ secrets.POETRY_CACHE_VERSION }}
restore-keys: ${{ runner.os }}-poetry-${{ env.DEFAULT_PYTHON_VERSION }}
- name: Clear Poetry cache
if: steps.cache-poetry.outputs.cache-hit == 'true' && contains(github.event.pull_request.labels.*.name, 'tools:clear-poetry-cache-unit-tests')
run: rm -r .venv
- name: Create virtual environment
if: steps.cache-poetry.outputs.cache-hit != 'true' || contains(github.event.pull_request.labels.*.name, 'tools:clear-poetry-cache-unit-tests')
run: python -m venv create .venv
- name: Set up virtual environment
run: poetry config virtualenvs.in-project true
- name: Install Dependencies 📦
# Poetry intermittently fails to install dependency if it is not PEP 517 compliant
# This is a workaround for that issue
run: |
sudo apt-get -y install libpq-dev
make install
- name: Configure git
run: |
git config --global user.email ${{ env.COMMIT_EMAIL }}
git config --global user.name "Github Actions"
- name: Tag Release
run: make tag-release