Publish #14
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: Publish # For tagging and publishing releases. | |
on: | |
push: | |
branches: | |
- main # This entire workflow only runs on a push to the `main` branch (i.e. POST SUBMIT). | |
tags: | |
- 'v*' # Trigger only on pushed tags whose names start with 'v'. | |
workflow_dispatch: # For triggering publication workflows manually, on demend, from GitHub UI. | |
inputs: | |
publish_to_pypi: # Creates a boolean `github.event.inputs.publish_to_pypi` variable. | |
description: 'Publish to PyPI' | |
required: false | |
type: boolean | |
default: false | |
publish_to_testpypi: | |
description: 'Publish to TestPyPI' | |
required: false | |
type: boolean | |
default: false | |
env: | |
USE_PYTHON_VERSION: "3.11" | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
timeout-minutes: 15 | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: ./.github/actions/build | |
with: | |
python_version: ${{ env.USE_PYTHON_VERSION }} | |
# Check if the current `meridian.__version__` semver has been incremented. If so, set a | |
# `new_version` output. | |
check-version: | |
runs-on: ubuntu-latest | |
timeout-minutes: 10 | |
outputs: | |
new_version: ${{ steps.version_check.outputs.new_version }} | |
steps: | |
- uses: actions/checkout@v4 | |
- id: version_check | |
uses: ./.github/actions/version-check | |
with: | |
python_version: ${{ env.USE_PYTHON_VERSION }} | |
create-tag: | |
needs: check-version | |
# Only run if new_version was discovered. | |
if: needs.check-version.outputs.new_version != '' | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write # Allow to create tags | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: ./.github/actions/create-version-tag | |
with: | |
new_version: ${{ needs.check-version.outputs.new_version }} | |
publish-to-pypi: | |
name: Publish Python distribution to PyPI | |
needs: | |
- build | |
- check-version | |
# Check if it's a tag push, or the `publish_to_pypi` workflow is selected in a manual trigger. | |
# or if a new version was discovered in a push to the `main` branch. | |
if: > | |
github.repository == 'google/meridian' && ( | |
(github.ref_type == 'tag' && startsWith(github.ref, 'refs/tags/')) | |
|| (github.event_name == 'workflow_dispatch' | |
&& github.event.inputs.publish_to_pypi == 'true') | |
) | |
runs-on: ubuntu-latest | |
environment: | |
name: pypi | |
url: https://pypi.org/p/google-meridian | |
permissions: | |
id-token: write # IMPORTANT: mandatory for trusted publishing | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: ./.github/actions/publish | |
with: | |
repository_url: https://upload.pypi.org/legacy/ | |
publish-to-testpypi: | |
name: Publish Python distribution to TestPyPI | |
needs: | |
- build | |
- check-version | |
# Check if it's a tag push, or the `publish_to_testpypi` workflow is selected in a manual trigger. | |
# or if a new version was discovered in a push to the `main` branch. | |
if: > | |
github.repository == 'google/meridian' && ( | |
(github.ref_type == 'tag' && startsWith(github.ref, 'refs/tags/')) | |
|| (github.event_name == 'workflow_dispatch' | |
&& github.event.inputs.publish_to_testpypi == 'true') | |
|| needs.check-version.outputs.new_version != '' | |
) | |
runs-on: ubuntu-latest | |
environment: | |
name: testpypi | |
url: https://test.pypi.org/p/google-meridian | |
permissions: | |
id-token: write # IMPORTANT: mandatory for trusted publishing | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: ./.github/actions/publish | |
with: | |
repository_url: https://test.pypi.org/legacy/ |