Repository navigation
73 lines (66 loc) · 2.23 KB
/
Copy pathpythonpublish.yml
File metadata and controls
73 lines (66 loc) · 2.23 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
name: PyPI 📦 Distribution
on: [push, pull_request]
permissions:
contents: read
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: "3.13"
- name: Install dependencies
run: python -m pip install "poetry>=2,<3" build twine
- name: Check package metadata
run: poetry check --lock
- name: Check release tag matches package version
if: startsWith(github.ref, 'refs/tags/')
env:
RELEASE_TAG: ${{ github.ref_name }}
run: |
python - <<'PY'
import os
import tomllib
from pathlib import Path
from packaging.version import Version
tag = os.environ['RELEASE_TAG'].removeprefix('v')
version = tomllib.loads(Path('pyproject.toml').read_text())['tool']['poetry']['version']
if Version(tag) != Version(version):
raise SystemExit(f'Release tag {tag!r} does not match package version {version!r}')
PY
- name: Build distribution 📦
run: python -m build
- name: Check distribution metadata
run: python -m twine check --strict dist/*
- name: Test installed wheel
run: |
python -m pip install dist/*.whl
python -I tests/test_qltool.py InstalledQltool_Test -v
- uses: actions/upload-artifact@v4
with:
name: distributions
path: ${{ github.workspace }}/dist/*
if-no-files-found: error
publish:
needs: [build]
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/')
steps:
- uses: actions/download-artifact@v4
with:
name: distributions
path: dist
- name: Publish distribution 📦 to test PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.testpypi_pass }}
repository-url: https://test.pypi.org/legacy/
skip-existing: true
- name: Publish distribution 📦 to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.pypi_pass }}