Skip to content

Commit 7fa6df0

Browse files
authored
Merge pull request #10 from proxymesh/ci/pypi-publish
Add PyPI publish workflow and bump to v0.2.0
2 parents e1c8879 + 847239e commit 7fa6df0

2 files changed

Lines changed: 95 additions & 1 deletion

File tree

.github/workflows/publish.yml

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
name: Publish to PyPI
2+
3+
on:
4+
release:
5+
types: [published]
6+
7+
# Allow manual trigger for testing
8+
workflow_dispatch:
9+
inputs:
10+
test_pypi:
11+
description: 'Publish to TestPyPI instead of PyPI'
12+
required: false
13+
default: 'false'
14+
type: boolean
15+
16+
jobs:
17+
build:
18+
name: Build distribution
19+
runs-on: ubuntu-latest
20+
21+
steps:
22+
- uses: actions/checkout@v4
23+
24+
- name: Set up Python
25+
uses: actions/setup-python@v5
26+
with:
27+
python-version: '3.x'
28+
29+
- name: Install build dependencies
30+
run: |
31+
python -m pip install --upgrade pip
32+
pip install build
33+
34+
- name: Build package
35+
run: python -m build
36+
37+
- name: Store distribution packages
38+
uses: actions/upload-artifact@v4
39+
with:
40+
name: python-package-distributions
41+
path: dist/
42+
43+
publish-to-pypi:
44+
name: Publish to PyPI
45+
if: github.event_name == 'release' || (github.event_name == 'workflow_dispatch' && inputs.test_pypi == 'false')
46+
needs: build
47+
runs-on: ubuntu-latest
48+
49+
environment:
50+
name: pypi
51+
url: https://pypi.org/p/python-proxy-headers
52+
53+
permissions:
54+
id-token: write # Required for trusted publishing
55+
56+
steps:
57+
- name: Download distribution packages
58+
uses: actions/download-artifact@v4
59+
with:
60+
name: python-package-distributions
61+
path: dist/
62+
63+
- name: Publish to PyPI
64+
uses: pypa/gh-action-pypi-publish@release/v1
65+
with:
66+
# Uses trusted publishing (OIDC) - no API token needed if configured
67+
# Fallback to API token if trusted publishing not set up
68+
password: ${{ secrets.PYPI_API_TOKEN }}
69+
70+
publish-to-testpypi:
71+
name: Publish to TestPyPI
72+
if: github.event_name == 'workflow_dispatch' && inputs.test_pypi == 'true'
73+
needs: build
74+
runs-on: ubuntu-latest
75+
76+
environment:
77+
name: testpypi
78+
url: https://test.pypi.org/p/python-proxy-headers
79+
80+
permissions:
81+
id-token: write
82+
83+
steps:
84+
- name: Download distribution packages
85+
uses: actions/download-artifact@v4
86+
with:
87+
name: python-package-distributions
88+
path: dist/
89+
90+
- name: Publish to TestPyPI
91+
uses: pypa/gh-action-pypi-publish@release/v1
92+
with:
93+
repository-url: https://test.pypi.org/legacy/
94+
password: ${{ secrets.TEST_PYPI_API_TOKEN }}

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "python-proxy-headers"
7-
version = "0.1.0"
7+
version = "0.2.0"
88
authors = [
99
{ name="ProxyMesh", email="support@proxymesh.com" },
1010
]

0 commit comments

Comments
 (0)