|
8 | 8 | branches: [ master ] |
9 | 9 | pull_request: |
10 | 10 | branches: [ master ] |
| 11 | + tags: |
| 12 | + - ['v*'] |
11 | 13 |
|
12 | 14 | jobs: |
13 | | - build: |
14 | | - |
| 15 | + test: |
15 | 16 | runs-on: ${{ matrix.os }} |
16 | 17 | strategy: |
17 | 18 | matrix: |
|
49 | 50 | run: | |
50 | 51 | pip install pytest |
51 | 52 | pytest |
| 53 | +
|
| 54 | + build-for-publish: |
| 55 | + name: Build distribution 📦 |
| 56 | + runs-on: ubuntu-latest |
| 57 | + # if: "startsWith(github.ref, 'refs/tags')" |
| 58 | + needs: test |
| 59 | + steps: |
| 60 | + - uses: actions/checkout@v4 |
| 61 | + with: |
| 62 | + fetch-depth: 0 |
| 63 | + submodules: true |
| 64 | + - name: Set up Python |
| 65 | + uses: actions/setup-python@v5 |
| 66 | + with: |
| 67 | + python-version: '3.11' |
| 68 | + |
| 69 | + - name: Install dependencies |
| 70 | + run: | |
| 71 | + python -m pip install --upgrade build |
| 72 | +
|
| 73 | + - name: Build a source tarball and wheel |
| 74 | + run: python -m build . |
| 75 | + |
| 76 | + - name: Store the distribution packages |
| 77 | + uses: actions/upload-artifact@v4 |
| 78 | + with: |
| 79 | + name: python-package-distributions |
| 80 | + path: dist/ |
| 81 | + |
| 82 | + publish-to-pypi: |
| 83 | + name: >- |
| 84 | + Publish Python 🐍 distribution 📦 to PyPI |
| 85 | + if: startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes |
| 86 | + needs: |
| 87 | + - build-for-publish |
| 88 | + runs-on: ubuntu-latest |
| 89 | + environment: |
| 90 | + name: pypi |
| 91 | + url: https://pypi.org/p/pyopenjtalk |
| 92 | + permissions: |
| 93 | + id-token: write # IMPORTANT: mandatory for trusted publishing |
| 94 | + steps: |
| 95 | + - name: Download all the dists |
| 96 | + uses: actions/download-artifact@v4 |
| 97 | + with: |
| 98 | + name: python-package-distributions |
| 99 | + path: dist/ |
| 100 | + - name: Publish distribution 📦 to PyPI |
| 101 | + uses: pypa/gh-action-pypi-publish@release/v1 |
| 102 | + |
| 103 | + publish-to-testpypi: |
| 104 | + name: Publish Python 🐍 distribution 📦 to TestPyPI |
| 105 | + needs: |
| 106 | + - build-for-publish |
| 107 | + runs-on: ubuntu-latest |
| 108 | + |
| 109 | + environment: |
| 110 | + name: testpypi |
| 111 | + url: https://test.pypi.org/p/pyopenjtalk |
| 112 | + |
| 113 | + permissions: |
| 114 | + id-token: write # IMPORTANT: mandatory for trusted publishing |
| 115 | + |
| 116 | + steps: |
| 117 | + - name: Download all the dists |
| 118 | + uses: actions/download-artifact@v4 |
| 119 | + with: |
| 120 | + name: python-package-distributions |
| 121 | + path: dist/ |
| 122 | + - name: Publish distribution 📦 to TestPyPI |
| 123 | + uses: pypa/gh-action-pypi-publish@release/v1 |
| 124 | + with: |
| 125 | + repository-url: https://test.pypi.org/legacy/ |
0 commit comments