-
Notifications
You must be signed in to change notification settings - Fork 4
89 lines (73 loc) · 2.17 KB
/
ci.yml
File metadata and controls
89 lines (73 loc) · 2.17 KB
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
name: CI
on:
push:
branches:
- main
tags:
- 'v*' # Trigger on version tags like v1.2.3
pull_request_target:
branches:
- main
permissions:
contents: write
jobs:
# 1️⃣ Test Job
test:
name: Tests
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.11", "3.12", "3.13"]
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install Poetry
run: pip install poetry
- name: Install dependencies
run: poetry install --with dev,test
- name: Run tests
run: poetry run pytest
# 2️⃣ Release Job (Uses Prebuilt Package)
release:
name: Release / Publish to PyPI
runs-on: ubuntu-latest
needs:
- test
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.13"
- name: Install Poetry
run: pip install poetry
- name: Install dependencies
run: poetry install --without test,dev
- name: Clean dist folder
run: rm -rf dist/
- name: Configure Poetry and Set Version
run: |
git fetch --tags
if [[ "${GITHUB_REF}" == refs/tags/* ]]; then
VERSION=$(poetry version --short)
echo "Stable version for release: $VERSION"
elif [[ "${GITHUB_REF}" == refs/heads/main ]]; then
VERSION="$(poetry version --short).dev${{ github.run_number }}"
echo "Development version (main): $VERSION"
poetry version "$VERSION"
else
VERSION="$(poetry version --short).dev${{ github.run_number }}"
echo "Development version (branch): $VERSION"
poetry version "$VERSION"
fi
- name: Build the package
run: poetry build
- name: Publish to PyPI
run: |
poetry config pypi-token.pypi "${{ secrets.PYPI_API_TOKEN }}"
poetry publish