Repository navigation
80 lines (76 loc) · 2.12 KB
/
Copy pathpublish.yml
File metadata and controls
80 lines (76 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: Publish to PyPI
on:
push:
tags:
- "v*"
permissions:
contents: read
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
with:
persist-credentials: false
- uses: actions/setup-python@v6
with:
python-version: "3.12"
cache: pip
- run: python -m pip install -U pip
- run: python -m pip install -e ".[dev]"
- name: Check release version and companion tag
run: |
python - <<'PY'
import os
import subprocess
import dftk
tag = os.environ["GITHUB_REF_NAME"]
expected = f"v{dftk.__version__}"
if tag != expected:
raise SystemExit(f"Release tag {tag} does not match package version {expected}")
subprocess.run([
"git", "ls-remote", "--exit-code", "--refs",
"https://github.com/DigiForensics/DFTK-skill.git",
f"refs/tags/{tag}",
], check=True)
PY
- run: python scripts/check_docs.py
- run: pytest -q
- name: Require an explicit public license
run: |
test -f LICENSE || {
echo "Refusing production publish: add the selected public LICENSE file first."
exit 1
}
build:
needs: test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
with:
persist-credentials: false
- uses: actions/setup-python@v6
with:
python-version: "3.12"
cache: pip
- run: python -m pip install -U build twine
- run: python -m build
- run: python -m twine check --strict dist/*
- uses: actions/upload-artifact@v6
with:
name: python-package-distributions
path: dist/
if-no-files-found: error
publish:
needs: build
runs-on: ubuntu-latest
environment:
name: pypi
permissions:
id-token: write
steps:
- uses: actions/download-artifact@v6
with:
name: python-package-distributions
path: dist/
- uses: pypa/gh-action-pypi-publish@release/v1