forked from br3ndonland/template-python
-
Notifications
You must be signed in to change notification settings - Fork 0
62 lines (59 loc) · 1.9 KB
/
Copy pathci.yml
File metadata and controls
62 lines (59 loc) · 1.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
name: ci
on:
pull_request:
push:
branches: [main]
tags: ["[0-9]+.[0-9]+.[0-9]+*"]
workflow_dispatch:
permissions:
contents: read
jobs:
ci:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.10", "3.11", "3.12", "3.13"]
defaults:
run:
shell: bash -el {0}
steps:
- uses: actions/checkout@v4
- uses: conda-incubator/setup-miniconda@v3
with:
python-version: ${{ matrix.python-version }}
environment-file: environment.yml
activate-environment: template-python
auto-update-conda: false
auto-activate-base: false
cache-downloads: true
cache-environment: true
- name: Test that Git tag version and Python package version match
if: github.ref_type == 'tag' && matrix.python-version == '3.12'
run: |
GIT_TAG_VERSION=$GITHUB_REF_NAME
PACKAGE_VERSION=$(python -c "import template_python; print(template_python.__version__)")
echo "The Python package version is $PACKAGE_VERSION."
echo "The Git tag version is $GIT_TAG_VERSION."
if [ "$PACKAGE_VERSION" = "$GIT_TAG_VERSION" ]; then
echo "Versions match."
else
echo "Versions do not match." && exit 1
fi
- name: Check code quality
run: |
ruff check
ruff format --check
- name: Run tests
run: coverage run
- name: Enforce test coverage
run: coverage report
- name: Build Python package
if: github.ref_type == 'tag' && matrix.python-version == '3.12'
run: |
pip install build --quiet
python -m build
- name: Publish Python package to PyPI
if: github.ref_type == 'tag' && matrix.python-version == '3.12'
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_TOKEN }}