-
Notifications
You must be signed in to change notification settings - Fork 1
48 lines (36 loc) · 1.04 KB
/
publish.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
name: Publish to PyPI
on:
push:
tags:
- 'v*' # This will trigger the workflow for any tag starting with 'v'
jobs:
build-and-publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.x'
- name: Install Poetry
run: |
curl -sSL https://install.python-poetry.org | python3 -
echo "$HOME/.local/bin" >> $GITHUB_PATH
- name: Install dependencies
run: poetry install
- name: Check version
run: |
pkg_version=$(poetry version -s)
tag_version=${GITHUB_REF#refs/tags/v}
if [ "$pkg_version" != "$tag_version" ]; then
echo "Version mismatch: pyproject.toml ($pkg_version) != Git tag ($tag_version)"
exit 1
fi
- name: Build package
run: poetry build
- name: Publish to PyPI
env:
PYPI_TOKEN: ${{ secrets.PYPI_PUBLISH }}
run: |
poetry config pypi-token.pypi $PYPI_TOKEN
poetry publish