|
1 | | -name: Release to PGXN |
| 1 | +name: Release |
2 | 2 |
|
3 | | -# Publishes a release to the PostgreSQL Extension Network (https://pgxn.org) when a |
4 | | -# version tag is pushed. Requires two repository secrets, from a PGXN Manager account |
5 | | -# (https://manager.pgxn.org): PGXN_USERNAME and PGXN_PASSWORD. |
| 3 | +# Builds release artifacts and publishes them when a version tag (v*) is pushed: |
| 4 | +# * debian - .deb packages for PostgreSQL 16/17/18 (Debian bookworm / PGDG) |
| 5 | +# * docker - ghcr.io image: PostgreSQL 18 + PostGIS + pg_table_range |
| 6 | +# * github-release - attaches the .deb files to the GitHub Release (tags only) |
| 7 | +# * pgxn - bundles the source and uploads it to https://pgxn.org (tags only) |
6 | 8 | # |
7 | | -# To cut a release: |
8 | | -# 1. Bump "version" in Cargo.toml and META.json (keep them identical). |
9 | | -# 2. Commit, then tag: git tag v0.1.0 && git push origin v0.1.0 |
10 | | -# The tag (without its leading "v") must match the META.json version. |
| 9 | +# workflow_dispatch runs the build jobs as a dry run (no pushes / publishes), so packaging |
| 10 | +# can be validated without cutting a release. |
| 11 | +# |
| 12 | +# Secrets required for the tagged release: |
| 13 | +# PGXN_USERNAME / PGXN_PASSWORD - a PGXN Manager account (https://manager.pgxn.org) |
| 14 | +# The Docker push uses the built-in GITHUB_TOKEN (no extra secret needed). |
11 | 15 |
|
12 | 16 | on: |
13 | 17 | push: |
14 | 18 | tags: |
15 | 19 | - "v*" |
| 20 | + workflow_dispatch: |
| 21 | + |
| 22 | +env: |
| 23 | + PGRX_VERSION: "0.18.1" |
16 | 24 |
|
17 | 25 | jobs: |
18 | | - release: |
19 | | - name: Bundle and release on PGXN |
| 26 | + debian: |
| 27 | + name: Debian package (PostgreSQL ${{ matrix.pg }}) |
| 28 | + runs-on: ubuntu-latest |
| 29 | + container: debian:bookworm |
| 30 | + strategy: |
| 31 | + fail-fast: false |
| 32 | + matrix: |
| 33 | + pg: ["16", "17", "18"] |
| 34 | + steps: |
| 35 | + - name: Install build dependencies and PGDG PostgreSQL ${{ matrix.pg }} |
| 36 | + run: | |
| 37 | + set -eux |
| 38 | + apt-get update |
| 39 | + apt-get install -y --no-install-recommends \ |
| 40 | + ca-certificates curl gnupg git build-essential pkg-config \ |
| 41 | + clang libclang-dev libreadline-dev zlib1g-dev flex bison |
| 42 | + curl -fsSL https://www.postgresql.org/media/keys/ACCC4CF8.asc \ |
| 43 | + | gpg --dearmor -o /usr/share/keyrings/pgdg.gpg |
| 44 | + echo "deb [signed-by=/usr/share/keyrings/pgdg.gpg] https://apt.postgresql.org/pub/repos/apt bookworm-pgdg main" \ |
| 45 | + > /etc/apt/sources.list.d/pgdg.list |
| 46 | + apt-get update |
| 47 | + apt-get install -y --no-install-recommends \ |
| 48 | + "postgresql-${{ matrix.pg }}" "postgresql-server-dev-${{ matrix.pg }}" |
| 49 | +
|
| 50 | + - uses: actions/checkout@v4 |
| 51 | + |
| 52 | + - name: Install Rust (toolchain from rust-toolchain.toml) |
| 53 | + run: | |
| 54 | + curl --proto '=https' --tlsv1.2 -fsSL https://sh.rustup.rs | sh -s -- -y --default-toolchain none |
| 55 | + echo "$HOME/.cargo/bin" >> "$GITHUB_PATH" |
| 56 | +
|
| 57 | + - name: Cache cargo |
| 58 | + uses: actions/cache@v4 |
| 59 | + with: |
| 60 | + path: | |
| 61 | + ~/.cargo/registry |
| 62 | + ~/.cargo/git |
| 63 | + ~/.cargo/bin |
| 64 | + key: deb-cargo-${{ env.PGRX_VERSION }}-${{ hashFiles('Cargo.lock') }} |
| 65 | + |
| 66 | + - name: Install cargo-pgrx |
| 67 | + run: | |
| 68 | + rustup show |
| 69 | + cargo install cargo-pgrx --version "=${{ env.PGRX_VERSION }}" --locked |
| 70 | +
|
| 71 | + - name: Build the extension for PostgreSQL ${{ matrix.pg }} |
| 72 | + run: | |
| 73 | + # cargo-pgrx needs a config.toml that knows this PostgreSQL; write a minimal one |
| 74 | + # (no `cargo pgrx init`, which would run initdb and fail as root in this container). |
| 75 | + mkdir -p ~/.pgrx |
| 76 | + printf '[configs]\npg%s = "%s"\n' "${{ matrix.pg }}" \ |
| 77 | + "/usr/lib/postgresql/${{ matrix.pg }}/bin/pg_config" > ~/.pgrx/config.toml |
| 78 | + cargo pgrx package --no-default-features --features "pg${{ matrix.pg }}" \ |
| 79 | + --pg-config "/usr/lib/postgresql/${{ matrix.pg }}/bin/pg_config" |
| 80 | +
|
| 81 | + - name: Build .deb |
| 82 | + run: bash packaging/build-deb.sh "${{ matrix.pg }}" |
| 83 | + |
| 84 | + - name: Upload .deb artifact |
| 85 | + uses: actions/upload-artifact@v4 |
| 86 | + with: |
| 87 | + name: deb-pg${{ matrix.pg }} |
| 88 | + path: target/deb/*.deb |
| 89 | + if-no-files-found: error |
| 90 | + |
| 91 | + docker: |
| 92 | + name: Docker image (ghcr.io) |
| 93 | + needs: debian |
| 94 | + runs-on: ubuntu-latest |
| 95 | + permissions: |
| 96 | + contents: read |
| 97 | + packages: write |
| 98 | + steps: |
| 99 | + - uses: actions/checkout@v4 |
| 100 | + |
| 101 | + - name: Download the PostgreSQL 18 .deb |
| 102 | + uses: actions/download-artifact@v4 |
| 103 | + with: |
| 104 | + name: deb-pg18 |
| 105 | + path: docker-deb |
| 106 | + |
| 107 | + - name: Compute image tags |
| 108 | + id: meta |
| 109 | + run: | |
| 110 | + repo="ghcr.io/${GITHUB_REPOSITORY_OWNER,,}/pg_table_range" |
| 111 | + tags="${repo}:18" |
| 112 | + push=false |
| 113 | + if [ "${GITHUB_REF_TYPE}" = "tag" ]; then |
| 114 | + tags="${tags},${repo}:${GITHUB_REF_NAME},${repo}:latest" |
| 115 | + push=true |
| 116 | + fi |
| 117 | + echo "tags=${tags}" >> "$GITHUB_OUTPUT" |
| 118 | + echo "push=${push}" >> "$GITHUB_OUTPUT" |
| 119 | +
|
| 120 | + - name: Set up Buildx |
| 121 | + uses: docker/setup-buildx-action@v3 |
| 122 | + |
| 123 | + - name: Log in to GHCR |
| 124 | + if: steps.meta.outputs.push == 'true' |
| 125 | + uses: docker/login-action@v3 |
| 126 | + with: |
| 127 | + registry: ghcr.io |
| 128 | + username: ${{ github.actor }} |
| 129 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 130 | + |
| 131 | + - name: Build and push image |
| 132 | + uses: docker/build-push-action@v6 |
| 133 | + with: |
| 134 | + context: . |
| 135 | + file: packaging/Dockerfile |
| 136 | + push: ${{ steps.meta.outputs.push }} |
| 137 | + tags: ${{ steps.meta.outputs.tags }} |
| 138 | + |
| 139 | + github-release: |
| 140 | + name: GitHub Release |
| 141 | + needs: debian |
| 142 | + if: github.ref_type == 'tag' |
| 143 | + runs-on: ubuntu-latest |
| 144 | + permissions: |
| 145 | + contents: write |
| 146 | + steps: |
| 147 | + - name: Download all .deb artifacts |
| 148 | + uses: actions/download-artifact@v4 |
| 149 | + with: |
| 150 | + pattern: deb-pg* |
| 151 | + path: debs |
| 152 | + merge-multiple: true |
| 153 | + |
| 154 | + - name: Create / update the GitHub Release |
| 155 | + uses: softprops/action-gh-release@v2 |
| 156 | + with: |
| 157 | + files: debs/*.deb |
| 158 | + generate_release_notes: true |
| 159 | + |
| 160 | + pgxn: |
| 161 | + name: Release on PGXN |
| 162 | + needs: debian |
| 163 | + if: github.ref_type == 'tag' |
20 | 164 | runs-on: ubuntu-latest |
21 | 165 | container: pgxn/pgxn-tools |
22 | 166 | env: |
23 | 167 | PGXN_USERNAME: ${{ secrets.PGXN_USERNAME }} |
24 | 168 | PGXN_PASSWORD: ${{ secrets.PGXN_PASSWORD }} |
25 | 169 | steps: |
26 | | - - name: Check out the release tag |
27 | | - uses: actions/checkout@v4 |
| 170 | + - uses: actions/checkout@v4 |
28 | 171 |
|
29 | 172 | - name: Verify META.json version matches the tag |
30 | 173 | run: | |
|
0 commit comments