From 71626f47e6646bcc429cf6a084a9d6ec8f4ae0fe Mon Sep 17 00:00:00 2001 From: tlento Date: Thu, 25 Jul 2024 14:43:40 -0700 Subject: [PATCH] Enable tag-based deployment for dbt-metricflow We need to be able to start deploying dbt-metricflow via tags that trigger a deployment action instead of relying on manual deployment. This is necessary for two reasons: 1. The MetricFlow repository is evolving to allow for multiple package deployments in distinctive ways, and each package would benefit from a set of pre-deployment steps. 2. With the CLI now bundled with dbt-metricflow we need a structured way of adding and deploying patch fixes for versions that are too far behind the current repo main branch to deploy off of main. Therefore, this PR splits our PyPI deployment action into two separate versions with different tag-format triggers, one for MetricFlow and the other for dbt-metricflow. Authentication for dbt-metricflow will be managed via PyPI's Trusted Publisher mechanism. MetricFlow will follow suit once the relevant PyPI enrollments are ready. Note these are separate files with some duplication here, but it's minimal, and we expect further divergence over time as we develop package-specific pre-deployment tests for these packages. --- .../cd-push-dbt-metricflow-to-pypi.yaml | 27 +++++++++++++++++++ ...i.yaml => cd-push-metricflow-to-pypi.yaml} | 4 ++- 2 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/cd-push-dbt-metricflow-to-pypi.yaml rename .github/workflows/{cd-push-to-pypi.yaml => cd-push-metricflow-to-pypi.yaml} (74%) diff --git a/.github/workflows/cd-push-dbt-metricflow-to-pypi.yaml b/.github/workflows/cd-push-dbt-metricflow-to-pypi.yaml new file mode 100644 index 0000000000..05618a380c --- /dev/null +++ b/.github/workflows/cd-push-dbt-metricflow-to-pypi.yaml @@ -0,0 +1,27 @@ +name: Publish dbt-metricflow Release +on: + workflow_dispatch: + push: + # Tag format is /v + tags: + - "dbt-metricflow/v[0-9]+.[0-9]+.[0-9]+*" + +env: + PYTHON_VERSION: "3.8" + +jobs: + pypi-publish: + runs-on: ubuntu-latest + environment: Pypi Publish + steps: + - name: Check-out the repo + uses: actions/checkout@v3 + + - name: Setup Python ${{ env.PYTHON_VERSION }} Environment + uses: ./.github/actions/setup-python-env + with: + python-version: "${{ env.PYTHON_VERSION }}" + + - name: Hatch Publish `dbt-metricflow` + working-directory: ./dbt-metricflow + run: hatch build && hatch publish diff --git a/.github/workflows/cd-push-to-pypi.yaml b/.github/workflows/cd-push-metricflow-to-pypi.yaml similarity index 74% rename from .github/workflows/cd-push-to-pypi.yaml rename to .github/workflows/cd-push-metricflow-to-pypi.yaml index 6b32bec67e..962009d81f 100644 --- a/.github/workflows/cd-push-to-pypi.yaml +++ b/.github/workflows/cd-push-metricflow-to-pypi.yaml @@ -2,8 +2,10 @@ name: Publish Metricflow Release on: workflow_dispatch: push: + # MetricFlow historically tagged releases with v + # We restrict to this for now and assume any tag without a package identifier is MetricFlow itself tags: - - "*" + - "v[0-9]+.[0-9]+.[0-9]+*" env: PYTHON_VERSION: "3.8"