-
Notifications
You must be signed in to change notification settings - Fork 3
35 lines (33 loc) · 955 Bytes
/
main.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
name: build-test-publish
on:
push:
branches: [main]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: '3.12'
- name: Install and configure Poetry
uses: snok/install-poetry@v1
- name: Build and install project
run: |
poetry build
poetry install
- name: Run tests with pytest
run: |
poetry run pytest tests
- name: Publish to PyPi
env:
PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }}
run: |
# Attempt to publish and capture output
if OUTPUT=$(poetry publish --build -u __token__ -p $PYPI_TOKEN 2>&1); then
echo "Package published successfully"
else
echo "::warning::Not published to PyPi. Poetry output: $OUTPUT"
fi
# Ensure step exits successfully
exit 0