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