Skip to content

Commit 440902b

Browse files
committed
Added github ci
1 parent bf6196a commit 440902b

2 files changed

Lines changed: 169 additions & 0 deletions

File tree

.github/workflows/ci.yml

Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [master, main, "feature/*"]
6+
pull_request:
7+
branches: [master, main]
8+
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
13+
outputs:
14+
version: ${{ steps.git_version.outputs.BUILD_VERSION }}
15+
version_major: ${{ steps.git_version.outputs.BUILD_VERSION_MAJOR }}
16+
version_minor: ${{ steps.git_version.outputs.BUILD_VERSION_MINOR }}
17+
version_patch: ${{ steps.git_version.outputs.BUILD_VERSION_PATCH }}
18+
version_build: ${{ steps.git_version.outputs.BUILD_VERSION_BUILD }}
19+
tag: ${{ steps.git_version.outputs.BUILD_VERSION_TAG }}
20+
branch: ${{ steps.git_version.outputs.BUILD_VERSION_BRANCH }}
21+
commit: ${{ steps.git_version.outputs.BUILD_VERSION_COMMIT }}
22+
short: ${{ steps.git_version.outputs.BUILD_VERSION_SHORT }}
23+
full: ${{ steps.git_version.outputs.BUILD_VERSION_FULL }}
24+
extended: ${{ steps.git_version.outputs.BUILD_VERSION_EXTENDED }}
25+
default_branch: ${{ steps.git_version.outputs.BUILD_VERSION_DEFAULT_BRANCH }}
26+
27+
steps:
28+
- uses: actions/checkout@v4
29+
with:
30+
fetch-depth: 0
31+
32+
- name: Set up Python
33+
uses: actions/setup-python@v5
34+
with:
35+
python-version: "3.13"
36+
37+
- name: Install build tools
38+
run: |
39+
python -m pip install --upgrade pip
40+
pip install build
41+
42+
- name: Build package
43+
run: python -m build
44+
45+
- name: Install built package
46+
run: pip install dist/*.whl
47+
48+
- name: Extract version info from built package
49+
id: git_version
50+
run: |
51+
while IFS='=' read -r key value; do
52+
echo "$key=$value" >> "$GITHUB_OUTPUT"
53+
done < <(git-version --property env)
54+
55+
- name: Show version info
56+
run: |
57+
echo "═══════════════════════════════════════"
58+
echo " GIT VERSION INFORMATION"
59+
echo "═══════════════════════════════════════"
60+
echo " Version: ${{ steps.git_version.outputs.BUILD_VERSION }}"
61+
echo " Major: ${{ steps.git_version.outputs.BUILD_VERSION_MAJOR }}"
62+
echo " Minor: ${{ steps.git_version.outputs.BUILD_VERSION_MINOR }}"
63+
echo " Patch: ${{ steps.git_version.outputs.BUILD_VERSION_PATCH }}"
64+
echo " Build: ${{ steps.git_version.outputs.BUILD_VERSION_BUILD }}"
65+
echo " Tag: ${{ steps.git_version.outputs.BUILD_VERSION_TAG }}"
66+
echo " Branch: ${{ steps.git_version.outputs.BUILD_VERSION_BRANCH }}"
67+
echo " Commit: ${{ steps.git_version.outputs.BUILD_VERSION_COMMIT }}"
68+
echo " Short: ${{ steps.git_version.outputs.BUILD_VERSION_SHORT }}"
69+
echo " Full: ${{ steps.git_version.outputs.BUILD_VERSION_FULL }}"
70+
echo " Extended: ${{ steps.git_version.outputs.BUILD_VERSION_EXTENDED }}"
71+
echo " DefaultBranch: ${{ steps.git_version.outputs.BUILD_VERSION_DEFAULT_BRANCH }}"
72+
echo "═══════════════════════════════════════"
73+
74+
- name: Upload build artifacts
75+
uses: actions/upload-artifact@v4
76+
with:
77+
name: dist
78+
path: dist/
79+
80+
test:
81+
runs-on: ubuntu-latest
82+
needs: build
83+
84+
strategy:
85+
matrix:
86+
python-version: ["3.10", "3.11", "3.12", "3.13"]
87+
88+
steps:
89+
- uses: actions/checkout@v4
90+
with:
91+
fetch-depth: 0
92+
93+
- name: Set up Python ${{ matrix.python-version }}
94+
uses: actions/setup-python@v5
95+
with:
96+
python-version: ${{ matrix.python-version }}
97+
98+
- name: Install build tools
99+
run: |
100+
python -m pip install --upgrade pip
101+
pip install build
102+
103+
- name: Build package
104+
run: python -m build
105+
106+
- name: Install built package
107+
run: pip install dist/*.whl
108+
109+
- name: Install test dependencies
110+
run: pip install pytest
111+
112+
- name: Run tests from repo
113+
run: python -m pytest tests/ -v
114+
115+
lint:
116+
runs-on: ubuntu-latest
117+
118+
steps:
119+
- uses: actions/checkout@v4
120+
121+
- name: Set up Python
122+
uses: actions/setup-python@v5
123+
with:
124+
python-version: "3.13"
125+
126+
- name: Install lint tools
127+
run: |
128+
python -m pip install --upgrade pip
129+
pip install ruff
130+
131+
- name: Lint with ruff
132+
run: ruff check src/ tests/

.github/workflows/publish.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: Publish to PyPI
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
version:
7+
description: "Version to publish (e.g., 0.1.0)"
8+
required: true
9+
type: string
10+
11+
jobs:
12+
publish:
13+
runs-on: ubuntu-latest
14+
if: github.ref == 'refs/heads/master'
15+
16+
steps:
17+
- uses: actions/checkout@v4
18+
with:
19+
fetch-depth: 0
20+
21+
- name: Set up Python
22+
uses: actions/setup-python@v5
23+
with:
24+
python-version: "3.13"
25+
26+
- name: Install build tools
27+
run: |
28+
python -m pip install --upgrade pip
29+
pip install build
30+
31+
- name: Build package
32+
run: python -m build
33+
34+
- name: Publish to PyPI
35+
uses: pypa/gh-action-pypi-publish@release/v1
36+
with:
37+
password: ${{ secrets.PYPI_API_TOKEN }}

0 commit comments

Comments
 (0)