Skip to content

Commit 35bd877

Browse files
authored
ci: Adding release-on-tag flow (#18)
* chore: correcting `__all__` * Updated changelog * Version bump * Added runscripts to the build * Updated README.md file * Small code cleanup * Added a few more scripts for easier testing * reformat * Release on tag
1 parent 64eddae commit 35bd877

File tree

2 files changed

+76
-3
lines changed

2 files changed

+76
-3
lines changed

.github/workflows/release.yml

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
name: Publish to PyPI
2+
3+
on:
4+
push:
5+
tags:
6+
- '[0-9]+.[0-9]+.[0-9]'
7+
- 'v[0-9]+.[0-9]+.[0-9]'
8+
- 'V[0-9]+.[0-9]+.[0-9]'
9+
10+
jobs:
11+
publish:
12+
runs-on: ubuntu-latest
13+
strategy:
14+
matrix:
15+
python-version: ["3.11"]
16+
17+
permissions:
18+
id-token: write
19+
20+
steps:
21+
- uses: actions/checkout@v4
22+
23+
- name: Install Poetry
24+
uses: snok/install-poetry@v1
25+
with:
26+
virtualenvs-create: true
27+
virtualenvs-in-project: true
28+
29+
- name: Set up Python ${{ matrix.python-version }}
30+
uses: actions/setup-python@v5
31+
with:
32+
python-version: ${{ matrix.python-version }}
33+
cache: 'poetry'
34+
35+
- name: Install dependencies
36+
run: |
37+
poetry install --no-interaction
38+
pip install -U ruff mypy
39+
40+
- name: Set version from tag
41+
run: |
42+
VERSION=${GITHUB_REF#refs/tags/} # Extract the tag (e.g., v1.0.0 or V2.3.4)
43+
VERSION=${VERSION#v} # Remove 'v' prefix if present
44+
VERSION=${VERSION#V} # Remove 'V' prefix if present
45+
echo "Setting version to $VERSION"
46+
poetry version $VERSION
47+
48+
- name: Run ruff format check
49+
if: always()
50+
run: poetry run ruff format --check --diff .
51+
52+
- name: Run ruff lint check
53+
if: always()
54+
run: poetry run ruff check --diff .
55+
56+
- name: Run tests with coverage
57+
if: always()
58+
run: poetry run pytest --cov=${{ github.event.repository.name }} --cov-report=xml
59+
60+
- name: Upload coverage report
61+
uses: codecov/codecov-action@v5
62+
with:
63+
fail_ci_if_error: true
64+
files: ./coverage.xml
65+
token: ${{ secrets.CODECOV_TOKEN }}
66+
67+
- name: Build packages
68+
run: poetry build
69+
70+
- name: Publish package distributions to PyPI
71+
uses: pypa/gh-action-pypi-publish@release/v1

.github/workflows/run_tests.yml renamed to .github/workflows/tests.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,11 @@ jobs:
3030
run: python -m pip install ruff
3131

3232
- name: Check python code
33+
if: always()
3334
run: ruff check --no-fix .
3435

3536
- name: Check formatting style
37+
if: always()
3638
run: ruff format --diff .
3739
#----------------------------------------------
3840

@@ -77,15 +79,15 @@ jobs:
7779
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
7880
run: poetry install --no-interaction --no-root
7981

80-
- name: Install smartschool
82+
- name: Install ${{ github.event.repository.name }}
8183
run: poetry install --no-interaction
8284

8385
- name: Run tests
8486
run: |
8587
source .venv/bin/activate
86-
pytest --cov=smartschool --cov-append --cov-fail-under=80 --cov-branch --cov-report=json --cov-report=term
88+
pytest --cov=${{ github.event.repository.name }} --cov-append --cov-fail-under=90 --cov-branch --cov-report=json --cov-report=term
8789
8890
- name: Upload coverage reports to Codecov
89-
uses: codecov/codecov-action@v3
91+
uses: codecov/codecov-action@v5
9092
env:
9193
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

0 commit comments

Comments
 (0)