-
-
Notifications
You must be signed in to change notification settings - Fork 2
109 lines (107 loc) · 3.06 KB
/
pythonpackage.yml
File metadata and controls
109 lines (107 loc) · 3.06 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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
name: Python package
on:
push:
branches: master
tags: v*
pull_request:
branches: master
jobs:
lint:
runs-on: ubuntu-slim
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@v6
- uses: astral-sh/ruff-action@v3
- run: ruff format
typecheck:
runs-on: ubuntu-slim
steps:
- uses: actions/checkout@v6
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: '3.11'
- name: Install dependencies
run: |
pipx install 'poetry>=2'
- name: Install package with dev dependencies
run: poetry install -v --all-extras
- name: Run mypy type checking
run: poetry run mypy tact
build:
needs: [lint, typecheck]
runs-on: ubuntu-latest
strategy:
max-parallel: 4
matrix:
python-version:
- "3.11"
- "3.12"
- "3.13"
- "3.14"
steps:
- name: Install apt packages
run: |
sudo apt update
sudo apt install libopenblas-dev
- uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
pipx install 'poetry>=2'
- name: Check tags
if: startsWith(github.event.ref, 'refs/tags')
id: tag
run: |
# double echo to strip whitespace
gitd=$(echo $(git describe --tags))
echo "tag=$gitd" >> $GITHUB_OUTPUT
poetryv=$(echo v$(poetry version --short))
echo $gitd
echo $poetryv
- name: Install package for testing
run: poetry install -v --all-extras
- name: Test with pytest
run: poetry run pytest --script-launch-mode=subprocess -W error::DeprecationWarning
- name: Reinstall package for production
run: |
poetry env list --full-path | xargs rm -rf
poetry install -v
- name: Build distribution package
id: build
run: |
set -eux
# Torture git-describe into an acceptable Python version format
new_tag=$(git describe --tags | cut -c2- | sed 's/-/+/' | sed 's/-/./g')
echo $new_tag
echo "version=$new_tag" >> $GITHUB_OUTPUT
poetry version $new_tag
poetry build
- uses: actions/upload-artifact@v6
if: matrix.python-version == '3.13'
with:
name: ${{ steps.build.outputs.version }}
path: dist
publish-to-pypi:
name: Publish distribution to PyPI
if: startsWith(github.event.ref, 'refs/tags')
needs:
- build
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/tact
permissions:
id-token: write
steps:
- uses: actions/download-artifact@v7
with:
name: ${{ steps.build.outputs.version }}
path: dist/
- uses: pypa/gh-action-pypi-publish@release/v1