■ ■ ■ ■ ■ ■
.github/workflows/pipup.yml
1 | | - | name: Publish to PyPI and TestPyPI |
| 1 | + | # This is a basic workflow to help you get started with Actions |
2 | 2 | | |
3 | | - | on: push |
| 3 | + | name: Upload to PIP |
4 | 4 | | |
| 5 | + | # Controls when the action will run. |
| 6 | + | on: |
| 7 | + | # Triggers the workflow when a release is created |
| 8 | + | release: |
| 9 | + | types: [created] |
| 10 | + | # Allows you to run this workflow manually from the Actions tab |
| 11 | + | workflow_dispatch: |
| 12 | + | |
| 13 | + | # A workflow run is made up of one or more jobs that can run sequentially or in parallel |
5 | 14 | | jobs: |
6 | | - | build-n-publish: |
7 | | - | name: Build and publish Python 🐍 distributions 📦 to PyPI and TestPyPI |
| 15 | + | # This workflow contains a single job called "upload" |
| 16 | + | upload: |
| 17 | + | # The type of runner that the job will run on |
8 | 18 | | runs-on: ubuntu-latest |
| 19 | + | |
| 20 | + | # Steps represent a sequence of tasks that will be executed as part of the job |
9 | 21 | | steps: |
10 | | - | - uses: actions/checkout@master |
11 | | - | - name: Set up Python 3.10 |
12 | | - | uses: actions/setup-python@v3 |
13 | | - | with: |
14 | | - | python-version: "3.10" |
15 | | - | - name: Install pypa/build |
16 | | - | run: >- |
17 | | - | python -m |
18 | | - | pip install |
19 | | - | build |
20 | | - | --user |
21 | | - | - name: Build a binary wheel and a source tarball |
22 | | - | run: >- |
23 | | - | python -m |
24 | | - | build |
25 | | - | --sdist |
26 | | - | --wheel |
27 | | - | --outdir dist/ |
28 | | - | . |
29 | | - | - name: Publish distribution 📦 to Test PyPI |
30 | | - | uses: pypa/gh-action-pypi-publish@release/v1 |
31 | | - | with: |
32 | | - | password: ${{ secrets.PYPI_API_TOKEN }} |
33 | | - | repository_url: https://test.pypi.org/legacy/ |
34 | | - | - name: Publish distribution 📦 to PyPI |
35 | | - | if: startsWith(github.ref, 'refs/tags') |
36 | | - | uses: pypa/gh-action-pypi-publish@release/v1 |
37 | | - | with: |
38 | | - | password: ${{ secrets.PYPI_API_TOKEN }} |
| 22 | + | # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it |
| 23 | + | - uses: actions/checkout@v2 |
| 24 | + | |
| 25 | + | # Sets up python |
| 26 | + | - uses: actions/setup-python@v2 |
| 27 | + | with: |
| 28 | + | python-version: 3.8 |
| 29 | + | |
| 30 | + | # Install dependencies |
| 31 | + | - name: "Installs dependencies" |
| 32 | + | run: | |
| 33 | + | python3 -m pip install --upgrade pip |
| 34 | + | python3 -m pip install setuptools wheel twine |
39 | 35 | | |
| 36 | + | # Build and upload to PyPI |
| 37 | + | - name: "Builds and uploads to PyPI" |
| 38 | + | run: | |
| 39 | + | python3 setup.py sdist bdist_wheel |
| 40 | + | python3 -m twine upload dist/* |
| 41 | + | env: |
| 42 | + | TWINE_USERNAME: __token__ |
| 43 | + | TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }} |