|
| 1 | +name: Publish DorkEye to PyPI |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: |
| 6 | + - "v*.*.*" # Trigger su tag tipo v4.5.0, v5.0.0 ecc. |
| 7 | + |
| 8 | +jobs: |
| 9 | + test: |
| 10 | + name: Run Tests |
| 11 | + runs-on: ubuntu-latest |
| 12 | + strategy: |
| 13 | + matrix: |
| 14 | + python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"] |
| 15 | + |
| 16 | + steps: |
| 17 | + - name: Checkout repo |
| 18 | + uses: actions/checkout@v4 |
| 19 | + |
| 20 | + - name: Setup Python ${{ matrix.python-version }} |
| 21 | + uses: actions/setup-python@v5 |
| 22 | + with: |
| 23 | + python-version: ${{ matrix.python-version }} |
| 24 | + |
| 25 | + - name: Install dependencies |
| 26 | + run: | |
| 27 | + python -m pip install --upgrade pip |
| 28 | + pip install -e ".[all]" |
| 29 | + pip install pytest pytest-cov |
| 30 | +
|
| 31 | + - name: Run tests |
| 32 | + run: pytest tests/ -v --cov=dorkeye --cov-report=xml |
| 33 | + |
| 34 | + build: |
| 35 | + name: Build Distribution |
| 36 | + runs-on: ubuntu-latest |
| 37 | + needs: test |
| 38 | + |
| 39 | + steps: |
| 40 | + - name: Checkout repo |
| 41 | + uses: actions/checkout@v4 |
| 42 | + |
| 43 | + - name: Setup Python |
| 44 | + uses: actions/setup-python@v5 |
| 45 | + with: |
| 46 | + python-version: "3.12" |
| 47 | + |
| 48 | + - name: Install build tools |
| 49 | + run: | |
| 50 | + python -m pip install --upgrade pip |
| 51 | + pip install build twine |
| 52 | +
|
| 53 | + - name: Build package |
| 54 | + run: python -m build |
| 55 | + |
| 56 | + - name: Check distribution |
| 57 | + run: twine check dist/* |
| 58 | + |
| 59 | + - name: Upload build artifacts |
| 60 | + uses: actions/upload-artifact@v4 |
| 61 | + with: |
| 62 | + name: dist |
| 63 | + path: dist/ |
| 64 | + |
| 65 | + publish: |
| 66 | + name: Publish to PyPI |
| 67 | + runs-on: ubuntu-latest |
| 68 | + needs: build |
| 69 | + environment: |
| 70 | + name: pypi |
| 71 | + url: https://pypi.org/project/dorkeye/ |
| 72 | + permissions: |
| 73 | + id-token: write # Necessario per OIDC trusted publishing |
| 74 | + |
| 75 | + steps: |
| 76 | + - name: Download build artifacts |
| 77 | + uses: actions/download-artifact@v4 |
| 78 | + with: |
| 79 | + name: dist |
| 80 | + path: dist/ |
| 81 | + |
| 82 | + - name: Publish to PyPI |
| 83 | + uses: pypa/gh-action-pypi-publish@release/v1 |
| 84 | + # Usa OIDC trusted publishing (no API key necessaria!) |
| 85 | + # Configuralo su: https://pypi.org/manage/account/publishing/ |
| 86 | + |
| 87 | + github-release: |
| 88 | + name: Create GitHub Release |
| 89 | + runs-on: ubuntu-latest |
| 90 | + needs: publish |
| 91 | + permissions: |
| 92 | + contents: write |
| 93 | + |
| 94 | + steps: |
| 95 | + - name: Checkout repo |
| 96 | + uses: actions/checkout@v4 |
| 97 | + with: |
| 98 | + fetch-depth: 0 |
| 99 | + |
| 100 | + - name: Download build artifacts |
| 101 | + uses: actions/download-artifact@v4 |
| 102 | + with: |
| 103 | + name: dist |
| 104 | + path: dist/ |
| 105 | + |
| 106 | + - name: Create GitHub Release |
| 107 | + uses: softprops/action-gh-release@v2 |
| 108 | + with: |
| 109 | + files: dist/* |
| 110 | + generate_release_notes: true |
| 111 | + body: | |
| 112 | + ## 🎯 DorkEye ${{ github.ref_name }} |
| 113 | +
|
| 114 | + Installazione: |
| 115 | + ```bash |
| 116 | + pip install dorkeye==${{ github.ref_name }} |
| 117 | + ``` |
| 118 | + |
| 119 | + Vedi [CHANGELOG.md](CHANGELOG.md) per i dettagli. |
0 commit comments