Skip to content

Commit 802bc4e

Browse files
authored
Merge pull request #158 from DomainTools/IDEV-1077
IDEV-1077: Improve worfklow to automate publishing the package to PyPI
2 parents 6fa550f + 9422961 commit 802bc4e

File tree

2 files changed

+75
-25
lines changed

2 files changed

+75
-25
lines changed

.github/workflows/python.yml

Lines changed: 0 additions & 25 deletions
This file was deleted.
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
name: DomainTools python wrapper CI/CD
2+
3+
on:
4+
push:
5+
pull_request:
6+
release:
7+
types: [published]
8+
9+
10+
jobs:
11+
test:
12+
runs-on: ubuntu-20.04
13+
strategy:
14+
matrix:
15+
python-version: ["3.9", "3.10", "3.11"]
16+
17+
steps:
18+
- uses: actions/checkout@v2
19+
- name: Set up Python ${{ matrix.python-version }}
20+
uses: actions/setup-python@v2
21+
with:
22+
python-version: ${{ matrix.python-version }}
23+
- name: Install dependencies
24+
run: |
25+
python -m pip install --upgrade pip
26+
pip install tox
27+
- name: Test with tox
28+
run: |
29+
export TOX_SKIP_MISSING_INTERPRETERS="False";
30+
tox -e py
31+
32+
# run only in main and in pull request to `main` and in publish release
33+
release-build:
34+
if: |
35+
github.ref == 'refs/heads/main' ||
36+
(github.event_name == 'pull_request' && github.base_ref == 'main') ||
37+
(github.event_name == 'release' && github.event.action == 'published')
38+
needs: test
39+
runs-on: ubuntu-latest
40+
steps:
41+
- uses: actions/checkout@v4
42+
43+
- uses: actions/setup-python@v5
44+
with:
45+
python-version: "3.11"
46+
47+
- name: Install build dependencies
48+
run: |
49+
python -m pip install --upgrade pip
50+
pip install build
51+
52+
- name: Build package
53+
run: python -m build
54+
55+
- name: Upload distributions as artifact
56+
uses: actions/upload-artifact@v4
57+
with:
58+
name: release-dists
59+
path: dist/
60+
61+
publish-to-pypi:
62+
runs-on: ubuntu-latest
63+
needs: release-build
64+
if: github.event_name == 'release' && github.event.action == 'published'
65+
permissions:
66+
id-token: write # Required for OIDC trusted publishing
67+
steps:
68+
- name: Download build artifacts
69+
uses: actions/download-artifact@v4
70+
with:
71+
name: release-dists
72+
path: dist/
73+
74+
- name: Publish to PyPI using API token
75+
uses: pypa/gh-action-pypi-publish@release/v1

0 commit comments

Comments
 (0)