File tree Expand file tree Collapse file tree 1 file changed +79
-0
lines changed
Expand file tree Collapse file tree 1 file changed +79
-0
lines changed Original file line number Diff line number Diff line change 1+ name : CI/CD
2+
3+ on :
4+ push :
5+ branches :
6+ - main
7+ - ' **'
8+ pull_request :
9+ branches :
10+ - main
11+
12+ jobs :
13+ test :
14+ runs-on : ubuntu-latest
15+ steps :
16+ - uses : actions/checkout@v4
17+
18+ - name : Set up Python
19+ uses : actions/setup-python@v5
20+ with :
21+ python-version : ' 3.9'
22+
23+ - name : Install uv
24+ uses : astral-sh/setup-uv@v4
25+
26+ - name : Install dependencies
27+ run : uv sync
28+
29+ - name : Run pre-commit
30+ run : |
31+ uv run pre-commit run --all-files
32+
33+ - name : Run tests
34+ run : |
35+ uv run python -m unittest discover -s tests -p "*.py"
36+
37+ publish :
38+ needs : test
39+ runs-on : ubuntu-latest
40+ if : github.event_name == 'push'
41+ permissions :
42+ id-token : write
43+ steps :
44+ - uses : actions/checkout@v4
45+ with :
46+ fetch-depth : 0
47+
48+ - name : Set up Python
49+ uses : actions/setup-python@v5
50+ with :
51+ python-version : ' 3.9'
52+
53+ - name : Install uv
54+ uses : astral-sh/setup-uv@v4
55+
56+ - name : Install dependencies
57+ run : uv sync
58+
59+ - name : Update version for staging (non-main branches)
60+ if : github.ref != 'refs/heads/main'
61+ run : |
62+ COMMIT_HASH=$(git rev-parse --short HEAD)
63+ CURRENT_VERSION=$(grep '^version = ' pyproject.toml | sed 's/version = "\(.*\)"/\1/')
64+ NEW_VERSION="${CURRENT_VERSION}.dev${COMMIT_HASH}"
65+ sed -i "s/^version = .*/version = \"${NEW_VERSION}\"/" pyproject.toml
66+ echo "Publishing version ${NEW_VERSION} to Test PyPI"
67+
68+ - name : Build package
69+ run : uv build
70+
71+ - name : Publish to Test PyPI (staging)
72+ if : github.ref != 'refs/heads/main'
73+ run : |
74+ uv publish --publish-url https://test.pypi.org/legacy/ --trusted-publishing always
75+
76+ - name : Publish to PyPI (production)
77+ if : github.ref == 'refs/heads/main'
78+ run : |
79+ uv publish --trusted-publishing always
You can’t perform that action at this time.
0 commit comments