Skip to content

Commit 95227d0

Browse files
committed
Enable Trusted Publishing for PyPI actions (#1356)
In order to use Trusted Publishing we have to do some special things. Most of these things have been abstracted away through the official action plugin provided by the Python Packaging Authority. This change simply conforms our actions configs with the requirements for the plugin. Specifically, providing the `id-token: write` permission and the target URL for publication in the relevant environment config.
1 parent d7931ff commit 95227d0

File tree

2 files changed

+22
-6
lines changed

2 files changed

+22
-6
lines changed

.github/workflows/cd-push-dbt-metricflow-to-pypi.yaml

+12-3
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,11 @@ env:
1212
jobs:
1313
pypi-publish:
1414
runs-on: ubuntu-latest
15-
environment: Pypi Publish
15+
environment:
16+
name: Pypi Publish
17+
url: https://pypi.org/p/dbt-metricflow
18+
permissions:
19+
id-token: write
1620
steps:
1721
- name: Check-out the repo
1822
uses: actions/checkout@v3
@@ -22,6 +26,11 @@ jobs:
2226
with:
2327
python-version: "${{ env.PYTHON_VERSION }}"
2428

25-
- name: Hatch Publish `dbt-metricflow`
29+
- name: Build `dbt-metricflow` package
2630
working-directory: ./dbt-metricflow
27-
run: hatch build && hatch publish
31+
run: hatch build
32+
33+
- name: Publish `dbt-metricflow` package to PyPI
34+
uses: pypa/gh-action-pypi-publish@release/v1
35+
with:
36+
packages-dir: ./dbt-metricflow/dist/

.github/workflows/cd-push-metricflow-to-pypi.yaml

+10-3
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,11 @@ env:
1313
jobs:
1414
pypi-publish:
1515
runs-on: ubuntu-latest
16-
environment: Pypi Publish
16+
environment:
17+
name: Pypi Publish
18+
url: https://pypi.org/p/metricflow
19+
permissions:
20+
id-token: write
1721
steps:
1822
- name: Check-out the repo
1923
uses: actions/checkout@v3
@@ -23,5 +27,8 @@ jobs:
2327
with:
2428
python-version: "${{ env.PYTHON_VERSION }}"
2529

26-
- name: Hatch Publish `metricflow`
27-
run: hatch build && hatch publish
30+
- name: Build `metricflow` package
31+
run: hatch build
32+
33+
- name: Publish `metricflow` package to PyPI
34+
uses: pypa/gh-action-pypi-publish@release/v1

0 commit comments

Comments
 (0)