-
Notifications
You must be signed in to change notification settings - Fork 51
125 lines (101 loc) · 3.92 KB
/
Copy pathrelease.yaml
File metadata and controls
125 lines (101 loc) · 3.92 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
name: Release to PyPI
on:
workflow_dispatch:
inputs:
test_pypi:
description: 'Upload to Test PyPI instead of PyPI'
required: false
default: false
type: boolean
release:
types: [published]
jobs:
build-and-publish:
runs-on: ubuntu-latest
environment: release
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: '3.13'
- name: Check version matches release tag
if: github.event_name == 'release'
run: |
# Extract version from pyproject.toml using regex (no imports needed)
PACKAGE_VERSION=$(grep -oP '^version\s*=\s*"\K[^"]+' pyproject.toml)
# Extract tag name (remove 'v' prefix if present)
TAG_NAME="${{ github.event.release.tag_name }}"
TAG_VERSION="${TAG_NAME#v}"
echo "Package version: $PACKAGE_VERSION"
echo "Release tag: $TAG_NAME"
echo "Tag version (normalized): $TAG_VERSION"
if [ "$PACKAGE_VERSION" != "$TAG_VERSION" ]; then
echo "ERROR: Version mismatch!"
echo "Package version ($PACKAGE_VERSION) does not match release tag ($TAG_VERSION)"
echo "Please update version in pyproject.toml to match the release tag"
exit 1
fi
echo "Version check passed: $PACKAGE_VERSION matches $TAG_VERSION"
- name: Install uv
run: |
curl -LsSf https://astral.sh/uv/install.sh | sh
- name: Install build dependencies
run: |
uv pip install --python ${Python_ROOT_DIR} build twine
- name: Build package
run: python -m build
- name: Check package
run: python -m twine check dist/*
- name: Upload to Test PyPI
if: ${{ github.event.inputs.test_pypi == 'true' }}
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
repository-url: https://test.pypi.org/legacy/
verbose: true
- name: Upload to PyPI
if: ${{ github.event.inputs.test_pypi != 'true' }}
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_API_TOKEN }}
verbose: true
smoke-test:
runs-on: ubuntu-latest
needs: build-and-publish
steps:
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: '3.13'
- name: Install uv and pipx
run: |
curl -LsSf https://astral.sh/uv/install.sh | sh
uv pip install --python ${Python_ROOT_DIR} pipx
- name: Wait for package availability
run: |
echo "Waiting for package to be available on PyPI..."
sleep 60
- name: Test pipx run programbench --help (Test PyPI)
if: ${{ github.event.inputs.test_pypi == 'true' }}
run: pipx run --pip-args="--index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/" programbench --help
- name: Test pipx run programbench --help (PyPI)
if: ${{ github.event.inputs.test_pypi != 'true' }}
run: pipx run programbench --help
- name: Test uvx programbench --help (Test PyPI)
if: ${{ github.event.inputs.test_pypi == 'true' }}
run: uvx --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/ programbench --help
- name: Test uvx programbench --help (PyPI)
if: ${{ github.event.inputs.test_pypi != 'true' }}
run: uvx programbench --help
- name: Test pip install and CLI (Test PyPI)
if: ${{ github.event.inputs.test_pypi == 'true' }}
run: |
uv pip install --python ${Python_ROOT_DIR} --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/ programbench
programbench --help
- name: Test pip install and CLI (PyPI)
if: ${{ github.event.inputs.test_pypi != 'true' }}
run: |
uv pip install --python ${Python_ROOT_DIR} programbench
programbench --help