update workflow #1
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
| # GitHub Actions workflow for building and publishing txaio wheels. | ||
| name: wheels | ||
| on: | ||
| # Build wheels on feature branches and PRs (test only) | ||
| push: | ||
| branches: ["**"] | ||
| pull_request: | ||
| branches: [master] | ||
| # Publish to GitHub Releases when merged to master OR | ||
| # Publish to PyPI when tagged | ||
| workflow_dispatch: | ||
| env: | ||
| # Ensure uv and just are available in PATH | ||
| UV_CACHE_DIR: ${{ github.workspace }}/.uv-cache | ||
| jobs: | ||
| build-package: | ||
| name: Build wheels and source distribution | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@v4 | ||
| - name: Install Just | ||
| env: | ||
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| run: | | ||
| curl --proto '=https' --tlsv1.2 -sSf https://just.systems/install.sh | bash -s -- --to ~/bin | ||
| echo "$HOME/bin" >> $GITHUB_PATH | ||
| - name: Install uv | ||
| env: | ||
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| run: | | ||
| curl -LsSf https://astral.sh/uv/install.sh | sh | ||
| source $HOME/.cargo/env | ||
| echo "$HOME/.cargo/bin" >> $GITHUB_PATH | ||
| - name: Verify toolchain | ||
| run: | | ||
| export PATH="/root/.cargo/bin:$PATH" | ||
| echo "==> Build environment summary:" | ||
| echo "Just: $(just --version)" | ||
| echo "uv: $(uv --version)" | ||
| echo "Rust: $(rustc --version)" | ||
| echo "Python: $(python3 --version)" | ||
| echo "GCC: $(gcc --version | head -1)" | ||
| echo "glibc: $(ldd --version 2>/dev/null | head -1 || echo 'N/A')" | ||
| - name: Build package (wheel and source distribution on CPython 3.11) | ||
| run: just build cpy311 | ||
| - name: Generate build metadata | ||
| run: | | ||
| mkdir -p dist/ | ||
| cat > dist/build-info.txt << EOF | ||
| Build Information for ${{ matrix.target.name }} | ||
| ============================================= | ||
| Build Date: $(date -u +"%Y-%m-%d %H:%M:%S UTC") | ||
| Container: ${{ matrix.target.base_image }} | ||
| Platform: AMD64 | ||
| Build Method: GitHub Actions + Docker Container | ||
| System Information: | ||
| - OS: $(cat /etc/os-release | grep PRETTY_NAME | cut -d'"' -f2) | ||
| - Kernel: $(uname -r) | ||
| - glibc: $(ldd --version 2>/dev/null | head -1 || echo 'N/A') | ||
| Build Tools: | ||
| - Just: $(just --version) | ||
| - uv: $(uv --version) | ||
| - Rust: $(rustc --version) | ||
| - Python: $(python3 --version) | ||
| - GCC: $(gcc --version | head -1) | ||
| EOF | ||
| - name: List build artifacts | ||
| run: | | ||
| echo "==> Built package artifacts:" | ||
| ls -la dist/ 2>/dev/null || echo "No dist/ directory found" | ||
| echo "" | ||
| echo "==> Build metadata:" | ||
| cat dist/build-info.txt 2>/dev/null || echo "No build info found" | ||
| - name: Upload build artifacts | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: build-artifacts | ||
| path: dist/* | ||
| retention-days: 30 | ||
| publish-github-releases: | ||
| name: Publish to GitHub Releases | ||
| needs: build-package | ||
| runs-on: ubuntu-latest | ||
| # Publish to GitHub Releases when merged to master | ||
| if: github.ref == 'refs/heads/master' && github.event_name == 'push' | ||
| steps: | ||
| - name: Download build artifacts | ||
| uses: actions/download-artifact@v4 | ||
| with: | ||
| name: build-artifacts | ||
| path: dist/ | ||
| - name: List all artifacts | ||
| run: | | ||
| echo "All built artifacts:" | ||
| ls -la dist/ | ||
| echo "" | ||
| echo "Wheel count: $(ls dist/*.whl | wc -l)" | ||
| echo "Source distributions: $(ls dist/*.tar.gz | wc -l)" | ||
| - name: Create GitHub Release | ||
| env: | ||
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| run: | | ||
| # Generate release tag based on timestamp and commit | ||
| RELEASE_TAG="wheels-$(date +'%Y%m%d')-${{ GITHUB_SHA::8 }}" | ||
| # Create release | ||
| gh release create "$RELEASE_TAG" \ | ||
| --repo "$GITHUB_REPOSITORY" \ | ||
| --title "Wheels Build - $(date +'%Y-%m-%d')" \ | ||
| --notes "Automated wheel build from commit ${{ GITHUB_SHA::8 }}" \ | ||
| dist/* | ||
| publish-pypi: | ||
| name: Publish to PyPI | ||
| needs: build-package | ||
| runs-on: ubuntu-latest | ||
| # Publish to PyPI when tagged | ||
| if: startsWith(github.ref, 'refs/tags/') && github.event_name == 'push' | ||
| environment: | ||
| name: pypi | ||
| url: https://pypi.org/p/txaio | ||
| permissions: | ||
| id-token: write # IMPORTANT: this permission is mandatory for trusted publishing | ||
| steps: | ||
| - name: Download distribution package | ||
| uses: actions/download-artifact@v4 | ||
| with: | ||
| name: build-artifacts | ||
| path: dist/ | ||
| - name: List all artifacts | ||
| run: | | ||
| echo "All built artifacts:" | ||
| ls -la dist/ | ||
| echo "" | ||
| echo "Wheel count: $(ls dist/*.whl | wc -l)" | ||
| echo "Source distributions: $(ls dist/*.tar.gz | wc -l)" | ||
| - name: Publish package to PyPI | ||
| uses: pypa/gh-action-pypi-publish@release/v1 | ||
| with: | ||
| verbose: true | ||
| attestations: true | ||
| print-hash: true | ||