Skip to content

Commit 2866d05

Browse files
authored
Merge pull request #1 from synacker/feature/init
Initial commit.
2 parents fd26190 + 823fe72 commit 2866d05

12 files changed

Lines changed: 862 additions & 219 deletions

File tree

.github/workflows/ci.yml

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

.github/workflows/publish.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
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: Generate _version.py from git tags
32+
run: python tools/write_version.py
33+
34+
- name: Build package
35+
run: python -m build
36+
37+
- name: Publish to PyPI
38+
uses: pypa/gh-action-pypi-publish@release/v1
39+
with:
40+
password: ${{ secrets.PYPI_API_TOKEN }}

0 commit comments

Comments
 (0)