|
| 1 | +# https://raw.githubusercontent.com/mhils/workflows/0d7c124ffff22d26be111477a3ed9fadd853a6db/.github/workflows/python-deploy.yml |
| 2 | + |
| 3 | +# MIT License |
| 4 | + |
| 5 | +# Copyright (c) 2022 Maximilian Hils |
| 6 | + |
| 7 | +# Permission is hereby granted, free of charge, to any person obtaining a copy |
| 8 | +# of this software and associated documentation files (the "Software"), to deal |
| 9 | +# in the Software without restriction, including without limitation the rights |
| 10 | +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
| 11 | +# copies of the Software, and to permit persons to whom the Software is |
| 12 | +# furnished to do so, subject to the following conditions: |
| 13 | + |
| 14 | +# The above copyright notice and this permission notice shall be included in all |
| 15 | +# copies or substantial portions of the Software. |
| 16 | + |
| 17 | +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 18 | +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 19 | +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 20 | +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 21 | +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 22 | +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
| 23 | +# SOFTWARE. |
| 24 | + |
| 25 | +# Usage: |
| 26 | +# |
| 27 | +# deploy: |
| 28 | +# uses: mhils/workflows/.github/workflows/python-deploy.yml@main |
| 29 | +# needs: check |
| 30 | +# if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags') |
| 31 | +# secrets: |
| 32 | +# password: ${{ secrets.PYPI_TOKEN }} |
| 33 | + |
| 34 | +permissions: |
| 35 | + contents: read |
| 36 | + |
| 37 | +on: |
| 38 | + workflow_call: |
| 39 | + inputs: |
| 40 | + environment: |
| 41 | + type: string |
| 42 | + artifact-name: |
| 43 | + type: string |
| 44 | + artifact-pattern: |
| 45 | + type: string |
| 46 | + artifact-merge-multiple: |
| 47 | + type: boolean |
| 48 | + repository: |
| 49 | + type: string |
| 50 | + secrets: |
| 51 | + username: |
| 52 | + password: |
| 53 | + required: true |
| 54 | + |
| 55 | +jobs: |
| 56 | + deploy: |
| 57 | + environment: ${{ inputs.environment || 'deploy' }} |
| 58 | + env: |
| 59 | + TWINE_USERNAME: ${{ secrets.username || '__token__' }} |
| 60 | + TWINE_PASSWORD: ${{ secrets.password }} |
| 61 | + TWINE_REPOSITORY: ${{ inputs.repository || 'pypi' }} |
| 62 | + runs-on: ubuntu-latest |
| 63 | + steps: |
| 64 | + - name: Install twine from PyPI |
| 65 | + uses: install-pinned/twine@6aec23fc537538d8e480e593660afa49a377c224 # 5.0.0 |
| 66 | + - uses: actions/download-artifact@v4 |
| 67 | + with: |
| 68 | + name: ${{ inputs.artifact-name }} |
| 69 | + pattern: ${{ inputs.artifact-pattern }} |
| 70 | + merge-multiple: ${{ inputs.artifact-merge-multiple }} |
| 71 | + path: dist/ |
| 72 | + - run: twine check dist/* |
| 73 | + - run: twine upload dist/* |
0 commit comments