Skip to content

v0.4.3 Publish to PyPI #1

v0.4.3 Publish to PyPI

v0.4.3 Publish to PyPI #1

Workflow file for this run

name: Release
on:
release:
types: [published]
permissions:
contents: write
id-token: write # For trusted publishing to PyPI
jobs:
publish:
name: Build and Publish to PyPI
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: "20"
cache: "npm"
cache-dependency-path: frontend/package-lock.json
- name: Extract version from tag
id: get_version
run: |
# Get the tag name from the release
TAG="${{ github.event.release.tag_name }}"
# Remove 'v' prefix if present
VERSION="${TAG#v}"
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
echo "TAG=$TAG" >> $GITHUB_OUTPUT
echo "Release version: $VERSION (from tag: $TAG)"
- name: Verify package version matches tag
run: |
# Extract version from pyproject.toml
PACKAGE_VERSION=$(python -c "import tomllib; print(tomllib.load(open('pyproject.toml', 'rb'))['project']['version'])")
echo "Package version: $PACKAGE_VERSION"
echo "Tag version: ${{ steps.get_version.outputs.VERSION }}"
if [ "$PACKAGE_VERSION" != "${{ steps.get_version.outputs.VERSION }}" ]; then
echo "Error: Package version ($PACKAGE_VERSION) doesn't match tag version (${{ steps.get_version.outputs.VERSION }})"
echo "Please update the version in pyproject.toml to match the release tag"
exit 1
fi
- name: Install frontend dependencies
run: |
cd frontend
npm ci
- name: Build frontend
run: |
cd frontend
npm run build
echo "Frontend build completed"
ls -la ../mcphawk/web/static/assets/
- name: Install Python build dependencies
run: |
python -m pip install --upgrade pip
pip install build twine
- name: Build Python package
run: |
python -m build
echo "Built packages:"
ls -la dist/
- name: Check package with twine
run: |
twine check dist/*
- name: Publish to PyPI
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
run: |
twine upload dist/*
- name: Upload release assets
uses: softprops/action-gh-release@v1
with:
files: |
dist/*.whl
dist/*.tar.gz
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Post-release summary
run: |
echo "### 🎉 Release Published Successfully!"
echo ""
echo "**Version:** ${{ steps.get_version.outputs.VERSION }}"
echo "**Tag:** ${{ steps.get_version.outputs.TAG }}"
echo ""
echo "**PyPI:** https://pypi.org/project/mcphawk/${{ steps.get_version.outputs.VERSION }}/"
echo ""
echo "**Artifacts:**"
ls -lh dist/
echo ""
echo "Install with: \`pip install mcphawk==${{ steps.get_version.outputs.VERSION }}\`"