|
| 1 | +name: Publish to PyPI (Tag Release) |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + # branches: ["main"] |
| 6 | + tags: |
| 7 | + - 'v*' # Runs when a tag like v1.2.3 is pushed |
| 8 | + |
| 9 | +permissions: |
| 10 | + contents: read |
| 11 | + |
| 12 | +jobs: |
| 13 | + build_wheels: |
| 14 | + name: Build wheels |
| 15 | + runs-on: ubuntu-latest |
| 16 | + |
| 17 | + strategy: |
| 18 | + fail-fast: false |
| 19 | + |
| 20 | + steps: |
| 21 | + - name: Checkout repository |
| 22 | + uses: actions/checkout@v4 |
| 23 | + with: |
| 24 | + submodules: recursive |
| 25 | + |
| 26 | + - name: Set up Python |
| 27 | + uses: actions/setup-python@v5 |
| 28 | + with: |
| 29 | + python-version: "3.13" |
| 30 | + |
| 31 | + - name: Install Poetry |
| 32 | + run: | |
| 33 | + python -m pip install --upgrade pip |
| 34 | + pip install poetry |
| 35 | +
|
| 36 | + - name: Configure Poetry |
| 37 | + run: poetry config virtualenvs.create true && poetry lock |
| 38 | + |
| 39 | + - name: Install dependencies |
| 40 | + run: poetry install --no-interaction --no-root --with dev |
| 41 | + |
| 42 | + - name: Check formatting |
| 43 | + run: | |
| 44 | + poetry run black --check $(find hipopy/ -name '*.py') $(find tests/ -name '*.py') |
| 45 | + poetry run pylint $(find hipopy/ -name '*.py') |
| 46 | +
|
| 47 | + - name: Build package wheel |
| 48 | + run: | |
| 49 | + poetry build |
| 50 | +
|
| 51 | + - name: Upload built wheels |
| 52 | + uses: actions/upload-artifact@v4 |
| 53 | + with: |
| 54 | + name: wheels |
| 55 | + path: dist/*.whl |
| 56 | + |
| 57 | + publish_testpypi: |
| 58 | + name: Publish to TestPyPI |
| 59 | + needs: build_wheels |
| 60 | + runs-on: ubuntu-latest |
| 61 | + steps: |
| 62 | + - name: Checkout repository |
| 63 | + uses: actions/checkout@v4 |
| 64 | + with: |
| 65 | + submodules: recursive |
| 66 | + |
| 67 | + - name: Set up Python |
| 68 | + uses: actions/setup-python@v5 |
| 69 | + with: |
| 70 | + python-version: "3.13" |
| 71 | + |
| 72 | + - uses: actions/download-artifact@v4 |
| 73 | + with: |
| 74 | + path: dist |
| 75 | + - name: Upload to TestPyPI |
| 76 | + run: | |
| 77 | + pip install --upgrade pip poetry |
| 78 | + ls -lrth dist |
| 79 | + mkdir -p dist_flat |
| 80 | + cp dist/**/*.whl dist_flat/ |
| 81 | + rm -rf dist |
| 82 | + mv dist_flat dist |
| 83 | + ls -lrth dist |
| 84 | + poetry config repositories.testpypi https://test.pypi.org/legacy/ |
| 85 | + echo poetry publish -r testpypi -u __token__ -p ${{ secrets.TESTPYPI_API_TOKEN }} |
| 86 | +
|
| 87 | + publish: |
| 88 | + name: Publish to PyPI |
| 89 | + needs: publish_testpypi |
| 90 | + runs-on: ubuntu-latest |
| 91 | + steps: |
| 92 | + - name: Checkout repository |
| 93 | + uses: actions/checkout@v4 |
| 94 | + with: |
| 95 | + submodules: recursive |
| 96 | + |
| 97 | + - name: Set up Python |
| 98 | + uses: actions/setup-python@v5 |
| 99 | + with: |
| 100 | + python-version: "3.13" |
| 101 | + |
| 102 | + - name: Download distributions |
| 103 | + uses: actions/download-artifact@v4 |
| 104 | + with: |
| 105 | + path: dist |
| 106 | + |
| 107 | + - uses: actions/download-artifact@v4 |
| 108 | + with: |
| 109 | + path: dist |
| 110 | + - name: Upload to PyPI |
| 111 | + run: | |
| 112 | + pip install --upgrade pip poetry |
| 113 | + mkdir -p dist_flat |
| 114 | + cp dist/**/*.whl dist_flat/ |
| 115 | + rm -rf dist |
| 116 | + mv dist_flat dist |
| 117 | + ls -lrth dist |
| 118 | + echo poetry publish -u __token__ -p ${{ secrets.PYPI_API_TOKEN }} |
0 commit comments