Refactor EDAEngine to use ModelContext. #511
This file contains hidden or 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" | |
| BUILD_ARTIFACT_NAME: "meridian-core-package-distribution" | |
| PYPI_PACKAGE_NAME: "google-meridian" | |
| 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 }} | |
| artifact_name: ${{ env.BUILD_ARTIFACT_NAME }} | |
| # 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 | |
| - uses: ./.github/actions/install-meridian | |
| with: | |
| python_version: ${{ inputs.python_version }} | |
| extras: '' | |
| - id: get_version | |
| shell: bash | |
| run: | | |
| VERSION=$(python -c "import meridian; print(meridian.__version__)") | |
| echo "value=$VERSION" >> $GITHUB_OUTPUT | |
| - id: version_check | |
| uses: ./.github/actions/version-check | |
| with: | |
| python_version: ${{ env.USE_PYTHON_VERSION }} | |
| semver_prefix: v | |
| current_version: ${{ steps.get_version.outputs.value }} | |
| create-tag: | |
| needs: check-version | |
| # Only run if new_version was discovered, and do this only on the main branch. | |
| if: > | |
| github.ref == 'refs/heads/main' | |
| && 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: v${{ 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') | |
| || (github.event_name == 'push' && github.ref == 'refs/heads/main' | |
| && needs.check-version.outputs.new_version != '') | |
| ) | |
| runs-on: ubuntu-latest | |
| environment: | |
| name: pypi | |
| url: https://pypi.org/p/${{ env.PYPI_PACKAGE_NAME }} | |
| permissions: | |
| id-token: write # IMPORTANT: mandatory for trusted publishing | |
| steps: | |
| - name: Download all the dists | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: ${{ env.BUILD_ARTIFACT_NAME }} | |
| path: dist/ | |
| - name: Publish distribution to PyPI | |
| uses: pypa/gh-action-pypi-publish@release/v1 | |
| with: | |
| verbose: true | |
| publish-to-testpypi: | |
| name: Publish Python distribution to TestPyPI | |
| needs: | |
| - build | |
| - check-version | |
| # Check if the `publish_to_testpypi` workflow is selected in a manual trigger. | |
| if: > | |
| github.repository == 'google/meridian' && ( | |
| (github.event_name == 'workflow_dispatch' | |
| && github.event.inputs.publish_to_testpypi == 'true') | |
| ) | |
| runs-on: ubuntu-latest | |
| environment: | |
| name: testpypi | |
| url: https://test.pypi.org/p/${{ env.PYPI_PACKAGE_NAME }} | |
| permissions: | |
| id-token: write # IMPORTANT: mandatory for trusted publishing | |
| steps: | |
| - name: Download all the dists | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: ${{ env.BUILD_ARTIFACT_NAME }} | |
| path: dist/ | |
| - name: Publish distribution to TestPyPI | |
| uses: pypa/gh-action-pypi-publish@release/v1 | |
| with: | |
| repository-url: https://test.pypi.org/legacy/ | |
| verbose: true |