|
8 | 8 | types: |
9 | 9 | - published |
10 | 10 |
|
| 11 | +concurrency: |
| 12 | + group: "${{ github.ref }}-${{ github.head_ref }}-${{ github.workflow }}" |
| 13 | + cancel-in-progress: false |
| 14 | + |
| 15 | +defaults: |
| 16 | + run: |
| 17 | + shell: bash -l {0} |
| 18 | + |
| 19 | + |
11 | 20 | jobs: |
12 | | - testpypi_push: |
13 | | - environment: |
14 | | - name: deploy |
15 | | - url: https://test.pypi.org/p/GridDataFormats |
16 | | - permissions: |
17 | | - id-token: write |
18 | | - if: | |
19 | | - github.repository == 'MDAnalysis/GridDataFormats' && |
20 | | - (github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')) |
21 | | - name: Build, upload and test pure Python wheels to TestPypi |
| 21 | + build: |
| 22 | + name: Build package |
22 | 23 | runs-on: ubuntu-latest |
| 24 | + steps: |
| 25 | + - name: Checkout |
| 26 | + uses: actions/checkout@v4 |
| 27 | + |
| 28 | + - name: Set up Python |
| 29 | + uses: actions/setup-python@v5 |
| 30 | + with: |
| 31 | + python-version: "3.14" |
| 32 | + |
| 33 | + - name: Install build dependencies |
| 34 | + run: | |
| 35 | + python -m pip install --upgrade pip |
| 36 | + pip install build twine |
| 37 | +
|
| 38 | + - name: Build package (binary wheel and source distribution package) |
| 39 | + run: | |
| 40 | + python -m build |
| 41 | +
|
| 42 | + - name: Check package |
| 43 | + run: | |
| 44 | + twine check dist/* |
23 | 45 |
|
| 46 | + - name: Upload dist files |
| 47 | + uses: actions/upload-artifact@v4 |
| 48 | + with: |
| 49 | + name: dist-files |
| 50 | + path: dist/ |
| 51 | + retention-days: 1 |
| 52 | + |
| 53 | + test-pytest: |
| 54 | + name: Run tests |
| 55 | + runs-on: ubuntu-latest |
| 56 | + needs: build |
24 | 57 | steps: |
25 | | - - uses: actions/checkout@v4 |
| 58 | + - name: Set up Python |
| 59 | + uses: actions/setup-python@v5 |
| 60 | + with: |
| 61 | + python-version: "3.14" |
26 | 62 |
|
27 | | - - name: testpypi_deploy |
28 | | - uses: MDAnalysis/pypi-deployment@main |
29 | | - if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') |
| 63 | + - name: Download dist files |
| 64 | + uses: actions/download-artifact@v4 |
30 | 65 | with: |
31 | | - test_submission: true |
32 | | - package_name: GridDataFormats |
33 | | - module_name: 'gridData' |
| 66 | + name: dist-files |
| 67 | + path: dist/ |
34 | 68 |
|
35 | | - pypi_push: |
| 69 | + - name: Install package with test dependencies and tests |
| 70 | + run: | |
| 71 | + python -m pip install --upgrade pip |
| 72 | + WHEEL_FILE=$(ls dist/*.whl) |
| 73 | + pip install "$WHEEL_FILE"[test] |
| 74 | +
|
| 75 | + - name: Test import |
| 76 | + run: | |
| 77 | + python -c "import gridData; print(f'Package {gridData.__version__} imported successfully')" |
| 78 | + |
| 79 | + - name: Run basic tests |
| 80 | + run: | |
| 81 | + pytest --verbose --pyargs gridData |
| 82 | +
|
| 83 | + deploy-testpypi: |
| 84 | + name: Deploy to TestPyPI |
| 85 | + runs-on: ubuntu-latest |
| 86 | + needs: [build, test-pytest] |
| 87 | + if: | |
| 88 | + github.repository == 'MDAnalysis/GridDataFormats' && |
| 89 | + (github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')) |
36 | 90 | environment: |
37 | | - name: deploy |
38 | | - url: https://pypi.org/p/GridDataFormats |
| 91 | + name: testpypi |
| 92 | + url: https://test.pypi.org/p/GridDataFormats |
39 | 93 | permissions: |
40 | | - id-token: write |
| 94 | + id-token: write # IMPORTANT: mandatory for trusted publishing |
| 95 | + steps: |
| 96 | + - name: Download dist files |
| 97 | + uses: actions/download-artifact@v4 |
| 98 | + with: |
| 99 | + name: dist-files |
| 100 | + path: dist/ |
| 101 | + |
| 102 | + - name: Publish to TestPyPI |
| 103 | + uses: pypa/gh-action-pypi-publish@v1.13.0 |
| 104 | + with: |
| 105 | + repository-url: https://test.pypi.org/legacy/ |
| 106 | + |
| 107 | + deploy-pypi: |
| 108 | + name: Deploy to PyPI |
| 109 | + runs-on: ubuntu-latest |
| 110 | + needs: [build, test-pytest] |
41 | 111 | if: | |
42 | 112 | github.repository == 'MDAnalysis/GridDataFormats' && |
43 | 113 | (github.event_name == 'release' && github.event.action == 'published') |
44 | | - name: Build, upload and test pure Python wheels to PyPi |
45 | | - runs-on: ubuntu-latest |
| 114 | + environment: |
| 115 | + name: pypi |
| 116 | + url: https://pypi.org/p/GridDataFormats |
| 117 | + permissions: |
| 118 | + id-token: write # IMPORTANT: mandatory for trusted publishing |
| 119 | + steps: |
| 120 | + - name: Download dist files |
| 121 | + uses: actions/download-artifact@v4 |
| 122 | + with: |
| 123 | + name: dist-files |
| 124 | + path: dist/ |
| 125 | + |
| 126 | + - name: Publish to PyPI |
| 127 | + uses: pypa/gh-action-pypi-publish@v1.13.0 |
46 | 128 |
|
| 129 | + test-deployed-testpypi: |
| 130 | + name: Test deployed package (TestPyPI) |
| 131 | + runs-on: ${{ matrix.os }} |
| 132 | + strategy: |
| 133 | + fail-fast: false |
| 134 | + matrix: |
| 135 | + os: [ubuntu-latest, macos-latest] |
| 136 | + needs: deploy-testpypi |
| 137 | + if: | |
| 138 | + github.repository == 'MDAnalysis/GridDataFormats' && |
| 139 | + (github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')) |
47 | 140 | steps: |
48 | | - - uses: actions/checkout@v4 |
| 141 | + - name: Set up Python |
| 142 | + uses: actions/setup-python@v5 |
| 143 | + with: |
| 144 | + python-version: "3.14" |
| 145 | + |
| 146 | + - name: Install from TestPyPI |
| 147 | + run: | |
| 148 | + python -m pip install --upgrade pip |
| 149 | + pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/ GridDataFormats[test] |
49 | 150 |
|
50 | | - - name: pypi_deploy |
51 | | - uses: MDAnalysis/pypi-deployment@main |
52 | | - if: github.event_name == 'release' && github.event.action == 'published' |
| 151 | + - name: Test import |
| 152 | + run: | |
| 153 | + python -c "import gridData; print(f'Package {gridData.__version__} imported successfully from TestPyPi')" |
| 154 | +
|
| 155 | + - name: Run basic tests |
| 156 | + run: | |
| 157 | + pytest --verbose --pyargs gridData |
| 158 | +
|
| 159 | + test-deployed-pypi: |
| 160 | + name: Test deployed package (PyPI) |
| 161 | + runs-on: ${{ matrix.os }} |
| 162 | + strategy: |
| 163 | + fail-fast: false |
| 164 | + matrix: |
| 165 | + os: [ubuntu-latest, macos-latest] |
| 166 | + needs: deploy-pypi |
| 167 | + if: | |
| 168 | + github.repository == 'MDAnalysis/GridDataFormats' && |
| 169 | + (github.event_name == 'release' && github.event.action == 'published') |
| 170 | + steps: |
| 171 | + - name: Set up Python |
| 172 | + uses: actions/setup-python@v5 |
53 | 173 | with: |
54 | | - package_name: GridDataFormats |
55 | | - module_name: 'gridData' |
| 174 | + python-version: "3.14" |
| 175 | + |
| 176 | + - name: Install from PyPI |
| 177 | + run: | |
| 178 | + python -m pip install --upgrade pip |
| 179 | + pip install GridDataFormats[test] |
| 180 | +
|
| 181 | + - name: Test import |
| 182 | + run: | |
| 183 | + python -c "import gridData; print(f'Package {gridData.__version__} imported successfully from PyPi')" |
| 184 | +
|
| 185 | + - name: Run basic tests |
| 186 | + run: | |
| 187 | + pytest --verbose --pyargs gridData |
0 commit comments