build: release 0.0.1 #1
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
| # Copyright (c) 2025 Vantage Compute Corporation. | |
| name: Build and Release | |
| on: | |
| push: | |
| tags: | |
| - "[0-9]+.[0-9]+.[0-9]+" | |
| - "[0-9]+.[0-9]+.[0-9]+-alpha.[0-9]+" | |
| - "[0-9]+.[0-9]+.[0-9]+-beta.[0-9]+" | |
| - "[0-9]+.[0-9]+.[0-9]+a[0-9]+" | |
| - "[0-9]+.[0-9]+.[0-9]+b[0-9]+" | |
| - "[0-9]+.[0-9]+.[0-9]+rc[0-9]+" | |
| workflow_dispatch: # Allow manual triggering | |
| permissions: | |
| contents: write # Required for creating releases | |
| id-token: write # Required for PyPI trusted publishing | |
| jobs: | |
| build: | |
| name: Build Distribution | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 # Fetch full history for proper version detection | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.12' | |
| - name: Install system dependencies | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y build-essential | |
| sudo snap install astral-uv --classic | |
| - name: Install git-cliff | |
| run: | | |
| curl -L https://github.com/orhun/git-cliff/releases/download/v2.10.0/git-cliff-2.10.0-x86_64-unknown-linux-gnu.tar.gz | tar xz | |
| sudo mv git-cliff-*/git-cliff /usr/local/bin/ | |
| git-cliff --version | |
| - name: Build Python package | |
| run: | | |
| uv build | |
| - name: Check build artifacts | |
| run: | | |
| ls -la dist/ | |
| # Basic validation - ensure files exist | |
| test -n "$(find dist -name '*.whl')" || (echo "No wheel files found" && exit 1) | |
| test -n "$(find dist -name '*.tar.gz')" || (echo "No source distribution found" && exit 1) | |
| - name: Upload build artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: distribution-files | |
| path: dist/ | |
| retention-days: 7 | |
| test-install: | |
| name: Test Installation | |
| needs: build | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| python-version: ['3.12', '3.13'] | |
| steps: | |
| - name: Set up Python ${{ matrix.python-version }} | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: ${{ matrix.python-version }} | |
| - name: Download build artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: distribution-files | |
| path: dist/ | |
| - name: Test wheel installation | |
| run: | | |
| sudo snap install astral-uv --classic | |
| uv venv | |
| uv pip install dist/*.whl | |
| uv run python3 -c "import cudo_compute_sdk; print('Package imported successfully')" | |
| publish-pypi: | |
| name: Publish to PyPI | |
| needs: [build, test-install] | |
| runs-on: ubuntu-latest | |
| if: startsWith(github.ref, 'refs/tags/') | |
| environment: | |
| name: pypi | |
| url: https://pypi.org/p/cudo-compute-sdk | |
| steps: | |
| - name: Download build artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: distribution-files | |
| path: dist/ | |
| - name: Publish to PyPI | |
| run: | | |
| sudo snap install astral-uv --classic | |
| uv publish | |
| create-release: | |
| name: Create GitHub Release | |
| needs: [build, test-install] | |
| runs-on: ubuntu-latest | |
| if: startsWith(github.ref, 'refs/tags/') | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Download build artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: distribution-files | |
| path: dist/ | |
| - name: Extract version from tag | |
| id: get_version | |
| run: | | |
| VERSION=${GITHUB_REF#refs/tags/} | |
| echo "version=$VERSION" >> $GITHUB_OUTPUT | |
| echo "tag=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT | |
| - name: Generate release notes | |
| id: release_notes | |
| run: | | |
| # Extract release notes from CHANGELOG.md if it exists | |
| if [ -f "CHANGELOG.md" ]; then | |
| # Try to extract notes for this version using git-cliff for consistency | |
| VERSION="${{ steps.get_version.outputs.version }}" | |
| # Use git-cliff to generate notes for this specific version | |
| git-cliff --latest --strip header --strip footer > release_notes.txt || true | |
| # If that fails, fall back to grep method | |
| if [ ! -s release_notes.txt ]; then | |
| grep -A 1000 "^## .*${VERSION}" CHANGELOG.md | grep -B 1000 -m 2 "^## " | head -n -1 | tail -n +2 > release_notes.txt || true | |
| fi | |
| # If no specific version notes found, create generic notes | |
| if [ ! -s release_notes.txt ]; then | |
| echo "Release ${{ steps.get_version.outputs.tag }}" > release_notes.txt | |
| echo "" >> release_notes.txt | |
| echo "### Changes" >> release_notes.txt | |
| echo "- See CHANGELOG.md for detailed changes" >> release_notes.txt | |
| fi | |
| else | |
| echo "Release ${{ steps.get_version.outputs.tag }}" > release_notes.txt | |
| echo "" >> release_notes.txt | |
| echo "### Files" >> release_notes.txt | |
| echo "- Source distribution (tar.gz)" >> release_notes.txt | |
| echo "- Wheel distribution (.whl)" >> release_notes.txt | |
| fi | |
| echo "Release notes:" | |
| cat release_notes.txt | |
| - name: Create Release | |
| uses: softprops/action-gh-release@v1 | |
| with: | |
| name: Release ${{ steps.get_version.outputs.tag }} | |
| body_path: release_notes.txt | |
| files: | | |
| dist/*.tar.gz | |
| dist/*.whl | |
| draft: false | |
| prerelease: ${{ contains(steps.get_version.outputs.version, 'rc') || contains(steps.get_version.outputs.version, 'beta') || contains(steps.get_version.outputs.version, 'alpha') }} | |
| generate_release_notes: true | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| notify-success: | |
| name: Notify Success | |
| needs: [publish-pypi, create-release] | |
| runs-on: ubuntu-latest | |
| if: success() && startsWith(github.ref, 'refs/tags/') | |
| steps: | |
| - name: Extract version from tag | |
| id: get_version | |
| run: | | |
| VERSION=${GITHUB_REF#refs/tags/} | |
| echo "version=$VERSION" >> $GITHUB_OUTPUT | |
| echo "tag=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT | |
| - name: Success notification | |
| run: | | |
| echo "🎉 Successfully released cudo-compute-sdk ${{ steps.get_version.outputs.tag }}" | |
| echo "📦 Published to PyPI: https://pypi.org/project/cudo-compute-sdk/${{ steps.get_version.outputs.version }}/" | |
| echo "🚀 GitHub Release: ${{ github.server_url }}/${{ github.repository }}/releases/tag/${{ steps.get_version.outputs.tag }}" |