Skip to content

Commit 1ec7533

Browse files
authored
Merge pull request #3 from proxymesh/ci/pypi-publish
Add GitHub Actions workflow for PyPI publishing
2 parents 6939370 + 2ef52d6 commit 1ec7533

1 file changed

Lines changed: 78 additions & 0 deletions

File tree

.github/workflows/publish.yml

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
name: Publish to PyPI
2+
3+
on:
4+
release:
5+
types: [published]
6+
workflow_dispatch:
7+
inputs:
8+
test_pypi:
9+
description: 'Publish to TestPyPI instead of PyPI'
10+
required: false
11+
default: false
12+
type: boolean
13+
14+
jobs:
15+
build:
16+
name: Build distribution
17+
runs-on: ubuntu-latest
18+
steps:
19+
- uses: actions/checkout@v4
20+
21+
- name: Set up Python
22+
uses: actions/setup-python@v5
23+
with:
24+
python-version: "3.x"
25+
26+
- name: Install build dependencies
27+
run: python -m pip install --upgrade pip build
28+
29+
- name: Build package
30+
run: python -m build
31+
32+
- name: Upload distribution artifacts
33+
uses: actions/upload-artifact@v4
34+
with:
35+
name: python-package-distributions
36+
path: dist/
37+
38+
publish-to-pypi:
39+
name: Publish to PyPI
40+
if: github.event_name == 'release' || (github.event_name == 'workflow_dispatch' && inputs.test_pypi == false)
41+
needs: build
42+
runs-on: ubuntu-latest
43+
environment:
44+
name: pypi
45+
url: https://pypi.org/p/scrapy-proxy-headers
46+
permissions:
47+
id-token: write
48+
steps:
49+
- name: Download distribution artifacts
50+
uses: actions/download-artifact@v4
51+
with:
52+
name: python-package-distributions
53+
path: dist/
54+
55+
- name: Publish to PyPI
56+
uses: pypa/gh-action-pypi-publish@release/v1
57+
58+
publish-to-testpypi:
59+
name: Publish to TestPyPI
60+
if: github.event_name == 'workflow_dispatch' && inputs.test_pypi == true
61+
needs: build
62+
runs-on: ubuntu-latest
63+
environment:
64+
name: testpypi
65+
url: https://test.pypi.org/p/scrapy-proxy-headers
66+
permissions:
67+
id-token: write
68+
steps:
69+
- name: Download distribution artifacts
70+
uses: actions/download-artifact@v4
71+
with:
72+
name: python-package-distributions
73+
path: dist/
74+
75+
- name: Publish to TestPyPI
76+
uses: pypa/gh-action-pypi-publish@release/v1
77+
with:
78+
repository-url: https://test.pypi.org/legacy/

0 commit comments

Comments
 (0)