Nightly Builds #389
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 [email protected] | |
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 }}" | |