-
Notifications
You must be signed in to change notification settings - Fork 4
132 lines (114 loc) · 4.78 KB
/
Copy pathtest-publish.yml
File metadata and controls
132 lines (114 loc) · 4.78 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
name: Test Publish to TestPyPI
on:
workflow_dispatch:
inputs:
version:
description: 'Version to test (optional - uses current version if empty)'
required: false
type: string
permissions:
contents: read
jobs:
test-build-and-publish:
name: Test Build and Publish to TestPyPI
runs-on: ubuntu-latest
environment: testpypi
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.11"
- name: Install build dependencies
run: |
python -m pip install --upgrade pip
pip install build twine
- name: Extract version from pyproject.toml
id: version
run: |
VERSION=$(python -c "import tomllib; print(tomllib.load(open('pyproject.toml', 'rb'))['project']['version'])")
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "Building version: $VERSION"
- name: Build package
run: |
python -m build
echo "Built packages:"
ls -la dist/
- name: Check package metadata
run: |
twine check dist/*
echo "✅ Package metadata is valid"
- name: Verify package contents
run: |
python -c "
import zipfile
import sys
try:
with zipfile.ZipFile('dist/ccnotify-${{ steps.version.outputs.version }}-py3-none-any.whl', 'r') as z:
files = [f for f in z.namelist() if f.startswith('ccnotify/')]
print(f'📦 Package contains {len(files)} files')
for f in sorted(files)[:10]: # Show first 10 files
print(f' {f}')
if len(files) > 10:
print(f' ... and {len(files) - 10} more files')
except Exception as e:
print(f'❌ Error checking package: {e}')
sys.exit(1)
"
- name: Publish to TestPyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: https://test.pypi.org/legacy/
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
print-hash: true
verbose: true
- name: Wait for package availability
run: |
echo "⏳ Waiting 30 seconds for package to become available on TestPyPI..."
sleep 30
- name: Test installation from TestPyPI
run: |
echo "🧪 Testing installation from TestPyPI..."
python -m pip install --upgrade pip
# Install from TestPyPI with fallback to PyPI for dependencies
pip install \
--index-url https://test.pypi.org/simple/ \
--extra-index-url https://pypi.org/simple/ \
ccnotify==${{ steps.version.outputs.version }}
# Test basic functionality
python -c "
import ccnotify
print(f'✅ Successfully imported ccnotify v{ccnotify.__version__}')
# Test version consistency
if ccnotify.__version__ == '${{ steps.version.outputs.version }}':
print('✅ Version matches expected')
else:
print(f'❌ Version mismatch: expected ${{ steps.version.outputs.version }}, got {ccnotify.__version__}')
exit(1)
"
# Test CLI entry point
ccnotify --version
echo "✅ CLI entry point works correctly"
- name: Create test summary
run: |
echo "## 🧪 TestPyPI Publication Summary" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "**Package:** ccnotify" >> $GITHUB_STEP_SUMMARY
echo "**Version:** ${{ steps.version.outputs.version }}" >> $GITHUB_STEP_SUMMARY
echo "**TestPyPI URL:** https://test.pypi.org/project/ccnotify/${{ steps.version.outputs.version }}/" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "### ✅ Tests Passed" >> $GITHUB_STEP_SUMMARY
echo "- Package build successful" >> $GITHUB_STEP_SUMMARY
echo "- Metadata validation passed" >> $GITHUB_STEP_SUMMARY
echo "- TestPyPI upload successful" >> $GITHUB_STEP_SUMMARY
echo "- Installation test passed" >> $GITHUB_STEP_SUMMARY
echo "- CLI functionality verified" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "### 🚀 Ready for Production" >> $GITHUB_STEP_SUMMARY
echo "This version has been tested and is ready for production PyPI publishing." >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "### Test Installation" >> $GITHUB_STEP_SUMMARY
echo '```bash' >> $GITHUB_STEP_SUMMARY
echo "pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/ ccnotify==${{ steps.version.outputs.version }}" >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY