Skip to content

Commit c2f46eb

Browse files
committed
Add GitHub Actions CI for tests and release
1 parent 01ff1f6 commit c2f46eb

File tree

2 files changed

+132
-0
lines changed

2 files changed

+132
-0
lines changed

.github/workflows/release.yml

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
name: Release
2+
3+
on:
4+
release:
5+
types: [published]
6+
workflow_dispatch:
7+
inputs:
8+
version:
9+
description: 'Version to release (e.g., 0.1.0)'
10+
required: true
11+
type: string
12+
13+
jobs:
14+
build-and-publish:
15+
runs-on: ubuntu-latest
16+
permissions:
17+
contents: read
18+
id-token: write
19+
20+
steps:
21+
- name: Checkout code
22+
uses: actions/checkout@v4
23+
24+
- name: Set up Python 3.13.7
25+
uses: actions/setup-python@v5
26+
with:
27+
python-version: "3.13.7"
28+
29+
- name: Cache pip dependencies
30+
uses: actions/cache@v4
31+
with:
32+
path: ~/.cache/pip
33+
key: ${{ runner.os }}-pip-${{ hashFiles('**/pyproject.toml') }}
34+
restore-keys: |
35+
${{ runner.os }}-pip-
36+
37+
- name: Install dependencies
38+
run: |
39+
python -m pip install --upgrade pip
40+
pip install build twine
41+
42+
- name: Build package
43+
run: |
44+
python -m build
45+
46+
- name: Check package
47+
run: |
48+
twine check dist/*
49+
50+
- name: Upload to PyPI
51+
uses: pypa/gh-action-pypi-publish@release/v1
52+
with:
53+
user: ${{ secrets.PYPI_USERNAME }}
54+
password: ${{ secrets.PYPI_PASSWORD }}
55+
56+
- name: Create GitHub Release
57+
if: github.event_name == 'release'
58+
uses: actions/create-release@v1
59+
env:
60+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
61+
with:
62+
tag_name: ${{ github.event.release.tag_name }}
63+
release_name: ${{ github.event.release.name }}
64+
body: ${{ github.event.release.body }}
65+
draft: false
66+
prerelease: false
67+
68+
test-release:
69+
runs-on: ubuntu-latest
70+
needs: build-and-publish
71+
if: github.event_name == 'workflow_dispatch'
72+
73+
steps:
74+
- name: Checkout code
75+
uses: actions/checkout@v4
76+
77+
- name: Set up Python 3.13.7
78+
uses: actions/setup-python@v5
79+
with:
80+
python-version: "3.13.7"
81+
82+
- name: Install released package
83+
run: |
84+
python -m pip install --upgrade pip
85+
pip install sqlmodel-encrypted-fields==${{ github.event.inputs.version }}
86+
87+
- name: Test installed package
88+
run: |
89+
python -c "import sqlmodel_encrypted_fields; print('Package installed successfully')"
90+
python -c "from sqlmodel_encrypted_fields import EncryptedString; print('Fields imported successfully')"

.github/workflows/tests.yml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: Tests
2+
3+
on:
4+
push:
5+
branches: [ main, develop ]
6+
pull_request:
7+
branches: [ main, develop ]
8+
9+
jobs:
10+
test:
11+
runs-on: ubuntu-latest
12+
strategy:
13+
matrix:
14+
include:
15+
- python-version: "3.12"
16+
- python-version: "3.13.7"
17+
18+
steps:
19+
- name: Checkout code
20+
uses: actions/checkout@v4
21+
22+
- name: Set up Python ${{ matrix.python-version }}
23+
uses: actions/setup-python@v5
24+
with:
25+
python-version: ${{ matrix.python-version }}
26+
27+
- name: Cache pip dependencies
28+
uses: actions/cache@v4
29+
with:
30+
path: ~/.cache/pip
31+
key: ${{ runner.os }}-pip-${{ hashFiles('**/pyproject.toml') }}
32+
restore-keys: |
33+
${{ runner.os }}-pip-
34+
35+
- name: Install dependencies
36+
run: |
37+
python -m pip install --upgrade pip
38+
pip install -e ".[test]"
39+
40+
- name: Run tests
41+
run: |
42+
pytest -v

0 commit comments

Comments
 (0)