|
7 | 7 | release: |
8 | 8 | types: [created] |
9 | 9 | workflow_dispatch: |
| 10 | + inputs: |
| 11 | + version: |
| 12 | + description: 'Versione' |
| 13 | + required: true |
10 | 14 |
|
11 | 15 | jobs: |
12 | | - test: |
| 16 | + |
| 17 | + build: |
13 | 18 | runs-on: ubuntu-latest |
| 19 | + needs: test |
| 20 | + permissions: |
| 21 | + contents: read |
14 | 22 | steps: |
15 | | - - uses: actions/checkout@v2 |
| 23 | + - name: Check Out Repo |
| 24 | + uses: actions/checkout@v4 |
| 25 | + - name: Set env |
| 26 | + if: github.event_name != 'workflow_dispatch' |
| 27 | + run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV |
| 28 | + - name: Set env |
| 29 | + if: github.event_name == 'workflow_dispatch' |
| 30 | + run: echo "RELEASE_VERSION=${{ github.event.inputs.version }}" >> $GITHUB_ENV |
16 | 31 | - name: Set up Python |
17 | | - uses: actions/setup-python@v2 |
| 32 | + uses: actions/setup-python@v5 |
18 | 33 | with: |
19 | 34 | python-version: '3.x' |
| 35 | + cache: 'pip' # caching pip dependencies |
20 | 36 | - name: Install dependencies |
21 | | - run: if [ -f requirements.txt ]; then pip install -r requirements.txt; fi |
22 | | - # - name: Test with unittest |
23 | | - # run: python -m unittest discover -v -s ./tests -p test_*.py |
| 37 | + run: | |
| 38 | + python3 -m pip install build --user |
| 39 | + - name: Build a binary wheel and a source tarball |
| 40 | + run: python3 -m build |
| 41 | + - name: Store the distribution packages |
| 42 | + uses: actions/upload-artifact@v4 |
| 43 | + with: |
| 44 | + name: python-package-distributions |
| 45 | + path: dist/ |
24 | 46 |
|
25 | 47 | deploy: |
26 | 48 | runs-on: ubuntu-latest |
27 | | - needs: test |
| 49 | + needs: build |
| 50 | + environment: |
| 51 | + name: pypi |
| 52 | + url: https://pypi.org/project/animeworld/ |
| 53 | + permissions: |
| 54 | + id-token: write |
28 | 55 | steps: |
29 | | - - uses: actions/checkout@v2 |
30 | | - - name: Set up Python |
31 | | - uses: actions/setup-python@v2 |
| 56 | + - name: Download all the dists |
| 57 | + uses: actions/download-artifact@v4 |
32 | 58 | with: |
33 | | - python-version: '3.x' |
34 | | - - name: Install dependencies |
35 | | - run: | |
36 | | - python -m pip install --upgrade pip |
37 | | - pip install setuptools wheel twine |
38 | | - - name: Build and publish |
39 | | - env: |
40 | | - TWINE_USERNAME: '__token__' |
41 | | - TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }} |
42 | | - run: | |
43 | | - python setup.py sdist bdist_wheel |
44 | | - twine upload dist/* |
| 59 | + name: python-package-distributions |
| 60 | + path: dist/ |
| 61 | + - name: Publish distribution 📦 to PyPI |
| 62 | + uses: pypa/gh-action-pypi-publish@release/v1 |
0 commit comments