Skip to content

Commit 2cd0f59

Browse files
authored
build: use a dedicated publish workflow (#248)
1 parent a2885e0 commit 2cd0f59

File tree

2 files changed

+38
-33
lines changed

2 files changed

+38
-33
lines changed

.github/workflows/publish.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# This will run every time a tag is created and pushed to the repository.
2+
# It calls our tests workflow via a `workflow_call`, and if tests pass
3+
# then it triggers our upload to PyPI for a new release.
4+
name: Publish to PyPI
5+
on:
6+
release:
7+
types: ["published"]
8+
9+
jobs:
10+
tests:
11+
uses: ./.github/workflows/tests.yml
12+
13+
publish:
14+
needs: [tests]
15+
name: Publish to PyPi
16+
runs-on: ubuntu-latest
17+
steps:
18+
- name: Checkout source
19+
uses: actions/checkout@v4
20+
- name: Set up Python 3.10
21+
uses: actions/setup-python@v5
22+
with:
23+
python-version: 3.10
24+
- name: Build package
25+
run: |
26+
pip install wheel
27+
python setup.py sdist bdist_wheel
28+
- name: Publish
29+
uses: pypa/gh-action-pypi-publish@v1.8.11
30+
with:
31+
user: __token__
32+
password: ${{ secrets.PYPI_KEY }}

.github/workflows/tests.yml

Lines changed: 6 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ on:
66
pull_request:
77
schedule:
88
- cron: "0 8 * * *"
9+
workflow_call:
910

1011
jobs:
1112
pre-commit:
@@ -36,11 +37,8 @@ jobs:
3637
uses: actions/setup-python@v5
3738
with:
3839
python-version: ${{ matrix.python-version }}
39-
40-
- name: Install dependencies
41-
run: |
42-
python -m pip install --upgrade pip hatch
43-
40+
- name: Install hatch
41+
run: pip install hatch
4442
- name: Run tests
4543
run: hatch run test:test -x
4644

@@ -49,32 +47,7 @@ jobs:
4947
steps:
5048
- uses: actions/checkout@v4
5149
- uses: actions/setup-python@v5
52-
- name: Install dependencies
53-
run: |
54-
python -m pip install --upgrade pip hatch
55-
50+
- name: Install hatch
51+
run: pip install hatch
5652
- name: Build docs
57-
run: |
58-
hatch run doc:build
59-
60-
publish:
61-
name: Publish to PyPi
62-
needs: [tests]
63-
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags')
64-
runs-on: ubuntu-latest
65-
steps:
66-
- name: Checkout source
67-
uses: actions/checkout@v4
68-
- name: Set up Python 3.8
69-
uses: actions/setup-python@v5
70-
with:
71-
python-version: 3.8
72-
- name: Build package
73-
run: |
74-
pip install wheel
75-
python setup.py sdist bdist_wheel
76-
- name: Publish
77-
uses: pypa/gh-action-pypi-publish@v1.8.11
78-
with:
79-
user: __token__
80-
password: ${{ secrets.PYPI_KEY }}
53+
run: hatch run doc:build

0 commit comments

Comments
 (0)