-
Notifications
You must be signed in to change notification settings - Fork 234
163 lines (136 loc) · 5.99 KB
/
release-artifacts.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
name: Release artifacts
on:
push:
tags:
- "*"
workflow_dispatch:
jobs:
build_docker_image_set_env:
name: Prepare environment for Docker build
runs-on: ubuntu-22.04
if: github.repository == 'RasaHQ/rasa-sdk'
outputs:
# Tag name used for intermediate images created during Docker image builds, e.g. 3886 - a PR number
image_tag: ${{ steps.set_output.outputs.image_tag }}
# Return 'true' if tag version is equal or higher than the latest tagged rasa-sdk version
is_newest_version: ${{ steps.rasa_sdk_get_version.outputs.is_newest_version }}
steps:
- name: Checkout git repository 🕝
uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3
# Set environment variables for a tag
#
# In this scenario, we've pushed the '2.4.1' tag
#
# Example output:
# IMAGE_TAG=2.4.1
- name: Set image_tag
run: |
TAG_NAME=${GITHUB_REF#refs/tags/}
echo "IMAGE_TAG=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
echo "image_tag=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
- name: Set is_newest_version
id: rasa_sdk_get_version
run: |
# Get latest tagged rasa-sdk version
git fetch --depth=1 origin "+refs/tags/*:refs/tags/*"
# Fetch branch history
git fetch --prune --unshallow
LATEST_TAGGED_NON_ALPHA_RASA_SDK_VERSION=$(git tag | sort -r -V | grep -E "^[0-9.]+$" | head -n1)
CURRENT_TAG=${GITHUB_REF#refs/tags/}
# Return 'true' if tag version is equal or higher than the latest tagged rasa-sdk version
IS_NEWEST_VERSION=$((printf '%s\n%s\n' "${LATEST_TAGGED_NON_ALPHA_RASA_SDK_VERSION}" "$CURRENT_TAG" \
| sort -V -C && echo true || echo false) || true)
if [[ "${IS_NEWEST_VERSION}" == "true" && "$CURRENT_TAG" =~ ^[0-9.]+$ ]]; then
echo "is_newest_version=true" >> $GITHUB_OUTPUT
else
echo "is_newest_version=false" >> $GITHUB_OUTPUT
fi
build_docker_image:
name: Build Docker image
runs-on: ubuntu-22.04
needs: [ build_docker_image_set_env ]
if: github.repository == 'RasaHQ/rasa-sdk'
steps:
- name: Checkout git repository 🕝
uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3
- name: Set up QEMU
uses: docker/setup-qemu-action@68827325e0b33c7199eb31dd4e31fbe9023e06e3 # v3.0.0
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@0d103c3126aa41d772a8362f6aa67afac040f80c # v3.1.0
- name: Set environment variables
run: |
echo "IMAGE_TAG=${{ needs.build_docker_image_set_env.outputs.image_tag }}" >> $GITHUB_ENV
echo "TAG=${GITHUB_REF#refs/tags/}"
- name: Login to Docker Hub Registry 🔢
run: echo ${{ secrets.DOCKER_HUB_PASSWORD }} | docker login -u ${{ secrets.DOCKER_HUB_USERNAME }} --password-stdin || true
- name: Build and Push Docker image 📦
run: |
IS_NEWEST_VERSION=${{ needs.build_docker_image_set_env.outputs.is_newest_version }}
# Push image
IMAGE_NAME=rasa/rasa-sdk \
IMAGE_TAG=${GITHUB_REF#refs/tags/} \
make build-and-push-multi-platform-docker
# Tag the image as latest
if [[ "${IS_NEWEST_VERSION}" == "true" ]]; then
IMAGE_TAG=latest \
make build-and-push-multi-platform-docker
fi
deploy:
name: Deploy to PyPI
runs-on: ubuntu-22.04
# deploy will only be run when there is a tag available
needs: [ build_docker_image ] # only run after all other stages succeeded
steps:
- name: Checkout git repository 🕝
uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3
- name: Set up Python 3.10 🐍
uses: actions/setup-python@d27e3f3d7c64b4bbf8e4abfb9b63b83e846e0435
with:
python-version: '3.10'
- name: Read Poetry Version 🔢
run: |
echo "POETRY_VERSION=$(scripts/poetry-version.sh)" >> $GITHUB_ENV
shell: bash
- name: Install poetry 🦄
uses: Gr1N/setup-poetry@15821dc8a61bc630db542ae4baf6a7c19a994844
with:
poetry-version: ${{ env.POETRY_VERSION }}
- name: Build ⚒️ Distributions
run: poetry build
- name: Publish to PyPI 📦
uses: pypa/gh-action-pypi-publish@bea5cda687c2b79989126d589ef4411bedce0195
with:
user: __token__
password: ${{ secrets.PYPI_TOKEN }}
skip_existing: true
- name: Publish Release Notes 🗞
if: env.IS_TAG_BUILD
env:
GITHUB_TAG: ${{ github.ref }}
GITHUB_REPO_SLUG: ${{ github.repository }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
GITHUB_TAG=${GITHUB_TAG/refs\/tags\//}
sudo apt-get update
sudo apt-get -y install pandoc
pip install -U github3.py pep440_version_utils
python3 ${GITHUB_WORKSPACE}/scripts/publish_gh_release_notes.py
- name: Get RASA SDK Version
env:
RASA_SDK_VERSION: ${{ github.ref }}
run: |
echo "RASA_SDK_VERSION=${RASA_SDK_VERSION/refs\/tags\//}" >> $GITHUB_ENV
- name: Notify Slack 💬
if: env.IS_TAG_BUILD && success()
env:
SLACK_WEBHOOK: ${{ secrets.SLACK_RELEASE_ASSISTANT_RELEASE_WEBHOOK }}
uses: Ilshidur/[email protected]
with:
args: "⚡ New *Rasa SDK* version ${{ env.RASA_SDK_VERSION }} has been released! Changelog: https://github.com/RasaHQ/rasa-sdk/blob/${{ env.RASA_SDK_VERSION }}/CHANGELOG.mdx"
- name: Notify Slack of Failure ⛔
if: env.IS_TAG_BUILD && failure()
env:
SLACK_WEBHOOK: ${{ secrets.SLACK_RELEASE_ASSISTANT_DEV_TRIBE_WEBHOOK }}
uses: Ilshidur/[email protected]
with:
args: "⛔️ *Rasa SDK* version ${{ env.RASA_SDK_VERSION }} could not be released 😱 GitHub Actions: https://github.com/RasaHQ/rasa-sdk/actions?query=branch%3A${{ env.RASA_SDK_VERSION }}"