Skip to content

Commit f1d5c41

Browse files
committed
Added a shared workflow to publish python package.
1 parent 725840f commit f1d5c41

File tree

2 files changed

+57
-21
lines changed

2 files changed

+57
-21
lines changed

.github/workflows/ci.yml

Lines changed: 8 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -70,33 +70,20 @@ jobs:
7070
files: dist/*
7171

7272
test_publish_to_pypi:
73-
runs-on: ubuntu-latest
7473
environment: test_deployment
7574
needs: test
7675
name: Test publish to PyPI
7776
if: startsWith(github.ref, 'refs/heads/')
78-
steps:
79-
- uses: actions/checkout@v2
80-
- name: Publish to TestPyPI
81-
uses: JRubics/poetry-publish@v1.10
82-
with:
83-
repository_name: testpypi
84-
repository_url: ${{ secrets.PYPI_REPOSITORY }}
85-
repository_username: __token__
86-
repository_password: ${{ secrets.pypi_token }}
77+
uses: "./.github/workflows/publish.yml"
78+
with:
79+
token: ${{ secrets.pypi_token }}
80+
url: ${{ secrets.pypi_url }}
8781

8882
publish_to_pypi:
89-
runs-on: ubuntu-latest
9083
environment: Production
9184
needs: test
92-
name: Publish to PyPI
9385
if: startsWith(github.ref, 'refs/tags/')
94-
steps:
95-
- uses: actions/checkout@v2
96-
- name: Publish to PyPI
97-
uses: JRubics/poetry-publish@v1.10
98-
with:
99-
repository_name: testpypi
100-
repository_url: ${{ secrets.PYPI_REPOSITORY }}
101-
repository_username: __token__
102-
repository_password: ${{ secrets.pypi_token }}
86+
uses: "./.github/workflows/publish.yml"
87+
with:
88+
token: ${{ secrets.pypi_token }}
89+
url: ${{ secrets.pypi_url }}

.github/workflows/publish.yml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
on:
2+
workflow_call:
3+
inputs:
4+
url:
5+
required: true
6+
type: string
7+
default: https://pypi.python.org/simple/
8+
9+
token:
10+
required: true
11+
type: string
12+
13+
python_version:
14+
required: true
15+
default: 3.9
16+
type: string
17+
18+
poetry_version:
19+
required: true
20+
default: 1.1.12
21+
type: string
22+
23+
install_deps:
24+
type: string
25+
default: true
26+
required: false
27+
28+
jobs:
29+
publish:
30+
runs-on: ubuntu-latest
31+
name: Publish python package
32+
steps:
33+
- uses: actions/setup-python@v2
34+
with:
35+
python-version: ${{ inputs.python_version }}
36+
37+
- uses: actions/checkout@v2
38+
- run: pip install --upgrade pip poetry
39+
- run: |
40+
poetry config repositories.destrepo ${{ secrets.url }}
41+
poetry config pypi-token.destrepo ${{ secrets.token }}
42+
poetry config virtualenvs.create false
43+
name: Configure poetry
44+
- name: Install project dependencies
45+
run: |
46+
poetry install $(test "$INSTALL_DEPS" != "true" && echo --no-dev)
47+
- run: poetry build
48+
name: Build package
49+
- run: poetry publish -r destrepo

0 commit comments

Comments
 (0)