-
Notifications
You must be signed in to change notification settings - Fork 0
51 lines (49 loc) · 1.48 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
45
46
47
48
49
50
51
name: PyPI Publish
on:
release:
types:
- published
jobs:
publish:
name: Publish
runs-on: 'ubuntu-latest'
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Install Poetry
if: steps.cache-poetry.outputs.cache-hit != 'true'
run: |
curl -sSL https://install.python-poetry.org | python -
- name: Add Poetry to $PATH
run: |
echo "$HOME/.poetry/bin" >> $GITHUB_PATH
- name: Add version to environment vars
run: |
PROJECT_VERSION=$(poetry version --short)
echo "PROJECT_VERSION=$PROJECT_VERSION" >> $GITHUB_ENV
- name: Check if tag version matches project version
run: |
TAG=$(git describe HEAD --tags --abbrev=0)
echo $TAG
echo $PROJECT_VERSION
if [[ "$TAG" != "v$PROJECT_VERSION" ]]; then exit 1; fi
- name: Get Poetry version
run: poetry --version
- name: Check pyproject.toml validity
run: poetry check --no-interaction
- name: Install deps
run: |
poetry config virtualenvs.in-project true
poetry install --no-interaction
- name: Publish to PyPI
env:
PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }}
run: |
poetry config pypi-token.pypi $PYPI_TOKEN
poetry publish --build