|
| 1 | +name: Build and publish to PyPI |
| 2 | + |
| 3 | +on: |
| 4 | + release: |
| 5 | + types: [published] |
| 6 | + |
| 7 | +permissions: |
| 8 | + contents: read |
| 9 | + |
| 10 | +jobs: |
| 11 | + build: |
| 12 | + runs-on: ubuntu-latest |
| 13 | + strategy: |
| 14 | + matrix: |
| 15 | + python-version: ['3.10', '3.11'] |
| 16 | + steps: |
| 17 | + - name: Check out repository |
| 18 | + uses: actions/checkout@v2 |
| 19 | + - name: Set up Python ${{ matrix.python-version }} |
| 20 | + id: setup-python |
| 21 | + uses: actions/setup-python@v2 |
| 22 | + with: |
| 23 | + python-version: ${{ matrix.python-version }} |
| 24 | + - name: Load cached Poetry installation |
| 25 | + id: cached-poetry |
| 26 | + uses: actions/cache@v3 |
| 27 | + with: |
| 28 | + path: ~/.local # the path depends on the OS |
| 29 | + key: poetry-1.4.0-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }} |
| 30 | + - name: Install Poetry |
| 31 | + if: steps.cached-poetry.outputs.cache-hit != 'true' |
| 32 | + uses: snok/install-poetry@v1 |
| 33 | + with: |
| 34 | + version: 1.4.0 |
| 35 | + virtualenvs-create: true |
| 36 | + virtualenvs-in-project: true |
| 37 | + installer-parallel: true |
| 38 | + - name: Load cached venv |
| 39 | + id: cached-poetry-dependencies |
| 40 | + uses: actions/cache@v3 |
| 41 | + with: |
| 42 | + path: .venv |
| 43 | + key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }} |
| 44 | + - name: Install dependencies |
| 45 | + if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true' |
| 46 | + run: poetry install --no-interaction --no-root |
| 47 | + - name: Build package |
| 48 | + run: poetry build |
| 49 | + - name: Upload artifacts |
| 50 | + uses: actions/upload-artifact@v2 |
| 51 | + with: |
| 52 | + name: dist-${{ matrix.python-version }} |
| 53 | + path: dist |
| 54 | + |
| 55 | + pypi-publish: |
| 56 | + name: Upload release to PyPI |
| 57 | + runs-on: ubuntu-latest |
| 58 | + environment: |
| 59 | + name: release |
| 60 | + url: https://pypi.org/project/chainbench |
| 61 | + permissions: |
| 62 | + id-token: write # IMPORTANT: this permission is mandatory for trusted publishing |
| 63 | + steps: |
| 64 | + - name: Download artifacts |
| 65 | + uses: actions/download-artifact@v2 |
| 66 | + with: |
| 67 | + name: dist-3.10 |
| 68 | + path: dist |
| 69 | + |
| 70 | + - name: Download artifacts |
| 71 | + uses: actions/download-artifact@v2 |
| 72 | + with: |
| 73 | + name: dist-3.11 |
| 74 | + path: dist |
| 75 | + |
| 76 | + - name: Publish package distributions to PyPI |
| 77 | + uses: pypa/gh-action-pypi-publish@release/v1 |
0 commit comments