forked from RasaHQ/rasa
-
Notifications
You must be signed in to change notification settings - Fork 0
198 lines (162 loc) 路 7.61 KB
/
nightly_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
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
name: Nightly Builds
on:
schedule:
# Runs every weekday at 1am
- cron: 0 1 * * 1-5
workflow_dispatch:
jobs:
run_script_and_tag_nightly_release:
name: Run release script and tag a new nightly release
runs-on: ubuntu-22.04
outputs:
tag_name: ${{ steps.set_tagname.outputs.tag_name }}
steps:
- name: Checkout git repository 馃暆
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Python ${{ env.DEFAULT_PYTHON_VERSION }} 馃悕
uses: actions/setup-python@57ded4d7d5e986d7296eab16560982c6dd7c923b
with:
python-version: ${{ env.DEFAULT_PYTHON_VERSION }}
- name: Compose tag name
id: set_tagname
run: |
DATE=$(date +'%Y%m%d')
# Find latest rasa-oss version
echo "Trying to find the latest rasa-oss version..."
pip install toml
LATEST_RASA_MINOR=$(python scripts/get_version_from_toml.py)
echo "Current RASA version: ${LATEST_RASA_MINOR}"
LATEST_NIGHTLY_VERSION=$(echo ${LATEST_RASA_MINOR})
echo "Composing nightly build tag name..."
GH_TAG=${LATEST_NIGHTLY_VERSION}.dev${DATE}
echo "New nightly release version: ${GH_TAG}"
echo "tag_name=${GH_TAG}" >> $GITHUB_OUTPUT
- name: Tag latest main commit as nightly
run: |
git config user.name github-actions
git config user.email github-actions@github.com
git tag -a ${{ steps.set_tagname.outputs.tag_name }} -m "This is an internal development build"
git push origin ${{ steps.set_tagname.outputs.tag_name }} --tags
deploy:
name: Deploy to PyPI
runs-on: ubuntu-22.04
# deploy will only be run when there is a tag available
needs: run_script_and_tag_nightly_release # only run after all other stages succeeded
steps:
- name: Checkout git repository 馃暆
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c
- name: Set up Python ${{ env.DEFAULT_PYTHON_VERSION }} 馃悕
uses: actions/setup-python@57ded4d7d5e986d7296eab16560982c6dd7c923b
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: Copy Segment write key to the package
env:
RASA_TELEMETRY_WRITE_KEY: ${{ secrets.RASA_OSS_TELEMETRY_WRITE_KEY }}
RASA_EXCEPTION_WRITE_KEY: ${{ secrets.RASA_OSS_EXCEPTION_WRITE_KEY }}
run: |
./scripts/write_keys_file.sh
- name: Update version (nightly releases) 馃殌
run: |
poetry run pip install toml pep440_version_utils
poetry run python ./scripts/prepare_nightly_release.py --next_version "${{ needs.run_script_and_tag_nightly_release.outputs.tag_name }}"
- name: Build 鈿掞笍 Distributions
run: |
poetry build
# Authenticate and push to the release registry
- id: 'auth-release'
name: Authenticate with gcloud for release registry 馃帿
uses: 'google-github-actions/auth@e8df18b60c5dd38ba618c121b779307266153fbf'
with:
credentials_json: '${{ secrets.RASA_OSS_RELEASE_ACCOUNT_KEY }}'
- name: 'Set up Cloud SDK'
uses: 'google-github-actions/setup-gcloud@62d4898025f6041e16b1068643bfc5a696863587'
- name: Release via GCP Artifact Registry
run: |
pip install keyring
pip install keyrings.google-artifactregistry-auth
pip install twine
gcloud artifacts print-settings python --project=rasa-releases --repository=rasa --location=europe-west3 > ~/.pypirc
twine upload --verbose --repository-url https://europe-west3-python.pkg.dev/rasa-releases/rasa/ ${{ format('{0}/dist/*', github.workspace) }}
docker:
name: Build Docker
runs-on: ubuntu-22.04
needs: run_script_and_tag_nightly_release
env:
GCLOUD_VERSION: "297.0.1"
# Registry used to store Docker images used for release purposes
DEV_REGISTRY: "europe-west3-docker.pkg.dev/rasa-ci-cd/rasa"
IMAGE_TAG: ${{ needs.run_script_and_tag_nightly_release.outputs.tag_name }}
steps:
- name: Checkout git repository 馃暆
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c
- name: Free disk space
# tries to make sure we do not run out of disk space, see
# https://github.community/t5/GitHub-Actions/BUG-Strange-quot-No-space-left-on-device-quot-IOExceptions-on/td-p/46101
run: |
sudo swapoff -a
sudo rm -f /swapfile
sudo apt clean
docker rmi $(docker image ls -aq)
df -h
- name: Read Poetry Version 馃敘
run: |
echo "POETRY_VERSION=$(scripts/poetry-version.sh)" >> $GITHUB_ENV
shell: bash
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@885d1462b80bc1c1c7f0b00334ad271f09369c55
id: buildx
with:
version: v0.5.1
driver: docker
- name: Copy Segment write key to the package
env:
RASA_TELEMETRY_WRITE_KEY: ${{ secrets.RASA_OSS_TELEMETRY_WRITE_KEY }}
RASA_EXCEPTION_WRITE_KEY: ${{ secrets.RASA_OSS_EXCEPTION_WRITE_KEY }}
run: |
./scripts/write_keys_file.sh
- name: Build Docker image
run: |
docker build . -t rasa/rasa:base-localdev -f docker/Dockerfile.base
docker build . -t rasa/rasa:base-builder-localdev -f docker/Dockerfile.base-builder --build-arg IMAGE_BASE_NAME=rasa/rasa --build-arg POETRY_VERSION=${{ env.POETRY_VERSION }}
docker build . -t rasa/rasa:base-poetry -f docker/Dockerfile.base-poetry --build-arg IMAGE_BASE_NAME=rasa/rasa --build-arg BASE_IMAGE_HASH=localdev
docker build . -t rasa/rasa:${IMAGE_TAG} -f Dockerfile --build-arg IMAGE_BASE_NAME=rasa/rasa --build-arg BASE_IMAGE_HASH=localdev --build-arg BASE_BUILDER_IMAGE_HASH=localdev
docker tag rasa/rasa:${IMAGE_TAG} ${{env.DEV_REGISTRY}}/rasa:${IMAGE_TAG}
# Authenticate and push to the release registry
- id: 'auth-dev'
name: Authenticate with gcloud for dev registry 馃帿
uses: 'google-github-actions/auth@e8df18b60c5dd38ba618c121b779307266153fbf'
with:
credentials_json: '${{ secrets.RASA_OSS_RELEASE_ACCOUNT_KEY }}'
- name: Authenticate docker for dev registry 馃帿
run: |
# Set up docker to authenticate via gcloud command-line tool.
gcloud auth configure-docker europe-west3-docker.pkg.dev
- name: Push image to release registry
run: |
docker push ${{env.DEV_REGISTRY}}/rasa:${IMAGE_TAG}
send_slack_notification_on_failure:
name: Notify Slack
runs-on: ubuntu-22.04
if: always()
needs:
- docker
- deploy
steps:
- name: Notify Slack of failure 鉀旓笍
# send notification if 'deploy' or 'docker' is skipped (previous needed job failed) or failed
if: needs.docker.result != 'success' || needs.deploy.result != 'success'
env:
SLACK_WEBHOOK: ${{ secrets.SLACK_RELEASE_ASSISTANT_ATOM_ALERTS_WEBHOOK }}
uses: Ilshidur/action-slack@689ad44a9c9092315abd286d0e3a9a74d31ab78a
with:
args: "鉀旓笍 *Rasa nightly release* failed 馃槺! Please check out GitHub Actions: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}"