Skip to content

Commit 1c13a15

Browse files
add github workflow
1 parent 71a78a0 commit 1c13a15

File tree

6 files changed

+1015
-800
lines changed

6 files changed

+1015
-800
lines changed

.github/workflows/main.yml

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
tags:
8+
- 'v*'
9+
10+
jobs:
11+
build:
12+
runs-on: ubuntu-latest
13+
if: startsWith(github.ref, 'refs/tags/v')
14+
15+
steps:
16+
- name: Checkout code
17+
uses: actions/checkout@v4
18+
19+
- name: Install uv
20+
uses: astral-sh/setup-uv@v5
21+
with:
22+
version: "0.6.6"
23+
24+
- name: "Set up Python"
25+
uses: actions/setup-python@v5
26+
with:
27+
python-version-file: ".python-version"
28+
29+
- name: Install the project
30+
run: uv sync --all-extras --group=build
31+
32+
- name: Build package
33+
run: |
34+
uv run -m build
35+
36+
- name: Upload distributions
37+
uses: actions/upload-artifact@v4
38+
with:
39+
name: release-dists
40+
path: dist/
41+
42+
pypi-publish:
43+
runs-on: ubuntu-latest
44+
needs: build
45+
permissions:
46+
# IMPORTANT: this permission is mandatory for trusted publishing
47+
id-token: write
48+
49+
# Dedicated environments with protections for publishing are strongly recommended.
50+
# For more information, see: https://docs.github.com/en/actions/deployment/targeting-different-environments/using-environments-for-deployment#deployment-protection-rules
51+
environment:
52+
name: pypi
53+
# OPTIONAL: uncomment and update to include your PyPI project URL in the deployment status:
54+
# url: https://pypi.org/p/YOURPROJECT
55+
#
56+
# ALTERNATIVE: if your GitHub Release name is the PyPI project version string
57+
# ALTERNATIVE: exactly, uncomment the following line instead:
58+
# url: https://pypi.org/project/YOURPROJECT/${{ github.event.release.name }}
59+
60+
steps:
61+
- name: Retrieve release distributions
62+
uses: actions/download-artifact@v4
63+
with:
64+
name: release-dists
65+
path: dist/
66+
67+
- name: Publish release distributions to PyPI
68+
uses: pypa/gh-action-pypi-publish@release/v1
69+
with:
70+
packages-dir: dist/
71+
72+
73+
- name: Create GitHub Release
74+
uses: softprops/action-gh-release@v2
75+
with:
76+
token: ${{ secrets.GITHUB_TOKEN }}
77+
tag_name: ${{ github.ref_name }}
78+
name: Release ${{ github.ref_name }}
79+
body: "Automated release of version ${{ github.ref_name }}."
80+
files: |
81+
dist/*

.github/workflows/release.yml

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
tags:
8+
- 'v*'
9+
10+
jobs:
11+
build:
12+
runs-on: ubuntu-latest
13+
if: startsWith(github.ref, 'refs/tags/v')
14+
15+
steps:
16+
- name: Checkout code
17+
uses: actions/checkout@v4
18+
19+
- name: Install uv
20+
uses: astral-sh/setup-uv@v5
21+
with:
22+
version: "0.6.6"
23+
24+
- name: "Set up Python"
25+
uses: actions/setup-python@v5
26+
with:
27+
python-version-file: ".python-version"
28+
29+
- name: Install the project
30+
run: uv sync --all-extras --group=build
31+
32+
- name: Build package
33+
run: |
34+
uv run -m build
35+
36+
- name: Upload distributions
37+
uses: actions/upload-artifact@v4
38+
with:
39+
name: release-dists
40+
path: dist/
41+
42+
pypi-publish:
43+
runs-on: ubuntu-latest
44+
needs: build
45+
permissions:
46+
# IMPORTANT: this permission is mandatory for trusted publishing
47+
id-token: write
48+
49+
# Dedicated environments with protections for publishing are strongly recommended.
50+
# For more information, see: https://docs.github.com/en/actions/deployment/targeting-different-environments/using-environments-for-deployment#deployment-protection-rules
51+
environment:
52+
name: pypi
53+
# OPTIONAL: uncomment and update to include your PyPI project URL in the deployment status:
54+
# url: https://pypi.org/p/YOURPROJECT
55+
#
56+
# ALTERNATIVE: if your GitHub Release name is the PyPI project version string
57+
# ALTERNATIVE: exactly, uncomment the following line instead:
58+
# url: https://pypi.org/project/YOURPROJECT/${{ github.event.release.name }}
59+
60+
steps:
61+
- name: Retrieve release distributions
62+
uses: actions/download-artifact@v4
63+
with:
64+
name: release-dists
65+
path: dist/
66+
67+
- name: Publish release distributions to PyPI
68+
uses: pypa/gh-action-pypi-publish@release/v1
69+
with:
70+
packages-dir: dist/
71+
72+
73+
- name: Create GitHub Release
74+
uses: softprops/action-gh-release@v2
75+
with:
76+
token: ${{ secrets.GITHUB_TOKEN }}
77+
tag_name: ${{ github.ref_name }}
78+
name: Release ${{ github.ref_name }}
79+
body: "Automated release of version ${{ github.ref_name }}."
80+
files: |
81+
dist/*

.pre-commit-config.yaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
minimum_pre_commit_version: "3.5.0"
2+
3+
repos:
4+
- repo: https://github.com/astral-sh/ruff-pre-commit
5+
# Ruff version.
6+
rev: v0.9.10
7+
hooks:
8+
# Run the linter.
9+
- id: ruff
10+
types_or: [ python, pyi ]
11+
args: [ --fix ]
12+
# Run the formatter.
13+
- id: ruff-format
14+
types_or: [ python, pyi ]

.python-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3.11

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ Homepage = "https://github.com/ika-rwth-aachen/omega-prime"
4848
Repository = "https://github.com/ika-rwth-aachen/omega-prime"
4949

5050
[project.optional-dependencies]
51-
test = ['ruff', 'pdoc3', 'pytest', 'pytest-sugar', 'pytest-env','pytest-cov','pytest-progress','pytest-codeblocks', 'nbval','ipywidgets']
51+
test = ['ruff', 'pdoc3', 'pre-commit', 'pytest', 'pytest-sugar', 'pytest-env','pytest-cov','pytest-progress','pytest-codeblocks', 'nbval','ipywidgets']
5252

5353
[project.scripts]
5454
omega-prime = "omega_prime.cli:app"
@@ -80,7 +80,7 @@ ignore_packages = [
8080
zero = true
8181

8282
[tool.pytest.ini_options]
83-
addopts = "-ra --junitxml=report.xml --nbval --codeblocks"
83+
addopts = "--nbval --codeblocks --cov=omega_prime --cov-report=xml --cov-report=html --cov-report=term-missing"
8484
testpaths = [
8585
"tests",
8686
"tutorial.ipynb",

0 commit comments

Comments
 (0)