Skip to content

Commit 34cd166

Browse files
mgrange1998meta-codesync[bot]
authored andcommitted
Add GitHub Actions release workflow with Trusted Publisher (facebookresearch#121)
Summary: Pull Request resolved: facebookresearch#121 ## Problem PrivacyGuard has no automated PyPI publishing workflow. Publishing requires manual package builds and API token management. ## Solution Add a GitHub Actions release workflow using PyPI Trusted Publishers (OIDC-based authentication, no API tokens needed). ### New: `.github/workflows/release.yml` - Triggers on GitHub Release publish or manual `workflow_dispatch` - Runs the full test suite before building (reuses `reusable_test.yml`) - Builds sdist + wheel via `python -m build` - Publishes to PyPI using `pypa/gh-action-pypi-publish` with OIDC Trusted Publisher auth - Requires a `pypi` GitHub environment (for optional approval gating) ### Modified: `pyproject.toml` - Enabled `setuptools_scm` (was commented out) so package version is derived from git tags automatically - Removed the unused `write_to` option — version is resolved at build time without generating a `version.py` ## Setup required before first use 1. **PyPI**: Register a pending Trusted Publisher at pypi.org -> Account -> Publishing: - PyPI project name: `PrivacyGuard` - Owner: `facebookresearch` - Repository: `PrivacyGuard` - Workflow: `release.yml` - Environment: `pypi` 2. **GitHub**: Create a `pypi` environment in repo Settings -> Environments (optionally add required reviewers) 3. **To publish**: Create a GitHub Release with a version tag (e.g., `v0.1.0`) — the workflow runs automatically Reviewed By: iden-kalemaj Differential Revision: D98518834 fbshipit-source-id: 1d0c37ab97d4b42007fc7db4a13901e92c31ac01
1 parent 6e90c21 commit 34cd166

2 files changed

Lines changed: 57 additions & 3 deletions

File tree

.github/workflows/release.yml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: Publish to PyPI
2+
3+
on:
4+
release:
5+
types: [published]
6+
workflow_dispatch:
7+
8+
jobs:
9+
tests:
10+
name: Run tests before publish
11+
uses: ./.github/workflows/reusable_test.yml
12+
secrets: inherit
13+
14+
build:
15+
name: Build distribution
16+
needs: tests
17+
runs-on: ubuntu-latest
18+
steps:
19+
- uses: actions/checkout@v4
20+
with:
21+
fetch-depth: 0
22+
23+
- name: Set up Python
24+
uses: actions/setup-python@v5
25+
with:
26+
python-version: "3.12"
27+
28+
- name: Install build tools
29+
run: pip install build
30+
31+
- name: Build sdist and wheel
32+
run: python -m build
33+
34+
- name: Upload build artifacts
35+
uses: actions/upload-artifact@v4
36+
with:
37+
name: dist
38+
path: dist/
39+
40+
publish:
41+
name: Publish to PyPI
42+
needs: build
43+
runs-on: ubuntu-latest
44+
environment: pypi
45+
permissions:
46+
id-token: write
47+
steps:
48+
- name: Download build artifacts
49+
uses: actions/download-artifact@v4
50+
with:
51+
name: dist
52+
path: dist/
53+
54+
- name: Publish to PyPI
55+
uses: pypa/gh-action-pypi-publish@release/v1

pyproject.toml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,8 @@ find = {}
9393
[tool.setuptools.package-data]
9494
"*" = ["*.js", "*.css", "*.html"]
9595

96-
#[tool.setuptools_scm]
97-
#write_to = "privacy_guard/version.py"
98-
#local_scheme = "node-and-date"
96+
[tool.setuptools_scm]
97+
local_scheme = "node-and-date"
9998

10099
[tool.usort]
101100
first_party_detection = false

0 commit comments

Comments
 (0)