Release #34
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: release | |
run-name: Release | |
on: | |
release: | |
types: [released] | |
workflow_call: | |
inputs: | |
release_id: | |
type: string | |
description: "The id of the release" | |
required: false | |
release_tag: | |
type: string | |
description: "The tag of the release" | |
required: false | |
is_draft: | |
type: boolean | |
description: "Is the release a draft" | |
required: false | |
env: | |
release_id: ${{ inputs.release_id || github.event.release.id }} | |
release_tag: ${{ inputs.release_tag || github.event.release.tag_name }} | |
is_draft: ${{ inputs.is_draft || github.event.release.draft }} | |
is_scheduled: ${{ github.event_name == 'schedule' }} | |
jobs: | |
validate_tag: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
ref: ${{ github.ref }} | |
- name: Fail early if tag schema is invalid | |
run: | | |
if [[ ! ${{ env.release_tag }} =~ ^refs/tags/(v[0-9]+\.[0-9]+\.[0-9]+)$ && ${{ env.release_tag }} =~ ^refs/tags/test-.*$ ]]; then | |
echo "Tag ${{ env.release_tag }} is not a valid semver tag" | |
exit 1 | |
fi | |
run_tests: | |
needs: validate_tag | |
uses: ./.github/workflows/JOB_tests.yml | |
release: | |
needs: [run_tests] | |
if: startsWith(github.ref, 'refs/tags/v') | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
ref: ${{ github.ref }} | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: "3.9" | |
- run: pip install pip --upgrade | |
- name: Setup Poetry | |
uses: abatilo/actions-poetry@v2 | |
with: | |
poetry-version: "1.3.1" | |
- name: Publish on pypi.org | |
env: | |
POETRY_HTTP_BASIC_PYPI_USERNAME: ${{ secrets.PYPI_USERNAME }} | |
POETRY_HTTP_BASIC_PYPI_PASSWORD: ${{ secrets.PYPI_PASSWORD }} | |
run: | | |
poetry publish --build | |
test_release: | |
needs: [run_tests] | |
if: startsWith(github.ref, 'refs/tags/test-') | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
ref: ${{ github.ref }} | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: "3.9" | |
- run: pip install pip --upgrade | |
- name: Setup Poetry | |
uses: abatilo/actions-poetry@v2 | |
with: | |
poetry-version: "1.3.1" | |
- name: Check secrets are set | |
run: | | |
if [[ -z "${{ secrets.TEST_PYPI_USERNAME }}" || -z "${{ secrets.TEST_PYPI_PASSWORD }}" ]]; then | |
echo "TEST_PYPI_USERNAME and TEST_PYPI_PASSWORD must be set" | |
exit 1 | |
fi | |
- name: Publish on test.pypi.org | |
env: | |
POETRY_HTTP_BASIC_PYPI_USERNAME: ${{ secrets.TEST_PYPI_USERNAME }} | |
POETRY_HTTP_BASIC_PYPI_PASSWORD: ${{ secrets.TEST_PYPI_PASSWORD }} | |
run: | | |
python ./deploy/nightly_package_setup.py | |
poetry config repositories.test-pypi https://test.pypi.org/legacy/ | |
poetry config http-basic.test-pypi ${{ secrets.TEST_PYPI_USERNAME }} ${{ secrets.TEST_PYPI_PASSWORD }} | |
poetry publish --build --repository test-pypi | |
python ./deploy/revert_nightly_setup.py | |
# Linear tickets update | |
notify_release: | |
needs: [release] | |
if: success() | |
uses: ./.github/workflows/JOB_slack_message.yml | |
secrets: inherit | |
with: | |
icon: ":rocket:" | |
at_team: true | |
message: | | |
:tada: *${{ inputs.release_tag || github.event.release.tag_name }}* has been released! | |
:link: | |
- https://pypi.org/project/darwin-py | |
- ${{ github.event.release.html_url }} | |
notify_failed_release: | |
needs: [release] | |
if: failure() | |
uses: ./.github/workflows/JOB_slack_message.yml | |
secrets: inherit | |
with: | |
icon: ":warning:" | |
at_team: true | |
message: | | |
:warning: *${{ inputs.release_tag || github.event.release.tag_name }}* Release has failed to be released! | |
*An error occurred performing release, and you may need to release manually.* | |
:link: | |
- ${{ github.event.release.html_url }} |