|
| 1 | +name: mod_wsgi-telemetry (build/test/release) |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + push: |
| 6 | + branches: |
| 7 | + - develop |
| 8 | + tags: |
| 9 | + - "mod_wsgi-telemetry-[0-9]+.[0-9]+.[0-9]+" |
| 10 | + - "mod_wsgi-telemetry-[0-9]+.[0-9]+.[0-9]+.dev[0-9]+" |
| 11 | + - "mod_wsgi-telemetry-[0-9]+.[0-9]+.[0-9]+rc[0-9]+" |
| 12 | + pull_request: |
| 13 | + branches: |
| 14 | + - develop |
| 15 | + |
| 16 | +jobs: |
| 17 | + build: |
| 18 | + name: "Build mod_wsgi-telemetry package" |
| 19 | + runs-on: "ubuntu-24.04" |
| 20 | + steps: |
| 21 | + - uses: "actions/checkout@v6" |
| 22 | + - uses: "actions/setup-python@v6" |
| 23 | + with: |
| 24 | + python-version: "3.12" |
| 25 | + - name: "Verify version matches tag" |
| 26 | + if: startsWith(github.ref, 'refs/tags/mod_wsgi-telemetry-') |
| 27 | + run: | |
| 28 | + TAG="${GITHUB_REF_NAME}" |
| 29 | + EXPECTED="${TAG#mod_wsgi-telemetry-}" |
| 30 | + ACTUAL="$(grep -oE '__version__[[:space:]]*=[[:space:]]*"[^"]+"' \ |
| 31 | + telemetry/src/mod_wsgi/telemetry/__init__.py \ |
| 32 | + | sed -E 's/.*"([^"]+)".*/\1/')" |
| 33 | + if [ "$ACTUAL" != "$EXPECTED" ]; then |
| 34 | + echo "Tag version ($EXPECTED) does not match __version__ ($ACTUAL) in telemetry/src/mod_wsgi/telemetry/__init__.py" >&2 |
| 35 | + exit 1 |
| 36 | + fi |
| 37 | + echo "Version match: $ACTUAL" |
| 38 | + - name: "Update pip installation" |
| 39 | + run: python -m pip install --upgrade pip build |
| 40 | + - name: "Build sdist and wheel" |
| 41 | + working-directory: telemetry |
| 42 | + run: python -m build && ls -las dist |
| 43 | + - name: "Store built packages" |
| 44 | + uses: "actions/upload-artifact@v7" |
| 45 | + with: |
| 46 | + name: dist |
| 47 | + path: telemetry/dist/* |
| 48 | + |
| 49 | + tests: |
| 50 | + name: "Test mod_wsgi-telemetry package (Python ${{ matrix.python-version }})" |
| 51 | + runs-on: "ubuntu-24.04" |
| 52 | + needs: |
| 53 | + - build |
| 54 | + strategy: |
| 55 | + fail-fast: false |
| 56 | + matrix: |
| 57 | + python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"] |
| 58 | + steps: |
| 59 | + - uses: "actions/checkout@v6" |
| 60 | + - uses: "actions/setup-python@v6" |
| 61 | + with: |
| 62 | + python-version: "${{ matrix.python-version }}" |
| 63 | + - name: "Download built packages" |
| 64 | + uses: "actions/download-artifact@v8" |
| 65 | + with: |
| 66 | + name: dist |
| 67 | + path: dist |
| 68 | + - name: "Update pip installation" |
| 69 | + run: python -m pip install --upgrade pip setuptools wheel |
| 70 | + - name: "Install pytest" |
| 71 | + run: python -m pip install pytest |
| 72 | + - name: "Install mod_wsgi-telemetry from wheel" |
| 73 | + run: python -m pip install --verbose dist/mod_wsgi[-_]telemetry-[0-9]*.whl |
| 74 | + - name: "Run telemetry tests against wheel install" |
| 75 | + run: pytest telemetry/tests |
| 76 | + - name: "Uninstall mod_wsgi-telemetry" |
| 77 | + run: pip uninstall --yes mod_wsgi-telemetry |
| 78 | + - name: "Install mod_wsgi-telemetry from sdist" |
| 79 | + run: python -m pip install --verbose dist/mod_wsgi[-_]telemetry-[0-9]*.tar.gz |
| 80 | + - name: "Run telemetry tests against sdist install" |
| 81 | + run: pytest telemetry/tests |
| 82 | + - name: "Uninstall mod_wsgi-telemetry" |
| 83 | + run: pip uninstall --yes mod_wsgi-telemetry |
| 84 | + |
| 85 | + release: |
| 86 | + name: "Publish GitHub release" |
| 87 | + runs-on: "ubuntu-24.04" |
| 88 | + needs: |
| 89 | + - tests |
| 90 | + if: startsWith(github.ref, 'refs/tags/mod_wsgi-telemetry-') |
| 91 | + permissions: |
| 92 | + contents: write |
| 93 | + steps: |
| 94 | + - name: "Resolve version and prerelease status" |
| 95 | + id: meta |
| 96 | + run: | |
| 97 | + TAG="${GITHUB_REF_NAME}" |
| 98 | + VERSION="${TAG#mod_wsgi-telemetry-}" |
| 99 | + BASE_VERSION="$(echo "$VERSION" | sed -E 's/\.?(dev|rc)[0-9]+$//')" |
| 100 | + if [[ "$VERSION" == *dev* || "$VERSION" == *rc* ]]; then |
| 101 | + PRERELEASE="true" |
| 102 | + else |
| 103 | + PRERELEASE="false" |
| 104 | + fi |
| 105 | + echo "tag=$TAG" >> "$GITHUB_OUTPUT" |
| 106 | + echo "version=$VERSION" >> "$GITHUB_OUTPUT" |
| 107 | + echo "base_version=$BASE_VERSION" >> "$GITHUB_OUTPUT" |
| 108 | + echo "prerelease=$PRERELEASE" >> "$GITHUB_OUTPUT" |
| 109 | +
|
| 110 | + - name: "Download built packages" |
| 111 | + uses: "actions/download-artifact@v8" |
| 112 | + with: |
| 113 | + name: dist |
| 114 | + path: dist |
| 115 | + |
| 116 | + - name: "Generate SHA256SUMS" |
| 117 | + run: | |
| 118 | + cd dist |
| 119 | + sha256sum * > SHA256SUMS |
| 120 | + cat SHA256SUMS |
| 121 | +
|
| 122 | + - name: "Write release notes body" |
| 123 | + run: | |
| 124 | + VERSION="${{ steps.meta.outputs.version }}" |
| 125 | + DOCS_URL="https://modwsgi.readthedocs.io/en/latest/user-guides/external-telemetry-service.html" |
| 126 | + if [[ "$VERSION" == *dev* ]]; then |
| 127 | + cat > body.md <<EOF |
| 128 | + Development snapshot of mod_wsgi-telemetry. Not normally |
| 129 | + published to PyPi (occasionally uploaded to exercise the |
| 130 | + release pipeline). |
| 131 | +
|
| 132 | + User guide: ${DOCS_URL} |
| 133 | +
|
| 134 | + To test, install the attached wheel: |
| 135 | +
|
| 136 | + pip install mod_wsgi_telemetry-${VERSION}-py3-none-any.whl |
| 137 | +
|
| 138 | + Or build from the attached source distribution: |
| 139 | +
|
| 140 | + tar xf mod_wsgi_telemetry-${VERSION}.tar.gz |
| 141 | + cd mod_wsgi_telemetry-${VERSION} |
| 142 | + pip install . |
| 143 | +
|
| 144 | + \`SHA256SUMS\` is attached for verification of the source and |
| 145 | + wheel archives. |
| 146 | + EOF |
| 147 | + elif [[ "$VERSION" == *rc* ]]; then |
| 148 | + cat > body.md <<EOF |
| 149 | + Release candidate for mod_wsgi-telemetry. |
| 150 | +
|
| 151 | + User guide: ${DOCS_URL} |
| 152 | +
|
| 153 | + May be installable from PyPi: |
| 154 | +
|
| 155 | + pip install mod_wsgi-telemetry==${VERSION} |
| 156 | +
|
| 157 | + If \`pip\` reports the version is unavailable, this candidate |
| 158 | + either has not been uploaded yet or is not being published to |
| 159 | + PyPi. Install the attached wheel instead: |
| 160 | +
|
| 161 | + pip install mod_wsgi_telemetry-${VERSION}-py3-none-any.whl |
| 162 | +
|
| 163 | + Or build from the attached source distribution: |
| 164 | +
|
| 165 | + tar xf mod_wsgi_telemetry-${VERSION}.tar.gz |
| 166 | + cd mod_wsgi_telemetry-${VERSION} |
| 167 | + pip install . |
| 168 | +
|
| 169 | + \`SHA256SUMS\` is attached for verification of the source and |
| 170 | + wheel archives. |
| 171 | + EOF |
| 172 | + else |
| 173 | + cat > body.md <<EOF |
| 174 | + User guide: ${DOCS_URL} |
| 175 | +
|
| 176 | + Install from PyPi (recommended): |
| 177 | +
|
| 178 | + pip install mod_wsgi-telemetry==${VERSION} |
| 179 | +
|
| 180 | + The mod_wsgi-telemetry package is versioned independently of |
| 181 | + mod_wsgi itself. |
| 182 | +
|
| 183 | + PyPi uploads follow each GitHub release; if \`pip\` reports the |
| 184 | + version is unavailable, the matching PyPi upload may not have |
| 185 | + happened yet. |
| 186 | +
|
| 187 | + Source archive and wheel attached together with \`SHA256SUMS\` |
| 188 | + for verification. |
| 189 | + EOF |
| 190 | + fi |
| 191 | + cat body.md |
| 192 | +
|
| 193 | + - name: "Create GitHub release" |
| 194 | + env: |
| 195 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 196 | + GH_REPO: ${{ github.repository }} |
| 197 | + run: | |
| 198 | + FLAGS=() |
| 199 | + if [[ "${{ steps.meta.outputs.prerelease }}" == "true" ]]; then |
| 200 | + FLAGS+=("--prerelease") |
| 201 | + fi |
| 202 | + gh release create "${{ steps.meta.outputs.tag }}" \ |
| 203 | + --title "mod_wsgi-telemetry ${{ steps.meta.outputs.version }}" \ |
| 204 | + --notes-file body.md \ |
| 205 | + "${FLAGS[@]}" \ |
| 206 | + dist/* |
| 207 | +
|
| 208 | + publish: |
| 209 | + name: "Publish to PyPi" |
| 210 | + runs-on: "ubuntu-24.04" |
| 211 | + needs: |
| 212 | + - release |
| 213 | + if: startsWith(github.ref, 'refs/tags/mod_wsgi-telemetry-') |
| 214 | + environment: pypi-mod-wsgi-telemetry |
| 215 | + permissions: |
| 216 | + id-token: write |
| 217 | + steps: |
| 218 | + - name: "Download built packages" |
| 219 | + uses: "actions/download-artifact@v8" |
| 220 | + with: |
| 221 | + name: dist |
| 222 | + path: dist |
| 223 | + - name: "Publish to PyPi" |
| 224 | + uses: "pypa/gh-action-pypi-publish@release/v1" |
| 225 | + with: |
| 226 | + packages-dir: dist/ |
0 commit comments