-
Notifications
You must be signed in to change notification settings - Fork 13
225 lines (196 loc) · 7.42 KB
/
pypi-publish.yml
File metadata and controls
225 lines (196 loc) · 7.42 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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
name: Publish to PyPI
on:
push:
tags:
- 'v*'
workflow_dispatch:
inputs:
version:
description: 'Version to publish (e.g., 1.1.3)'
required: true
type: string
skip_tests:
description: 'Skip installation tests (faster but less safe)'
required: false
type: boolean
default: false
permissions:
contents: read
jobs:
build-wheels:
strategy:
fail-fast: false
matrix:
include:
# Tier 1: Core platforms (~91% coverage)
- os: ubuntu-latest
platform: manylinux_2_17_x86_64
binary_suffix: linux-amd64
archive_ext: .tar.gz
- os: ubuntu-latest
platform: manylinux_2_17_aarch64
binary_suffix: linux-arm64
archive_ext: .tar.gz
- os: macos-latest
platform: macosx_11_0_arm64
binary_suffix: darwin-arm64
archive_ext: .tar.gz
- os: macos-15-intel
platform: macosx_10_9_x86_64
binary_suffix: darwin-amd64
archive_ext: .tar.gz
- os: windows-latest
platform: win_amd64
binary_suffix: windows-amd64
archive_ext: .zip
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v6
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Get version from tag
id: version
shell: bash
run: |
if [[ "${{ github.event.inputs.version }}" != "" ]]; then
# Manual workflow_dispatch with version input
VERSION="${{ github.event.inputs.version }}"
elif [[ "${{ github.ref }}" == refs/tags/* ]]; then
# Tag push
VERSION=${GITHUB_REF#refs/tags/v}
else
# Fallback for pull_request
VERSION=$(python -c "import sys; sys.path.insert(0, 'python-sdk'); from codepathfinder import __version__; print(__version__)")
fi
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "Version: $VERSION"
- name: Create bin directory
shell: bash
run: mkdir -p python-sdk/codepathfinder/bin
- name: Download binary (Unix)
if: runner.os != 'Windows'
shell: bash
run: |
VERSION=${{ steps.version.outputs.version }}
SUFFIX=${{ matrix.binary_suffix }}
URL="https://github.com/shivasurya/code-pathfinder/releases/download/v${VERSION}/pathfinder-${SUFFIX}.tar.gz"
echo "Downloading from: $URL"
curl -L "$URL" | tar xz -C python-sdk/codepathfinder/bin/
chmod +x python-sdk/codepathfinder/bin/pathfinder
ls -la python-sdk/codepathfinder/bin/
- name: Download binary (Windows)
if: runner.os == 'Windows'
shell: pwsh
run: |
$VERSION = "${{ steps.version.outputs.version }}"
$URL = "https://github.com/shivasurya/code-pathfinder/releases/download/v$VERSION/pathfinder-windows-amd64.zip"
Write-Host "Downloading from: $URL"
Invoke-WebRequest -Uri $URL -OutFile pathfinder.zip
Expand-Archive -Path pathfinder.zip -DestinationPath python-sdk/codepathfinder/bin/
Get-ChildItem python-sdk/codepathfinder/bin/
- name: Install build tools
run: pip install build wheel setuptools
- name: Build wheel
shell: bash
run: |
cd python-sdk
python -m build --wheel
- name: Rename wheel with platform tag
shell: bash
run: |
cd python-sdk/dist
for f in *.whl; do
# Replace 'any' with platform-specific tag
newname=$(echo "$f" | sed "s/-py3-none-any/-py3-none-${{ matrix.platform }}/")
if [ "$f" != "$newname" ]; then
mv "$f" "$newname"
echo "Renamed: $f -> $newname"
fi
done
ls -la
- name: Upload wheel
uses: actions/upload-artifact@v4
with:
name: wheel-${{ matrix.platform }}
path: python-sdk/dist/*.whl
retention-days: 7
- name: Test wheel installation
if: github.event.inputs.skip_tests != 'true' && matrix.platform != 'manylinux_2_17_aarch64'
shell: bash
run: |
echo "=== Testing wheel installation ==="
cd python-sdk/dist
WHEEL=$(ls *.whl)
echo "Installing: $WHEEL"
pip install "$WHEEL"
pip list | grep codepathfinder
- name: Test CLI is available
if: github.event.inputs.skip_tests != 'true' && matrix.platform != 'manylinux_2_17_aarch64'
shell: bash
run: |
echo "=== Testing CLI binary ==="
echo "Checking pathfinder command..."
which pathfinder || where pathfinder || echo "Binary location: $(python -c 'import codepathfinder.cli; print(codepathfinder.cli.get_binary_path())')"
echo "Running pathfinder --version..."
pathfinder --version || echo "Version command failed"
- name: Test Python SDK import and version
if: github.event.inputs.skip_tests != 'true' && matrix.platform != 'manylinux_2_17_aarch64'
shell: bash
run: |
echo "=== Testing Python SDK ==="
python -c "from codepathfinder import __version__, rule, calls, flows; print('[OK] SDK Import OK'); print(f'[OK] Python SDK Version: {__version__}'); print('[OK] Available: rule, calls, flows')"
- name: Test binary execution
if: github.event.inputs.skip_tests != 'true' && matrix.platform != 'manylinux_2_17_aarch64'
shell: bash
run: |
echo "=== Testing binary execution ==="
mkdir -p test-project
echo 'eval("test")' > test-project/test.py
pathfinder --help || echo "Help command test"
echo "[OK] Binary executes successfully"
- name: Verify binary path
if: github.event.inputs.skip_tests != 'true' && matrix.platform != 'manylinux_2_17_aarch64'
shell: bash
run: |
echo "=== Verifying bundled binary ==="
python -c "from pathlib import Path; import codepathfinder.cli as cli; binary_path = cli.get_binary_path(); print(f'Binary path: {binary_path}'); print(f'Binary exists: {Path(binary_path).exists()}'); print('[OK] Binary verification complete')"
build-sdist:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Install build tools
run: pip install build
- name: Build sdist (no binary - will download on install)
run: |
cd python-sdk
python -m build --sdist
- name: Upload sdist
uses: actions/upload-artifact@v4
with:
name: sdist
path: python-sdk/dist/*.tar.gz
retention-days: 7
publish:
needs: [build-wheels, build-sdist]
runs-on: ubuntu-latest
steps:
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: dist-temp
- name: Prepare dist directory
run: |
mkdir -p dist
find dist-temp -name '*.whl' -o -name '*.tar.gz' | xargs -I {} mv {} dist/
ls -la dist/
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
packages-dir: dist/
password: ${{ secrets.PYPI_API_TOKEN }}