-
Notifications
You must be signed in to change notification settings - Fork 7
135 lines (116 loc) · 3.97 KB
/
Copy pathpublish.yml
File metadata and controls
135 lines (116 loc) · 3.97 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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
name: Publish to PyPI
on:
workflow_dispatch:
inputs:
tag:
description: "Git tag to republish (e.g. v3.1.0)"
required: true
concurrency:
group: publish-pypi-${{ inputs.tag || github.ref_name }}
cancel-in-progress: false
env:
PYTHON_VERSION: "3.12"
jobs:
build:
name: Build distribution
runs-on: ubuntu-latest
timeout-minutes: 10
permissions:
contents: read
steps:
- name: Checkout code
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
with:
ref: ${{ inputs.tag || github.ref_name }}
- name: Set up Python
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Verify tag matches package version
env:
INPUT_TAG: ${{ inputs.tag || github.ref_name }}
run: |
if [[ ! "$INPUT_TAG" =~ ^v?[0-9] ]]; then
echo "Invalid tag format: $INPUT_TAG (expected [v]N.N.N)"
exit 1
fi
TAG_VERSION="${INPUT_TAG#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 pyproject.toml version ($PKG_VERSION)"
exit 1
fi
echo "Version check passed: $PKG_VERSION"
- name: Install and build package
run: |
python -m pip install --upgrade pip build
python -m build
- name: Upload distribution artifacts
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
with:
name: dist
path: dist/
if-no-files-found: error
retention-days: 5
test-package:
name: Verify built package (Python ${{ matrix.python-version }})
needs: build
runs-on: ubuntu-latest
timeout-minutes: 10
permissions:
contents: read
strategy:
fail-fast: false
matrix:
python-version: ["3.8", "3.12"]
steps:
- name: Checkout tests
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
with:
ref: ${{ inputs.tag || github.ref_name }}
sparse-checkout: |
tests
pyproject.toml
sparse-checkout-cone-mode: false
- name: Download distribution artifacts
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4
with:
name: dist
path: dist/
- name: Set up Python
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5
with:
python-version: ${{ matrix.python-version }}
- name: Verify sdist installs
run: |
python -m pip install --upgrade pip
python -m pip install dist/*.tar.gz
python -c "from signnow import __version__; print(f'sdist installed: {__version__}')"
python -m pip uninstall -y signnow-python-sdk
- name: Install wheel and test dependencies
run: |
python -m pip install dist/*.whl
python -m pip install "pytest>=7.4.0" "pytest-cov>=4.1.0"
- name: Run tests against installed wheel
run: |
python -c "from signnow import __version__; print(f'wheel installed: {__version__}')"
pytest tests/ -v
publish:
name: Publish to PyPI
needs: test-package
runs-on: ubuntu-latest
timeout-minutes: 10
environment:
name: pypi
url: https://pypi.org/project/signnow-python-sdk/
permissions:
contents: read
id-token: write
steps:
- name: Download distribution artifacts
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4
with:
name: dist
path: dist/
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@cef221092ed1bacb1cc03d23a2d87d1d172e277b # release/v1