|
| 1 | +name: Publish Python distribution to PyPI and TestPyPI |
| 2 | + |
| 3 | +on: |
| 4 | + schedule: |
| 5 | + # schedule a dev release on every 1st of the month, at 2034 UTC |
| 6 | + - cron: "34 20 1 * *" |
| 7 | + workflow_dispatch: |
| 8 | + inputs: |
| 9 | + tag: |
| 10 | + description: "uap-core ref to release" |
| 11 | + type: string |
| 12 | + environment: |
| 13 | + description: "environment to release for (testpypy or pypy)" |
| 14 | + type: environment |
| 15 | + |
| 16 | +jobs: |
| 17 | + build: |
| 18 | + name: Build distribution |
| 19 | + runs-on: ubuntu-latest |
| 20 | + |
| 21 | + steps: |
| 22 | + - uses: actions/checkout@v4 |
| 23 | + with: |
| 24 | + submodules: true |
| 25 | + fetch-depth: 0 |
| 26 | + - name: update core |
| 27 | + # needs to detach because we can update to a tag |
| 28 | + run: git -C uap-core switch --detach ${{ inputs.tag || 'master' }} |
| 29 | + - name: Set up Python |
| 30 | + uses: actions/setup-python@v5 |
| 31 | + with: |
| 32 | + python-version: "3.x" |
| 33 | + |
| 34 | + - name: Install pypa/build |
| 35 | + run: python3 -m pip install build --user |
| 36 | + - name: Build wheel |
| 37 | + run: | |
| 38 | + python3 -m build -w ua-parser-builtins |
| 39 | + mv ua-parser-builtins/dist . |
| 40 | + - name: Store the distribution packages |
| 41 | + uses: actions/upload-artifact@v4 |
| 42 | + with: |
| 43 | + name: python-package-distributions |
| 44 | + path: dist/ |
| 45 | + |
| 46 | + publish-to-testpypi: |
| 47 | + name: Publish to TestPyPI |
| 48 | + if: ${{ github.event.inputs.environment == 'testpypi' }} |
| 49 | + needs: |
| 50 | + - build |
| 51 | + runs-on: ubuntu-latest |
| 52 | + |
| 53 | + environment: |
| 54 | + name: testpypi |
| 55 | + url: https://test.pypi.org/p/ua-parser-builtins |
| 56 | + |
| 57 | + permissions: |
| 58 | + id-token: write |
| 59 | + |
| 60 | + steps: |
| 61 | + - name: Download all the dists |
| 62 | + uses: actions/download-artifact@v4 |
| 63 | + with: |
| 64 | + name: python-package-distributions |
| 65 | + path: dist/ |
| 66 | + - name: Publish |
| 67 | + uses: pypa/gh-action-pypi-publish@release/v1 |
| 68 | + with: |
| 69 | + repository-url: https://test.pypi.org/legacy/ |
| 70 | + |
| 71 | + publish-to-pypi: |
| 72 | + name: publish |
| 73 | + if: ${{ github.event_name == 'schedule' || github.event.inputs.environment == 'pypi' }} |
| 74 | + needs: |
| 75 | + - build |
| 76 | + runs-on: ubuntu-latest |
| 77 | + environment: |
| 78 | + name: pypi |
| 79 | + url: https://pypi.org/p/ua-parser-builtins |
| 80 | + permissions: |
| 81 | + id-token: write |
| 82 | + |
| 83 | + steps: |
| 84 | + - name: Download all the dists |
| 85 | + uses: actions/download-artifact@v4 |
| 86 | + with: |
| 87 | + name: python-package-distributions |
| 88 | + path: dist/ |
| 89 | + - name: Publish |
| 90 | + uses: pypa/gh-action-pypi-publish@release/v1 |
0 commit comments