From 667e5648ea68241945447da41a282285f070ce44 Mon Sep 17 00:00:00 2001 From: Thomas Lento Date: Tue, 30 Jul 2024 15:32:33 -0700 Subject: [PATCH] Backport publishing actions enabling tag deployment for dbt-metricflow (#1362) Backport of three PRs required to enable tag-based deployment from the `support/dbt-metricflow-0.7.x` branch. Specifically: - **Enable tag-based deployment for dbt-metricflow (#1349)** - **Remove access token reference for PyPI (#1350)** - **Enable Trusted Publishing for PyPI actions (#1356)** --- .../cd-push-dbt-metricflow-to-pypi.yaml | 36 +++++++++++++++++++ .../workflows/cd-push-metricflow-to-pypi.yaml | 34 ++++++++++++++++++ .github/workflows/cd-push-to-pypi.yaml | 28 --------------- 3 files changed, 70 insertions(+), 28 deletions(-) create mode 100644 .github/workflows/cd-push-dbt-metricflow-to-pypi.yaml create mode 100644 .github/workflows/cd-push-metricflow-to-pypi.yaml delete mode 100644 .github/workflows/cd-push-to-pypi.yaml 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..2bf657db66 --- /dev/null +++ b/.github/workflows/cd-push-dbt-metricflow-to-pypi.yaml @@ -0,0 +1,36 @@ +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: + name: Pypi Publish + url: https://pypi.org/p/dbt-metricflow + permissions: + id-token: write + 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: Build `dbt-metricflow` package + working-directory: ./dbt-metricflow + run: hatch build + + - name: Publish `dbt-metricflow` package to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 + with: + packages-dir: ./dbt-metricflow/dist/ diff --git a/.github/workflows/cd-push-metricflow-to-pypi.yaml b/.github/workflows/cd-push-metricflow-to-pypi.yaml new file mode 100644 index 0000000000..076d78593d --- /dev/null +++ b/.github/workflows/cd-push-metricflow-to-pypi.yaml @@ -0,0 +1,34 @@ +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" + +jobs: + pypi-publish: + runs-on: ubuntu-latest + environment: + name: Pypi Publish + url: https://pypi.org/p/metricflow + permissions: + id-token: write + 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: Build `metricflow` package + run: hatch build + + - name: Publish `metricflow` package to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 diff --git a/.github/workflows/cd-push-to-pypi.yaml b/.github/workflows/cd-push-to-pypi.yaml deleted file mode 100644 index 6b32bec67e..0000000000 --- a/.github/workflows/cd-push-to-pypi.yaml +++ /dev/null @@ -1,28 +0,0 @@ -name: Publish Metricflow Release -on: - workflow_dispatch: - push: - tags: - - "*" - -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 `metricflow` - run: hatch build && hatch publish - env: - HATCH_INDEX_USER: __token__ - HATCH_INDEX_AUTH: ${{ secrets.PYPI_API_TOKEN }}