| 1 |
name: Build and Publish IPython |
| 2 |
|
| 3 |
on: |
| 4 |
push: |
| 5 |
tags: |
| 6 |
- '*' |
| 7 |
workflow_dispatch: |
| 8 |
|
| 9 |
jobs: |
| 10 |
build-and-publish: |
| 11 |
name: Build and Publish to PyPI |
| 12 |
runs-on: ubuntu-latest |
| 13 |
environment: |
| 14 |
name: pypi |
| 15 |
url: https://pypi.org/p/ipython |
| 16 |
permissions: |
| 17 |
id-token: write # IMPORTANT: mandatory for trusted publishing |
| 18 |
|
| 19 |
steps: |
| 20 |
- uses: actions/checkout@v6 |
| 21 |
|
| 22 |
- name: Set up Python |
| 23 |
uses: actions/setup-python@v6 |
| 24 |
with: |
| 25 |
python-version: "3.14" |
| 26 |
cache: pip |
| 27 |
cache-dependency-path: | |
| 28 |
pyproject.toml |
| 29 |
|
| 30 |
- name: Install build dependencies |
| 31 |
run: | |
| 32 |
python -m pip install --upgrade pip |
| 33 |
python -m pip install build |
| 34 |
|
| 35 |
- name: Build distribution |
| 36 |
run: python -m build |
| 37 |
|
| 38 |
- name: Verify built version matches tag |
| 39 |
if: startsWith(github.ref, 'refs/tags/') |
| 40 |
run: | |
| 41 |
TAG_NAME=${GITHUB_REF#refs/tags/} |
| 42 |
echo "Tag name: $TAG_NAME" |
| 43 |
|
| 44 |
# Check dist folder filenames |
| 45 |
echo "Built distribution files:" |
| 46 |
ls -la dist/ |
| 47 |
|
| 48 |
# Install the built wheel |
| 49 |
python -m pip install dist/*.whl |
| 50 |
|
| 51 |
# Get IPython version |
| 52 |
IPYTHON_VERSION=$(ipython --version) |
| 53 |
echo "Installed IPython version: $IPYTHON_VERSION" |
| 54 |
|
| 55 |
# Compare versions (allow only X.Y.Z) |
| 56 |
if [[ "$TAG_NAME" != "$IPYTHON_VERSION" ]]; then |
| 57 |
echo "Error: Tag ($TAG_NAME) does not match built IPython version ($IPYTHON_VERSION)" |
| 58 |
exit 1 |
| 59 |
fi |
| 60 |
|
| 61 |
echo "Version check passed! Tag matches built version." |
| 62 |
|
| 63 |
- name: Publish distribution to PyPI |
| 64 |
if: startsWith(github.ref, 'refs/tags/') |
| 65 |
uses: pypa/[email protected] |
| 66 |
|
| 67 |
- name: Send Zulip notification |
| 68 |
if: startsWith(github.ref, 'refs/tags/') |
| 69 |
uses: zulip/github-actions-zulip/send-message@v1 |
| 70 |
with: |
| 71 |
api-key: ${{ secrets.ZULIP_API_KEY }} |
| 72 |
email: ${{ secrets.ZULIP_EMAIL }} |
| 73 |
organization-url: ${{ vars.ZULIP_ORGANIZATION_URL }} |
| 74 |
to: 'Releases' |
| 75 |
type: 'stream' |
| 76 |
topic: 'IPython' |
| 77 |
content: | |
| 78 |
IPython ${{ github.ref_name }} was just released on PyPI! 🎉 |
| 79 |
https://pypi.org/project/ipython/${{ github.ref_name }}/ |