ci: Add publishing workflow. #1
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 to PyPI (Tag Release) | |
| on: | |
| push: | |
| # branches: ["main"] | |
| tags: | |
| - 'v*' # Runs when a tag like v1.2.3 is pushed | |
| permissions: | |
| contents: read | |
| jobs: | |
| build_wheels: | |
| name: Build wheels | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: false | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| submodules: recursive | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.13" | |
| - name: Install Poetry | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install poetry | |
| - name: Configure Poetry | |
| run: poetry config virtualenvs.create true && poetry lock | |
| - name: Install dependencies | |
| run: poetry install --no-interaction --no-root --with dev | |
| - name: Check formatting | |
| run: | | |
| poetry run black --check $(find hipopy/ -name '*.py') $(find tests/ -name '*.py') | |
| poetry run pylint $(find hipopy/ -name '*.py') | |
| - name: Build package wheel | |
| run: | | |
| poetry build | |
| - name: Upload built wheels | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: wheels | |
| path: dist/*.whl | |
| publish_testpypi: | |
| name: Publish to TestPyPI | |
| needs: build_wheels | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| submodules: recursive | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.13" | |
| - uses: actions/download-artifact@v4 | |
| with: | |
| path: dist | |
| - name: Upload to TestPyPI | |
| run: | | |
| pip install --upgrade pip poetry | |
| ls -lrth dist | |
| mkdir -p dist_flat | |
| cp dist/**/*.whl dist_flat/ | |
| rm -rf dist | |
| mv dist_flat dist | |
| ls -lrth dist | |
| poetry config repositories.testpypi https://test.pypi.org/legacy/ | |
| echo poetry publish -r testpypi -u __token__ -p ${{ secrets.TESTPYPI_API_TOKEN }} | |
| publish: | |
| name: Publish to PyPI | |
| needs: publish_testpypi | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| submodules: recursive | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.13" | |
| - name: Download distributions | |
| uses: actions/download-artifact@v4 | |
| with: | |
| path: dist | |
| - uses: actions/download-artifact@v4 | |
| with: | |
| path: dist | |
| - name: Upload to PyPI | |
| run: | | |
| pip install --upgrade pip poetry | |
| mkdir -p dist_flat | |
| cp dist/**/*.whl dist_flat/ | |
| rm -rf dist | |
| mv dist_flat dist | |
| ls -lrth dist | |
| echo poetry publish -u __token__ -p ${{ secrets.PYPI_API_TOKEN }} |