|
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 | + |
11 | 19 | jobs: |
12 | | - testpypi_push: |
| 20 | + build: |
| 21 | + name: Build package |
| 22 | + if: github.repository == 'MDAnalysis/PathSimAnalysis' |
| 23 | + runs-on: ubuntu-latest |
| 24 | + outputs: |
| 25 | + version: ${{ steps.extract-version.outputs.version }} |
| 26 | + steps: |
| 27 | + - name: Checkout |
| 28 | + uses: actions/checkout@v7 |
| 29 | + with: |
| 30 | + fetch-depth: 0 |
| 31 | + fetch-tags: true |
| 32 | + |
| 33 | + - name: Set up Python |
| 34 | + uses: actions/setup-python@v6 |
| 35 | + with: |
| 36 | + python-version: "3.11" |
| 37 | + |
| 38 | + - name: Install build dependencies |
| 39 | + run: | |
| 40 | + python -m pip install --upgrade pip |
| 41 | + pip install "setuptools>=61.2,<81" build twine |
| 42 | +
|
| 43 | + - name: Build package (wheel and sdist) |
| 44 | + run: python -m build |
| 45 | + |
| 46 | + - name: Check package |
| 47 | + run: twine check dist/* |
| 48 | + |
| 49 | + - name: Extract package version |
| 50 | + id: extract-version |
| 51 | + run: | |
| 52 | + WHEEL_FILE=$(ls dist/*.whl) |
| 53 | + VERSION=$(basename "$WHEEL_FILE" | sed -n 's/pathsimanalysis-\([^-]*\)-.*/\1/p') |
| 54 | + if [ -z "$VERSION" ]; then |
| 55 | + pip install "$WHEEL_FILE" --quiet |
| 56 | + VERSION=$(python -c "import pathsimanalysis; print(pathsimanalysis.__version__)") |
| 57 | + pip uninstall -y pathsimanalysis --quiet |
| 58 | + fi |
| 59 | + echo "version=$VERSION" >> "$GITHUB_OUTPUT" |
| 60 | + echo "Extracted version: $VERSION" |
| 61 | +
|
| 62 | + - name: Upload dist files |
| 63 | + uses: actions/upload-artifact@v7 |
| 64 | + with: |
| 65 | + name: dist-files |
| 66 | + path: dist/ |
| 67 | + retention-days: 1 |
| 68 | + |
| 69 | + test-pytest: |
| 70 | + name: Run tests |
| 71 | + if: github.repository == 'MDAnalysis/PathSimAnalysis' |
| 72 | + runs-on: ubuntu-latest |
| 73 | + needs: build |
| 74 | + steps: |
| 75 | + - name: Set up Python |
| 76 | + uses: actions/setup-python@v6 |
| 77 | + with: |
| 78 | + python-version: "3.11" |
| 79 | + |
| 80 | + - name: Download dist files |
| 81 | + uses: actions/download-artifact@v8 |
| 82 | + with: |
| 83 | + name: dist-files |
| 84 | + path: dist/ |
| 85 | + |
| 86 | + - name: Install wheel with test extras |
| 87 | + run: | |
| 88 | + python -m pip install --upgrade pip |
| 89 | + WHEEL_FILE=$(ls dist/*.whl) |
| 90 | + pip install "${WHEEL_FILE}[test]" |
| 91 | +
|
| 92 | + - name: Test import |
| 93 | + run: | |
| 94 | + python -c "import pathsimanalysis; print(f'Package {pathsimanalysis.__version__} imported successfully')" |
| 95 | +
|
| 96 | + - name: Run tests |
| 97 | + run: pytest -v --pyargs pathsimanalysis.tests |
| 98 | + |
| 99 | + deploy-testpypi: |
| 100 | + name: Deploy to TestPyPI |
| 101 | + if: | |
| 102 | + github.repository == 'MDAnalysis/PathSimAnalysis' && |
| 103 | + (github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')) |
| 104 | + runs-on: ubuntu-latest |
| 105 | + needs: [build, test-pytest] |
13 | 106 | environment: |
14 | 107 | name: deploy |
15 | 108 | url: https://test.pypi.org/p/pathsimanalysis |
16 | 109 | permissions: |
17 | 110 | id-token: write |
18 | | - if: | |
19 | | - github.repository == 'MDAnalysis/PathSimAnalysis' && |
20 | | - (github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')) |
21 | | - name: Build, upload and test pure Python wheels to TestPyPi |
22 | | - runs-on: ubuntu-latest |
23 | | - |
24 | 111 | steps: |
25 | | - - uses: actions/checkout@v7 |
| 112 | + - name: Download dist files |
| 113 | + uses: actions/download-artifact@v8 |
| 114 | + with: |
| 115 | + name: dist-files |
| 116 | + path: dist/ |
26 | 117 |
|
27 | | - - name: testpypi_deploy |
28 | | - uses: MDAnalysis/pypi-deployment@main |
| 118 | + - name: Publish to TestPyPI |
| 119 | + uses: pypa/gh-action-pypi-publish@release/v1 |
29 | 120 | with: |
30 | | - test_submission: true |
31 | | - tests: true |
32 | | - test_deps: 'pytest MDAnalysisTests' |
33 | | - package_name: 'pathsimanalysis' |
| 121 | + repository-url: https://test.pypi.org/legacy/ |
| 122 | + verbose: true |
| 123 | + skip-existing: true |
34 | 124 |
|
35 | | - pypi_push: |
| 125 | + deploy-pypi: |
| 126 | + name: Deploy to PyPI |
| 127 | + if: | |
| 128 | + github.repository == 'MDAnalysis/PathSimAnalysis' && |
| 129 | + (github.event_name == 'release' && github.event.action == 'published') |
| 130 | + runs-on: ubuntu-latest |
| 131 | + needs: [build, test-pytest] |
36 | 132 | environment: |
37 | 133 | name: deploy |
38 | 134 | url: https://pypi.org/p/pathsimanalysis |
39 | 135 | permissions: |
40 | 136 | id-token: write |
| 137 | + steps: |
| 138 | + - name: Download dist files |
| 139 | + uses: actions/download-artifact@v8 |
| 140 | + with: |
| 141 | + name: dist-files |
| 142 | + path: dist/ |
| 143 | + |
| 144 | + - name: Publish to PyPI |
| 145 | + uses: pypa/gh-action-pypi-publish@release/v1 |
| 146 | + |
| 147 | + test-deployed-testpypi: |
| 148 | + name: Test deployed package (TestPyPI) |
41 | 149 | if: | |
42 | 150 | github.repository == 'MDAnalysis/PathSimAnalysis' && |
43 | | - (github.event_name == 'release' && github.event.action == 'published') |
44 | | - name: Build, upload and test pure Python wheels to PyPi |
| 151 | + (github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')) |
45 | 152 | runs-on: ubuntu-latest |
| 153 | + needs: [build, deploy-testpypi] |
| 154 | + steps: |
| 155 | + - name: Checkout repository for actions |
| 156 | + uses: actions/checkout@v7 |
| 157 | + |
| 158 | + - name: Set up Python |
| 159 | + uses: actions/setup-python@v6 |
| 160 | + with: |
| 161 | + python-version: "3.11" |
| 162 | + |
| 163 | + - name: Wait for version to be available on TestPyPI |
| 164 | + uses: ./.github/actions/wait-for-pypi-version |
| 165 | + with: |
| 166 | + repository: testpypi |
| 167 | + package: pathsimanalysis |
| 168 | + version: ${{ needs.build.outputs.version }} |
| 169 | + |
| 170 | + - name: Install from TestPyPI |
| 171 | + run: | |
| 172 | + python -m pip install --upgrade pip |
| 173 | + pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/ "pathsimanalysis[test]==${{ needs.build.outputs.version }}" |
46 | 174 |
|
| 175 | + - name: Test import |
| 176 | + run: | |
| 177 | + python -c "import pathsimanalysis; print(f'Package {pathsimanalysis.__version__} imported successfully from TestPyPI')" |
| 178 | +
|
| 179 | + - name: Run tests |
| 180 | + run: pytest -v --pyargs pathsimanalysis.tests |
| 181 | + |
| 182 | + test-deployed-pypi: |
| 183 | + name: Test deployed package (PyPI) |
| 184 | + if: | |
| 185 | + github.repository == 'MDAnalysis/PathSimAnalysis' && |
| 186 | + (github.event_name == 'release' && github.event.action == 'published') |
| 187 | + runs-on: ubuntu-latest |
| 188 | + needs: [build, deploy-pypi] |
47 | 189 | steps: |
48 | | - - uses: actions/checkout@v7 |
| 190 | + - name: Checkout repository for actions |
| 191 | + uses: actions/checkout@v7 |
| 192 | + |
| 193 | + - name: Set up Python |
| 194 | + uses: actions/setup-python@v6 |
| 195 | + with: |
| 196 | + python-version: "3.11" |
49 | 197 |
|
50 | | - - name: pypi_deploy |
51 | | - uses: MDAnalysis/pypi-deployment@main |
| 198 | + - name: Wait for version to be available on PyPI |
| 199 | + uses: ./.github/actions/wait-for-pypi-version |
52 | 200 | with: |
53 | | - package_name: 'pathsimanalysis' |
54 | | - tests: false |
| 201 | + repository: pypi |
| 202 | + package: pathsimanalysis |
| 203 | + version: ${{ needs.build.outputs.version }} |
| 204 | + |
| 205 | + - name: Install from PyPI |
| 206 | + run: | |
| 207 | + python -m pip install --upgrade pip |
| 208 | + pip install "pathsimanalysis[test]==${{ needs.build.outputs.version }}" |
| 209 | +
|
| 210 | + - name: Test import |
| 211 | + run: | |
| 212 | + python -c "import pathsimanalysis; print(f'Package {pathsimanalysis.__version__} imported successfully from PyPI')" |
| 213 | +
|
| 214 | + - name: Run tests |
| 215 | + run: pytest -v --pyargs pathsimanalysis.tests |
0 commit comments