|
| 1 | +name: release |
| 2 | + |
| 3 | +# Triggered by `v*` tags (push one with `make release`). Runs the test suite, |
| 4 | +# publishes the package to PyPI, then extracts the matching section from |
| 5 | +# docs/release-notes.md and publishes it as the GitHub Release body. Re-runs |
| 6 | +# idempotently update an existing release rather than failing. |
| 7 | + |
| 8 | +on: |
| 9 | + push: |
| 10 | + tags: |
| 11 | + - "v*" |
| 12 | + |
| 13 | +permissions: |
| 14 | + contents: write |
| 15 | + |
| 16 | +jobs: |
| 17 | + release: |
| 18 | + runs-on: ubuntu-latest |
| 19 | + timeout-minutes: 10 |
| 20 | + env: |
| 21 | + PYTHON_ENV: ci |
| 22 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 23 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 24 | + PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }} |
| 25 | + FLUID_FLAMEGRAPH_EXECUTABLE: "./flamegraph.pl" |
| 26 | + |
| 27 | + services: |
| 28 | + postgres: |
| 29 | + image: postgres:15 |
| 30 | + ports: |
| 31 | + - 5432:5432 |
| 32 | + env: |
| 33 | + POSTGRES_USER: postgres |
| 34 | + POSTGRES_PASSWORD: postgres |
| 35 | + POSTGRES_DB: test_db |
| 36 | + |
| 37 | + steps: |
| 38 | + - name: checkout code |
| 39 | + uses: actions/checkout@v4 |
| 40 | + with: |
| 41 | + fetch-depth: 0 |
| 42 | + - name: Set up Python |
| 43 | + uses: actions/setup-python@v5 |
| 44 | + with: |
| 45 | + python-version: "3.14" |
| 46 | + - name: Start Redis |
| 47 | + uses: supercharge/redis-github-action@1.2.0 |
| 48 | + with: |
| 49 | + redis-version: 7 |
| 50 | + - name: Install dependencies |
| 51 | + run: make install |
| 52 | + - name: Install flamegraph |
| 53 | + env: |
| 54 | + FG_PATH: "." |
| 55 | + run: ./.dev/install-flamegraph |
| 56 | + - name: run lint |
| 57 | + run: make lint-test |
| 58 | + - name: build docs |
| 59 | + run: make docs |
| 60 | + - name: tests |
| 61 | + run: make test |
| 62 | + - name: publish to PyPI |
| 63 | + run: make publish |
| 64 | + - name: Extract release notes |
| 65 | + run: | |
| 66 | + TAG="${GITHUB_REF_NAME}" |
| 67 | + awk -v tag="## ${TAG}" ' |
| 68 | + $0 == tag { in_section = 1; next } |
| 69 | + /^## / && in_section { exit } |
| 70 | + in_section { print } |
| 71 | + ' docs/release-notes.md > /tmp/notes.md |
| 72 | + if [ ! -s /tmp/notes.md ]; then |
| 73 | + echo "No section '## ${TAG}' found in docs/release-notes.md" >&2 |
| 74 | + exit 1 |
| 75 | + fi |
| 76 | + echo "--- extracted notes for ${TAG} ---" |
| 77 | + cat /tmp/notes.md |
| 78 | + - name: Publish GitHub Release |
| 79 | + run: | |
| 80 | + TAG="${GITHUB_REF_NAME}" |
| 81 | + if gh release view "$TAG" >/dev/null 2>&1; then |
| 82 | + gh release edit "$TAG" --notes-file /tmp/notes.md |
| 83 | + else |
| 84 | + gh release create "$TAG" --title "$TAG" --notes-file /tmp/notes.md |
| 85 | + fi |
0 commit comments