Prepare release #20
Workflow file for this run
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: Prepare release | |
on: | |
workflow_dispatch: | |
inputs: | |
version: | |
description: "The version to release" | |
required: true | |
concurrency: | |
group: ${{ github.ref }} | |
cancel-in-progress: false | |
env: | |
BRANCH_NAME: ${{ github.ref_name }} | |
BRANCH_IS_MAIN: ${{ github.ref_name == 'main' }} | |
BRANCH_IS_RELEASE: ${{ startsWith(github.ref_name, 'release/') }} | |
jobs: | |
prepare-release: | |
name: Prepare release ${{ github.event.inputs.version }} | |
runs-on: ubuntu-20.04 | |
defaults: | |
run: | |
shell: bash | |
env: | |
VERSION: ${{ github.event.inputs.version }} | |
steps: | |
# Mask internal URLs if logged | |
- name: Add masks | |
id: masks | |
run: | | |
echo "::add-mask::${{ secrets.INTERNAL_PYPI_URL_FOR_MASK }}" | |
echo "::add-mask::${{ secrets.INTERNAL_REPO_URL_FOR_MASK }}" | |
# Make sure that the target branch is: | |
# - main, for release-candidates or major/minor releases | |
# - a release branch, for patch releases | |
# - name: Stop if branch is not main or release | |
# if: ${{ always() && !cancelled() }} | |
# run: | | |
# if [[ "${BRANCH_IS_MAIN}" == "false" && "${BRANCH_IS_RELEASE}" == 'false' ]]; then | |
# echo "Release cannot be done: target branch is not main or a release branch" | |
# echo "Got branch ${BRANCH_NAME}" | |
# exit 1 | |
# fi | |
- name: Checkout Code | |
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c | |
with: | |
ref: ${{ github.ref }} | |
token: ${{ secrets.BOT_TOKEN }} | |
- name: Set up Python 3.8 | |
uses: actions/setup-python@61a6322f88396a6271a6ee3565807d608ecaddd1 | |
with: | |
python-version: '3.8' | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
python -m pip install poetry==1.2.2 | |
make setup_env | |
# Make sure that the workflow has been triggered from a release branch if this is a patch | |
# release or from main otherwise. If not, the release preparation process is stopped | |
# Additionally, for patch releases, if the release branch name does not match the current | |
# release version, the release preparation process is stopped as well | |
- name: Check release preparation is from right branch | |
run: | | |
IS_PATCH="$(poetry run python ./script/make_utils/version_utils.py is_patch_release --version "$PROJECT_VERSION")" | |
if [[ "${IS_PATCH}" == 'true']]; then | |
if [[ "${BRANCH_IS_RELEASE}" == "true" ]]; then | |
echo "Patch release cannot be done: target branch is not a release branch" | |
echo "Got branch ${BRANCH_NAME}" | |
exit 1 | |
elif [[ "${RELEASE_BRANCH_NAME}" != "${BRANCH_NAME}" ]]; then | |
echo "Patch release cannot be done: target branch name does not match the current version" | |
echo "Got branch ${BRANCH_NAME} but for version ${PROJECT_VERSION}" | |
echo "Expected "${RELEASE_BRANCH_NAME}" | |
exit 1 | |
fi | |
elif [[ "${IS_PATCH}" == 'false' && "${BRANCH_IS_MAIN}" == "false" ]]; then | |
echo "Release cannot be done: target branch is not main" | |
echo "Got branch ${BRANCH_NAME}" | |
exit 1 | |
fi | |
- name: Set version | |
run: | | |
make set_version | |
- name: Build apidocs | |
run: | | |
make apidocs | |
# Open a PR with the new version and updated apidocs | |
- name: Open PR | |
uses: peter-evans/create-pull-request@284f54f989303d2699d373481a0cfa13ad5a6666 | |
with: | |
token: ${{ secrets.BOT_TOKEN }} | |
commit-message: "chore: prepare release ${{ env.VERSION }}" | |
branch: "chore/prepare_release_${{ env.VERSION }}" | |
base: "${{ github.ref_name }}" | |
title: "Prepare release ${{ env.VERSION }}" | |
body: "Set version ${{ env.VERSION }} and build apidocs" | |
- name: Slack Notification | |
if: ${{ always() && !success() }} | |
continue-on-error: true | |
uses: rtCamp/action-slack-notify@b24d75fe0e728a4bf9fc42ee217caa686d141ee8 | |
env: | |
SLACK_CHANNEL: ${{ secrets.SLACK_CHANNEL }} | |
SLACK_ICON: https://pbs.twimg.com/profile_images/1274014582265298945/OjBKP9kn_400x400.png | |
SLACK_COLOR: ${{ job.status }} | |
SLACK_MESSAGE: "Preparing release ${{ env.VERSION }} finished with status \ | |
${{ job.status }} (${{ env.ACTION_RUN_URL }})" | |
SLACK_USERNAME: ${{ secrets.BOT_USERNAME }} | |
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }} |