Skip to content

Version: 0.2.18

Version: 0.2.18 #27

Workflow file for this run

name: Release
on:
push:
tags:
- '*'
workflow_dispatch:
inputs:
dry-run:
description: 'Perform a dry run (build packages but do not publish)'
type: boolean
default: false
jobs:
build-htty-core-wheels:
strategy:
fail-fast: false
matrix:
include:
# Linux builds
- os: ubuntu-latest
system: x86_64-linux
build_type: native
- os: ubuntu-latest
system: aarch64-linux
build_type: cross-compiled
# macOS builds
- os: macos-13 # Intel
system: x86_64-darwin
build_type: native
- os: macos-latest # ARM64
system: aarch64-darwin
build_type: native
runs-on: ${{ matrix.os }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Nix
uses: ./.github/actions/setup-nix
- name: Set up QEMU for cross-compilation
if: matrix.build_type == 'cross-compiled'
run: |
echo "Setting up QEMU for cross-compilation"
# Enable emulation for aarch64
docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
# Add aarch64-linux to supported systems
sudo mkdir -p /etc/nix
echo "extra-platforms = aarch64-linux" | sudo tee -a /etc/nix/nix.conf
- name: Build htty-core wheel
run: |
echo "πŸ—οΈ Building htty-core wheel for ${{ matrix.system }}"
if [ "${{ matrix.build_type }}" = "cross-compiled" ]; then
echo "πŸ”€ Cross-compiling for ${{ matrix.system }}"
case "${{ matrix.system }}" in
aarch64-linux)
nix build .#htty-core-wheel-cross-aarch64-linux
;;
*)
echo "❌ Unsupported cross-compilation target: ${{ matrix.system }}"
exit 1
;;
esac
else
echo "🏠 Building htty-core natively for ${{ matrix.system }}"
nix build .#htty-core-wheel
fi
# Copy wheel to dist directory
mkdir -p dist
cp result/*.whl dist/
echo "πŸ“¦ Built wheel:"
ls -la dist/
- name: Test wheel installation (native builds only)
# Only test on native builds since cross-compiled wheels need target architecture
if: matrix.build_type == 'native'
run: |
echo "πŸ§ͺ Testing htty-core wheel installation and functionality"
WHEEL_PATH=$(ls dist/*.whl | head -1)
WHEEL_NAME=$(basename "$WHEEL_PATH")
echo "πŸ“¦ Installing wheel: $WHEEL_NAME"
# Create a clean Python environment for testing wheel installation
python -m venv test_env
source test_env/bin/activate
# Install and test the wheel
pip install --force-reinstall --verbose "$WHEEL_PATH"
echo "πŸ”§ Testing Python import..."
python -c "import htty_core; print('βœ… htty_core import successful')"
echo "πŸ”§ Testing binary availability..."
python -c "import htty_core; print(f'βœ… Binary path: {htty_core.find_ht_binary()}')"
# Clean up
deactivate
rm -rf test_env
echo "πŸŽ‰ htty-core wheel testing complete!"
- name: Upload htty-core wheel
uses: actions/upload-artifact@v4
with:
name: htty-core-wheel-${{ matrix.system }}
path: "dist/*.whl"
build-htty-sdist:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Nix
uses: ./.github/actions/setup-nix
- name: Build htty source distribution
run: |
echo "πŸ“¦ Building htty source distribution"
nix build .#htty-sdist
# Copy sdist to dist directory
mkdir -p dist
cp result/*.tar.gz dist/
echo "πŸ“¦ Built source distribution:"
ls -la dist/
- name: Upload htty sdist
uses: actions/upload-artifact@v4
with:
name: htty-sdist
path: "dist/*.tar.gz"
publish-to-pypi:
needs: [build-htty-core-wheels, build-htty-sdist]
runs-on: ubuntu-latest
environment: release
permissions:
id-token: write # For trusted publishing
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Nix
uses: ./.github/actions/setup-nix
- name: Create packages directory
run: mkdir -p packages/
- name: Download all htty-core wheels
uses: actions/download-artifact@v4
with:
pattern: htty-core-wheel-*
path: packages/
merge-multiple: true
- name: Download htty source distribution
uses: actions/download-artifact@v4
with:
name: htty-sdist
path: packages/
- name: Verify packages for publication
run: |
echo "πŸ“¦ Packages to be published:"
ls -la packages/
# Count packages
HTTY_CORE_WHEELS=$(ls packages/htty_core-*.whl 2>/dev/null | wc -l)
HTTY_SDIST=$(ls packages/htty-*.tar.gz 2>/dev/null | wc -l)
echo " htty-core wheels: $HTTY_CORE_WHEELS"
echo " htty source distributions: $HTTY_SDIST"
# Verify we have expected packages
if [ "$HTTY_CORE_WHEELS" -eq 0 ]; then
echo "❌ ERROR: No htty-core wheels found"
exit 1
fi
if [ "$HTTY_SDIST" -eq 0 ]; then
echo "❌ ERROR: No htty source distribution found"
exit 1
fi
# Expected: 4 htty-core wheels (x86_64-linux, aarch64-linux, x86_64-darwin, aarch64-darwin)
if [ "$HTTY_CORE_WHEELS" -ne 4 ]; then
echo "⚠️ WARNING: Expected 4 htty-core wheels, found $HTTY_CORE_WHEELS"
fi
# Expected: 1 htty source distribution
if [ "$HTTY_SDIST" -ne 1 ]; then
echo "⚠️ WARNING: Expected 1 htty source distribution, found $HTTY_SDIST"
fi
echo "βœ… Package verification complete"
# Show package details
echo "πŸ“‹ Package details:"
for pkg in packages/*; do
echo " $(basename "$pkg") - $(ls -lh "$pkg" | awk '{print $5}')"
done
- name: Publish to PyPI
if: ${{ !inputs.dry-run }}
uses: pypa/gh-action-pypi-publish@release/v1
with:
packages-dir: packages/
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
- name: Dry run complete
if: ${{ inputs.dry-run }}
run: |
echo "🏁 Dry run complete - packages built but not published"
echo ""
echo "πŸ“¦ Built packages:"
ls -la packages/
echo ""
echo "To publish for real, create a release tag or run workflow without dry-run"