Publish Package to PyPI #3
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: "Publish Package to PyPI" | |
| permissions: | |
| contents: read | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| package: | |
| description: "Package to publish" | |
| required: true | |
| type: choice | |
| options: | |
| - Nitrodigest | |
| - Nitrowebfetch | |
| environment: | |
| description: "Where to publish (testpypi or pypi)" | |
| required: true | |
| default: "testpypi" | |
| type: choice | |
| options: | |
| - testpypi | |
| - pypi | |
| jobs: | |
| build-and-publish: | |
| name: Build and publish ${{ inputs.package }} | |
| runs-on: ubuntu-latest | |
| environment: ${{ inputs.environment }} | |
| permissions: | |
| id-token: write | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.12.10" | |
| - name: Install build dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install build | |
| - name: Build package | |
| working-directory: Projects/${{ inputs.package }} | |
| run: python -m build | |
| - name: Publish package to ${{ inputs.environment }} | |
| uses: pypa/gh-action-pypi-publish@release/v1 | |
| with: | |
| repository-url: ${{ inputs.environment == 'pypi' && 'https://upload.pypi.org/legacy/' || 'https://test.pypi.org/legacy/' }} | |
| packages-dir: Projects/${{ inputs.package }}/dist/ |