v4.1.0.1 #5
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Publish to PyPI | |
| on: | |
| # Trigger on new releases | |
| release: | |
| types: [published] | |
| # Allow manual triggering | |
| workflow_dispatch: | |
| inputs: | |
| target: | |
| description: 'Publication target' | |
| required: true | |
| default: 'testpypi' | |
| type: choice | |
| options: | |
| - testpypi | |
| - pypi | |
| # Restrict permissions for security | |
| permissions: | |
| contents: read | |
| jobs: | |
| build-and-publish: | |
| name: Build and publish Python package | |
| runs-on: ubuntu-latest | |
| environment: | |
| name: ${{ github.event_name == 'release' && 'pypi' || 'testpypi' }} | |
| url: ${{ github.event_name == 'release' && 'https://pypi.org/p/SuperGemini' || 'https://test.pypi.org/p/SuperGemini' }} | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| # Fetch full history for proper version detection | |
| fetch-depth: 0 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.11' | |
| cache: 'pip' | |
| - name: Install build dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| python -m pip install build twine | |
| - name: Verify package structure | |
| run: | | |
| echo "π¦ Checking package structure..." | |
| ls -la | |
| echo "π Checking SuperGemini package..." | |
| ls -la SuperGemini/ | |
| echo "π Checking setup package..." | |
| ls -la setup/ | |
| # Verify VERSION file exists | |
| echo "π Checking VERSION file..." | |
| if [ -f "VERSION" ]; then | |
| echo "VERSION file content:" | |
| cat VERSION | |
| else | |
| echo "β VERSION file not found!" | |
| exit 1 | |
| fi | |
| # Verify package can be imported | |
| echo "π Testing package import..." | |
| python -c " | |
| import sys | |
| sys.path.insert(0, '.') | |
| import SuperGemini | |
| print(f'β SuperGemini package imported successfully') | |
| " | |
| - name: Clean previous builds | |
| run: | | |
| rm -rf dist/ build/ *.egg-info/ | |
| - name: Build package | |
| run: | | |
| echo "π¨ Building package..." | |
| python -m build | |
| echo "π¦ Built files:" | |
| ls -la dist/ | |
| - name: Validate package | |
| run: | | |
| echo "π Validating package..." | |
| python -m twine check dist/* | |
| # Upload to TestPyPI for testing (manual trigger or non-release) | |
| - name: Upload to TestPyPI | |
| if: github.event_name == 'workflow_dispatch' && github.event.inputs.target == '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 | |
| # Upload to production PyPI (only on releases) | |
| - name: Upload to PyPI | |
| if: github.event_name == 'release' || (github.event_name == 'workflow_dispatch' && github.event.inputs.target == 'pypi') | |
| uses: pypa/gh-action-pypi-publish@release/v1 | |
| with: | |
| password: ${{ secrets.PYPI_API_TOKEN }} | |
| print-hash: true | |
| - name: Create deployment summary | |
| if: always() | |
| run: | | |
| echo "## π¦ SuperGemini Package Deployment" >> $GITHUB_STEP_SUMMARY | |
| echo "| Property | Value |" >> $GITHUB_STEP_SUMMARY | |
| echo "|----------|-------|" >> $GITHUB_STEP_SUMMARY | |
| echo "| Target | ${{ github.event_name == 'release' && 'PyPI (Production)' || github.event.inputs.target || 'TestPyPI' }} |" >> $GITHUB_STEP_SUMMARY | |
| echo "| Trigger | ${{ github.event_name }} |" >> $GITHUB_STEP_SUMMARY | |
| echo "| Version | $(cat VERSION 2>/dev/null || echo 'Unknown') |" >> $GITHUB_STEP_SUMMARY | |
| echo "| Commit | ${{ github.sha }} |" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| if [ "${{ github.event_name }}" == "release" ]; then | |
| echo "π **Production release published to PyPI!**" >> $GITHUB_STEP_SUMMARY | |
| echo "Install with: \`pip install SuperGemini\`" >> $GITHUB_STEP_SUMMARY | |
| else | |
| echo "π§ͺ **Test release published to TestPyPI**" >> $GITHUB_STEP_SUMMARY | |
| echo "Test install with: \`pip install --index-url https://test.pypi.org/simple/ SuperGemini\`" >> $GITHUB_STEP_SUMMARY | |
| fi | |
| test-installation: | |
| name: Test package installation | |
| needs: build-and-publish | |
| runs-on: ubuntu-latest | |
| if: github.event_name == 'workflow_dispatch' && github.event.inputs.target == 'testpypi' | |
| steps: | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.11' | |
| - name: Test installation from TestPyPI | |
| run: | | |
| echo "π§ͺ Testing installation from TestPyPI..." | |
| # Wait a bit for the package to be available | |
| sleep 30 | |
| # Install from TestPyPI | |
| pip install --index-url https://test.pypi.org/simple/ \ | |
| --extra-index-url https://pypi.org/simple/ \ | |
| SuperGemini | |
| # Test basic import | |
| python -c " | |
| import SuperGemini | |
| print(f'β Successfully imported SuperGemini') | |
| # Test CLI entry points | |
| import subprocess | |
| # Test SuperGemini command | |
| try: | |
| result = subprocess.run(['SuperGemini', '--help'], capture_output=True, text=True, timeout=10) | |
| print(f'β SuperGemini CLI available') | |
| except Exception as e: | |
| print(f'β οΈ SuperGemini CLI test: {e}') | |
| # Test supergemini command | |
| try: | |
| result = subprocess.run(['supergemini', '--help'], capture_output=True, text=True, timeout=10) | |
| print(f'β supergemini CLI available') | |
| except Exception as e: | |
| print(f'β οΈ supergemini CLI test: {e}') | |
| # Test sg command | |
| try: | |
| result = subprocess.run(['sg', '--help'], capture_output=True, text=True, timeout=10) | |
| print(f'β sg CLI available') | |
| except Exception as e: | |
| print(f'β οΈ sg CLI test: {e}') | |
| " | |
| echo "β Installation test completed successfully!" |