Skip to content

Commit 0052fab

Browse files
authored
Add hatch and update workflows (#44)
* Update gitignore * Add pyproject.toml * Run formatter * Remove setup.py * Remove travis and tox config * Add CI workflows * Update README * Remove not needed files * Use hatch test matrix * Fix build config * Use proper codecov action config
1 parent 1d91c4b commit 0052fab

31 files changed

+1405
-370
lines changed

.coveragerc

Lines changed: 0 additions & 13 deletions
This file was deleted.

.github/workflows/build.yml

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
name: Build
2+
3+
on:
4+
workflow_call:
5+
workflow_dispatch:
6+
7+
env:
8+
PYTHONUNBUFFERED: "1"
9+
FORCE_COLOR: "1"
10+
11+
jobs:
12+
test:
13+
uses: ./.github/workflows/test.yml
14+
permissions:
15+
contents: read
16+
build:
17+
name: Build distribution 📦
18+
runs-on: ubuntu-latest
19+
needs:
20+
- test
21+
steps:
22+
- name: Checkout source code
23+
uses: actions/checkout@v4
24+
25+
- name: Set up Python
26+
uses: actions/setup-python@v5
27+
with:
28+
python-version-file: pyproject.toml
29+
30+
- name: Install Hatch
31+
uses: pypa/hatch@a3c83ab3d481fbc2dc91dd0088628817488dd1d5
32+
33+
- name: Set package version from tag
34+
run: hatch version $(git describe --tags --always)
35+
36+
- name: Build package
37+
run: hatch build
38+
39+
- name: Store the distribution packages
40+
uses: actions/upload-artifact@v4
41+
with:
42+
name: python-package-distributions
43+
path: dist/
44+
45+
sign-release:
46+
name: >-
47+
Sign the Python 🐍 distribution 📦 with Sigstore
48+
needs:
49+
- build
50+
runs-on: ubuntu-latest
51+
permissions:
52+
id-token: write # IMPORTANT: mandatory for sigstore
53+
steps:
54+
- name: Download all the dists
55+
uses: actions/download-artifact@v4
56+
with:
57+
name: python-package-distributions
58+
path: dist/
59+
- name: Sign the dists with Sigstore
60+
uses: sigstore/gh-action-sigstore-python@v3.0.0
61+
with:
62+
inputs: >-
63+
./dist/*.tar.gz
64+
./dist/*.whl
65+
- name: Store the signature files
66+
uses: actions/upload-artifact@v4
67+
with:
68+
name: python-package-distributions
69+
path: dist/
70+
overwrite: true

.github/workflows/codecov.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: Codecov Report Upload
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
pull_request:
8+
9+
env:
10+
PYTHONUNBUFFERED: "1"
11+
FORCE_COLOR: "1"
12+
13+
jobs:
14+
cov-report:
15+
name: Generate and publish coverage report
16+
runs-on: ubuntu-latest
17+
steps:
18+
- name: Checkout source code
19+
uses: actions/checkout@v4
20+
21+
- name: Set up Python
22+
uses: actions/setup-python@v5
23+
with:
24+
python-version-file: pyproject.toml
25+
26+
- name: Install Hatch
27+
uses: pypa/hatch@a3c83ab3d481fbc2dc91dd0088628817488dd1d5
28+
29+
- name: Run coverage
30+
run: hatch test --cover -i python=3.13
31+
32+
- name: Generate coverage report
33+
run: hatch run coverage:xml
34+
35+
- name: Publish coverage report to Codecov
36+
uses: codecov/codecov-action@v4
37+
with:
38+
fail_ci_if_error: true
39+
token: ${{ secrets.CODECOV_TOKEN }}
40+
files: coverage.xml
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: Prepare release
2+
3+
on:
4+
push:
5+
tags:
6+
- '*'
7+
workflow_call:
8+
workflow_dispatch:
9+
10+
env:
11+
PYTHONUNBUFFERED: "1"
12+
FORCE_COLOR: "1"
13+
14+
jobs:
15+
build:
16+
uses: ./.github/workflows/build.yml
17+
permissions:
18+
contents: read
19+
id-token: write # IMPORTANT: mandatory for sigstore in build.yml
20+
21+
create-release:
22+
needs:
23+
- build
24+
runs-on: ubuntu-latest
25+
steps:
26+
- name: Download all the dists
27+
uses: actions/download-artifact@v4
28+
with:
29+
name: python-package-distributions
30+
path: dist/
31+
- name: Release
32+
id: create-draft-release
33+
uses: softprops/action-gh-release@v2
34+
with:
35+
files: |
36+
./dist/*
37+
draft: true
38+
- name: Summary
39+
run: |
40+
echo "# Release summary" >> $GITHUB_STEP_SUMMARY
41+
echo "Url: ${{ steps.create-draft-release.outputs.url }}" >> $GITHUB_STEP_SUMMARY
42+
echo "You can now publish the release on GitHub" >> $GITHUB_STEP_SUMMARY

.github/workflows/publish.yml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: Publish
2+
3+
on:
4+
release:
5+
types:
6+
- published
7+
workflow_call:
8+
workflow_dispatch:
9+
10+
env:
11+
PYTHONUNBUFFERED: "1"
12+
FORCE_COLOR: "1"
13+
14+
jobs:
15+
publish-to-pypi:
16+
name: >-
17+
Publish Python 🐍 distribution 📦 to PyPI
18+
if: startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes
19+
runs-on: ubuntu-latest
20+
environment:
21+
name: pypi
22+
url: https://pypi.org/p/django-prices-openexchangerates
23+
permissions:
24+
# IMPORTANT: this permission is mandatory for trusted publishing
25+
id-token: write
26+
contents: read
27+
28+
steps:
29+
- name: Download all the dists from the release
30+
env:
31+
GITHUB_TOKEN: ${{ github.token }}
32+
run: >-
33+
gh release download
34+
'${{ github.ref_name }}'
35+
-p '*.whl'
36+
-p '*.tar.gz'
37+
--dir dist/
38+
--repo '${{ github.repository }}'
39+
- name: Publish package distributions to PyPI
40+
uses: pypa/gh-action-pypi-publish@release/v1
41+
with:
42+
skip-existing: true

.github/workflows/test.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: Tests
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
pull_request:
8+
workflow_call:
9+
workflow_dispatch:
10+
11+
env:
12+
PYTHONUNBUFFERED: "1"
13+
FORCE_COLOR: "1"
14+
15+
jobs:
16+
test:
17+
name: Test for Python and Django versions
18+
runs-on: ubuntu-latest
19+
20+
steps:
21+
- name: Checkout source code
22+
uses: actions/checkout@v4
23+
24+
- name: Set up Python
25+
uses: actions/setup-python@v5
26+
with:
27+
python-version-file: pyproject.toml
28+
29+
- name: Install Hatch
30+
uses: pypa/hatch@a3c83ab3d481fbc2dc91dd0088628817488dd1d5
31+
32+
- name: Run static analysis
33+
run: hatch fmt --check
34+
35+
- name: Run tests
36+
run: hatch test --all

.github/workflows/tox.yml

Lines changed: 0 additions & 27 deletions
This file was deleted.

0 commit comments

Comments
 (0)