-
Notifications
You must be signed in to change notification settings - Fork 0
80 lines (66 loc) · 2.12 KB
/
release.yml
File metadata and controls
80 lines (66 loc) · 2.12 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
name: release
on:
push:
tags: ["v*"]
workflow_dispatch:
inputs:
publish:
description: "Publish to PyPI"
required: true
default: "false"
type: choice
options: ["false", "true"]
jobs:
quality:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install -e ".[dev]"
- name: Run tests
run: python -m pytest -q
- name: Run security checks
run: python -m bandit -q -r src/predicate_secure/
- name: Run pre-commit checks
run: |
python -m pip install pre-commit
pre-commit run --all-files
publish:
runs-on: ubuntu-latest
needs: [quality]
if: (github.event_name == 'workflow_dispatch' && inputs.publish == 'true') || startsWith(github.ref, 'refs/tags/v')
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Install build tooling
run: python -m pip install --upgrade pip build twine
- name: Validate version matches tag
if: startsWith(github.ref, 'refs/tags/v')
run: |
TAG_VERSION="${GITHUB_REF_NAME#v}"
PKG_VERSION=$(python -c "import tomllib; print(tomllib.load(open('pyproject.toml', 'rb'))['project']['version'])")
if [ "$TAG_VERSION" != "$PKG_VERSION" ]; then
echo "Tag version ($TAG_VERSION) does not match package version ($PKG_VERSION)"
exit 1
fi
echo "Version validated: $PKG_VERSION"
- name: Build package
run: python -m build
- name: Validate distribution metadata
run: twine check dist/*
- name: Publish to PyPI
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN_PREDICATE_SECURE }}
run: twine upload dist/*