|
1 |
| ---- |
2 |
| - # This workflow will upload a Python Package using Twine when a release is created |
3 |
| - # For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries |
| 1 | +# This workflow will upload a Python Package using Twine when a release is created |
| 2 | +# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries |
4 | 3 |
|
5 |
| - name: Upload Python Package |
| 4 | +name: Upload Python Package |
6 | 5 |
|
7 |
| - on: |
8 |
| - release: |
9 |
| - types: [created] |
| 6 | +on: |
10 | 7 |
|
11 |
| - jobs: |
12 |
| - quality: |
13 |
| - uses: ecmwf-actions/reusable-workflows/.github/workflows/qa-precommit-run.yml@v2 |
| 8 | + push: {} |
| 9 | + |
| 10 | + release: |
| 11 | + types: [created] |
| 12 | + |
| 13 | +jobs: |
| 14 | + quality: |
| 15 | + name: Code QA |
| 16 | + runs-on: ubuntu-latest |
| 17 | + steps: |
| 18 | + - uses: actions/checkout@v4 |
| 19 | + - uses: actions/setup-python@v5 |
| 20 | + with: |
| 21 | + python-version: 3.x |
| 22 | + - uses: pre-commit/[email protected] |
| 23 | + env: |
| 24 | + SKIP: no-commit-to-branch |
| 25 | + |
| 26 | + checks: |
| 27 | + if: ${{ github.event_name == 'release' }} |
| 28 | + |
| 29 | + strategy: |
| 30 | + fail-fast: false |
| 31 | + matrix: |
| 32 | + platform: ["ubuntu-latest", "macos-latest"] |
| 33 | + python-version: ["3.10"] |
| 34 | + |
| 35 | + name: Python ${{ matrix.python-version }} on ${{ matrix.platform }} |
| 36 | + runs-on: ${{ matrix.platform }} |
| 37 | + needs: quality |
| 38 | + |
| 39 | + steps: |
| 40 | + - uses: actions/checkout@v2 |
| 41 | + |
| 42 | + - uses: actions/setup-python@v2 |
14 | 43 | with:
|
15 |
| - skip-hooks: "no-commit-to-branch" |
| 44 | + python-version: ${{ matrix.python-version }} |
| 45 | + |
| 46 | + - name: Install |
| 47 | + run: | |
| 48 | + pip install pytest |
| 49 | + pip install -e . |
| 50 | + pip freeze |
| 51 | +
|
| 52 | + - name: Tests |
| 53 | + run: pytest |
| 54 | + |
| 55 | + deploy: |
16 | 56 |
|
17 |
| - checks: |
18 |
| - uses: ecmwf-actions/reusable-workflows/.github/workflows/qa-pytest-pyproject.yml@v2 |
| 57 | + if: ${{ github.event_name == 'release' }} |
| 58 | + runs-on: ubuntu-latest |
| 59 | + needs: checks |
| 60 | + |
| 61 | + steps: |
| 62 | + - uses: actions/checkout@v2 |
| 63 | + |
| 64 | + - name: Set up Python |
| 65 | + uses: actions/setup-python@v2 |
| 66 | + with: |
| 67 | + python-version: '3.x' |
19 | 68 |
|
20 |
| - deploy: |
21 |
| - needs: [checks, quality] |
22 |
| - uses: ecmwf-actions/reusable-workflows/.github/workflows/cd-pypi.yml@v2 |
23 |
| - secrets: inherit |
| 69 | + - name: Install dependencies |
| 70 | + run: | |
| 71 | + python -m pip install --upgrade pip |
| 72 | + pip install build wheel twine |
| 73 | + - name: Build and publish |
| 74 | + env: |
| 75 | + TWINE_USERNAME: __token__ |
| 76 | + TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }} |
| 77 | + run: | |
| 78 | + python -m pip install --upgrade build |
| 79 | + python -m build |
| 80 | + twine upload dist/* |
0 commit comments