tests: ensures magics get registered correctly #4
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
name: Publish Python 🐍 distribution 📦 to PyPI and TestPyPI | |
on: | |
push: | |
tags: | |
- "[0-9]+.[0-9]+.[0-9]+" | |
jobs: | |
test: | |
name: Run Tests 🧪 | |
uses: ./.github/workflows/test.yml | |
build: | |
name: Build distribution 📦 | |
needs: test | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
persist-credentials: false | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: "3.9" | |
- name: Install pypa/build | |
run: >- | |
python3 -m | |
pip install | |
build | |
--user | |
- name: Build a binary wheel and a source tarball | |
run: python3 -m build | |
- name: Store the distribution packages | |
uses: actions/upload-artifact@v4 | |
with: | |
name: python-package-distributions | |
path: dist/ | |
publish-to-pypi: | |
name: >- | |
Publish Python 🐍 distribution 📦 to PyPI | |
needs: | |
- build | |
runs-on: ubuntu-latest | |
environment: | |
name: pypi | |
url: https://pypi.org/p/patchimport-magic | |
permissions: | |
id-token: write | |
steps: | |
- name: Download all the dists | |
uses: actions/download-artifact@v4 | |
with: | |
name: python-package-distributions | |
path: dist/ | |
- name: Validate that filenames version matches the tag | |
run: | | |
# Extract the bare tag (e.g. "1.2.3") from GITHUB_REF | |
version=${GITHUB_REF#refs/tags/} | |
echo "Validating distribution filenames contain version $version" | |
for file in dist/*; do | |
if [[ "$file" != *"$version"* ]]; then | |
echo "::error file=$file::Filename does not contain version $version" | |
exit 1 | |
fi | |
done | |
- name: Publish distribution 📦 to PyPI | |
uses: pypa/gh-action-pypi-publish@release/v1 |