Skip to content

Commit 060ba47

Browse files
MAINT: Factor publish to pypi workflow into dedicated file (#645)
Co-authored-by: AakashGC <aakashguptachoudhury@gmail.com>
1 parent 099f655 commit 060ba47

File tree

2 files changed

+34
-25
lines changed

2 files changed

+34
-25
lines changed

.github/workflows/publish.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
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+
publish:
13+
name: publish
14+
needs: [tests] # require tests to pass before deploy runs
15+
runs-on: ubuntu-latest
16+
steps:
17+
- name: Checkout source
18+
uses: actions/checkout@v3
19+
- name: Set up Python 3.9
20+
uses: actions/setup-python@v4
21+
with:
22+
python-version: 3.9
23+
24+
- name: Build package
25+
run: |
26+
python -m pip install -U pip build
27+
python -m build
28+
29+
- name: Publish
30+
uses: pypa/gh-action-pypi-publish@v1.5.1
31+
with:
32+
user: __token__
33+
password: ${{ secrets.PYPI_KEY }}

.github/workflows/tests.yml

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ on:
66
tags:
77
- 'v*'
88
pull_request:
9+
workflow_call:
910

1011
env:
1112
PY_COLORS: 1
@@ -105,28 +106,3 @@ jobs:
105106
temporaryPublicStorage: true
106107
uploadArtifacts: true
107108
runs: 5
108-
109-
publish:
110-
name: Publish to PyPI
111-
needs: [pre-commit, tests]
112-
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags')
113-
114-
runs-on: ubuntu-latest
115-
steps:
116-
- name: Checkout source
117-
uses: actions/checkout@v3
118-
- name: Set up Python 3.7
119-
uses: actions/setup-python@v4
120-
with:
121-
python-version: 3.7
122-
123-
- name: Build package
124-
run: |
125-
python -m pip install -U pip build
126-
python -m build
127-
128-
- name: Publish
129-
uses: pypa/gh-action-pypi-publish@v1.5.1
130-
with:
131-
user: __token__
132-
password: ${{ secrets.PYPI_KEY }}

0 commit comments

Comments
 (0)