Skip to content

Commit 9fd5871

Browse files
authored
added publish workflow (#2325)
1 parent f1e77f3 commit 9fd5871

File tree

2 files changed

+86
-0
lines changed

2 files changed

+86
-0
lines changed

.github/workflows/publish.yml

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
name: Build and upload to PyPI
2+
3+
on:
4+
workflow_dispatch: # run on request (no need for PR)
5+
release:
6+
types: [published]
7+
8+
jobs:
9+
build_wheels:
10+
name: Build wheels
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Checkout
14+
uses: actions/checkout@v3
15+
- name: Build wheels
16+
uses: pypa/[email protected]
17+
- uses: actions/upload-artifact@v3
18+
with:
19+
path: ./wheelhouse/*.whl
20+
21+
build_sdist:
22+
name: Build source distribution
23+
runs-on: ubuntu-latest
24+
steps:
25+
- name: Checkout
26+
uses: actions/checkout@v3
27+
- name: Set up Python 3.10
28+
uses: actions/setup-python@v3
29+
with:
30+
python-version: "3.10"
31+
- name: Install pypa/build
32+
run: python -m pip install build
33+
- name: Build sdist
34+
run: python -m build --sdist
35+
- uses: actions/upload-artifact@v3
36+
with:
37+
path: dist/*.tar.gz
38+
39+
publish_package:
40+
name: Publish package
41+
needs: [build_wheels, build_sdist]
42+
environment: pypi
43+
runs-on: ubuntu-latest
44+
permissions: write-all
45+
steps:
46+
- name: Download artifacts
47+
uses: actions/download-artifact@v3
48+
with:
49+
# unpacks default artifact into dist/
50+
# if `name: artifact` is omitted, the action will create extra parent dir
51+
name: artifact
52+
path: dist
53+
# to determine where to publish the source distribution to PyPI or TestPyPI
54+
- name: Check tag
55+
id: check-tag
56+
uses: actions-ecosystem/action-regex-match@v2
57+
with:
58+
text: ${{ github.ref }}
59+
regex: '^refs/tags/[0-9]+\.[0-9]+\.[0-9]+(\.[0-9]+rc[0-9]+|rc[0-9]+)?$'
60+
- name: Upload package distributions to github
61+
if: ${{ steps.check-tag.outputs.match != '' }}
62+
uses: svenstaro/upload-release-action@v2
63+
with:
64+
repo_token: ${{ secrets.GITHUB_TOKEN }}
65+
file: dist/*
66+
tag: ${{ github.ref }}
67+
overwrite: true
68+
file_glob: true
69+
- name: Publish package distributions to PyPI
70+
if: ${{ steps.check-tag.outputs.match != '' }}
71+
uses: pypa/[email protected]
72+
with:
73+
password: ${{ secrets.PYPI_API_TOKEN }}
74+
- name: Publish package distributions to TestPyPI
75+
if: ${{ steps.check-tag.outputs.match == '' }}
76+
uses: pypa/[email protected]
77+
with:
78+
password: ${{ secrets.TESTPYPI_API_TOKEN }}
79+
repository-url: https://test.pypi.org/legacy/
80+
verbose: true

pyproject.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,12 @@ requires = [
1212
build-backend = "setuptools.build_meta"
1313

1414

15+
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
16+
# CIBUILDWHEEL CONFIGURATION. #
17+
[tool.cibuildwheel]
18+
build = "cp37-manylinux_x86_64 cp38-manylinux_x86_64 cp39-manylinux_x86_64 cp310-manylinux_x86_64"
19+
20+
1521
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
1622
# COVERAGE CONFIGURATION. #
1723
[tool.coverage.run]

0 commit comments

Comments
 (0)