|
| 1 | +name: Publish to PyPI |
| 2 | + |
| 3 | +on: |
| 4 | + release: |
| 5 | + types: |
| 6 | + - published |
| 7 | + |
| 8 | +jobs: |
| 9 | + build: |
| 10 | + runs-on: ubuntu-latest |
| 11 | + steps: |
| 12 | + - name: Checkout code |
| 13 | + uses: actions/checkout@v4 |
| 14 | + |
| 15 | + - name: Set up Python |
| 16 | + uses: actions/setup-python@v5 |
| 17 | + with: |
| 18 | + python-version: "3.x" |
| 19 | + |
| 20 | + - name: Install build tools |
| 21 | + run: | |
| 22 | + python -m pip install --upgrade build |
| 23 | +
|
| 24 | + - name: Build the package |
| 25 | + run: | |
| 26 | + python -m build |
| 27 | +
|
| 28 | + - name: Upload built package as artifact |
| 29 | + uses: actions/upload-artifact@v4 |
| 30 | + with: |
| 31 | + name: package-distributions |
| 32 | + path: dist/ |
| 33 | + |
| 34 | + publish: |
| 35 | + runs-on: ubuntu-latest |
| 36 | + needs: build # Only publish if build succeeds |
| 37 | + permissions: |
| 38 | + id-token: write |
| 39 | + environment: |
| 40 | + name: pypi |
| 41 | + url: "https://pypi.org/p/mccann_hub-odoo_client_lib" |
| 42 | + steps: |
| 43 | + - name: Download built package |
| 44 | + uses: actions/download-artifact@v4 |
| 45 | + with: |
| 46 | + name: package-distributions |
| 47 | + path: dist/ |
| 48 | + |
| 49 | + - name: Publish to PyPI |
| 50 | + uses: pypa/gh-action-pypi-publish@release/v1 |
| 51 | + with: |
| 52 | + verbose: true |
| 53 | + |
| 54 | + upload-to-release: |
| 55 | + runs-on: ubuntu-latest |
| 56 | + needs: build # Only upload to release if build succeeds |
| 57 | + permissions: |
| 58 | + contents: write # Required to upload assets to the release |
| 59 | + steps: |
| 60 | + - name: Download built package |
| 61 | + uses: actions/download-artifact@v4 |
| 62 | + with: |
| 63 | + name: package-distributions |
| 64 | + path: dist/ |
| 65 | + |
| 66 | + - name: Upload to GitHub Release |
| 67 | + uses: softprops/action-gh-release@v1 |
| 68 | + with: |
| 69 | + files: dist/* |
| 70 | + |
| 71 | + verify: |
| 72 | + runs-on: ubuntu-latest |
| 73 | + needs: publish # Only verify if PyPI upload succeeds |
| 74 | + steps: |
| 75 | + - name: Install package from PyPI |
| 76 | + run: | |
| 77 | + python -m pip install mccann_hub-odoo_client_lib |
| 78 | +
|
| 79 | + - name: Verify import |
| 80 | + run: | |
| 81 | + python -c "import mccann_hub.odoolib; print('✅ Import successful')" |
0 commit comments