-
Notifications
You must be signed in to change notification settings - Fork 23
201 lines (192 loc) · 7.95 KB
/
Copy pathRelease.yml
File metadata and controls
201 lines (192 loc) · 7.95 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
# SPDX-FileCopyrightText: Tim Sutton
# SPDX-License-Identifier: MIT
name: 📦 Release
on:
push:
tags:
- 'v*'
jobs:
build-artifacts:
runs-on: ubuntu-latest
services:
postgres:
image: postgis/postgis:17-3.5
env:
POSTGRES_PASSWORD: ci
POSTGRES_USER: ci
POSTGRES_DB: ci
ports:
- 5432:5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
env:
PGHOST: localhost
PGPORT: '5432'
PGUSER: ci
PGPASSWORD: ci
PGDATABASE: ci
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install Nix
uses: DeterminateSystems/nix-installer-action@v22
- name: Resolve release version + previous tag
id: ver
run: |
set -euo pipefail
VERSION="$(tr -d '[:space:]' < VERSION)"
VTAG="v$VERSION"
if [ "$GITHUB_REF" != "refs/tags/$VTAG" ]; then
echo "::warning::tag '$GITHUB_REF' does not match VERSION '$VTAG'"
fi
PREV_TAG="$(git tag --sort=-v:refname | grep '^v' | grep -v "^$VTAG$" | head -1 || true)"
{
echo "version=$VERSION"
echo "tag=$VTAG"
echo "prev_tag=$PREV_TAG"
} >> "$GITHUB_OUTPUT"
echo "Resolved: VTAG=$VTAG PREV_TAG=${PREV_TAG:-(none)}"
- name: Build HEAD artifacts (composite + per-domain)
run: |
nix develop --command bash scripts/build_artifacts.sh \
--version "${{ steps.ver.outputs.tag }}" \
--out dist
- name: Build previous-tag composite for schema diff
if: steps.ver.outputs.prev_tag != ''
run: |
set -euo pipefail
PREV="${{ steps.ver.outputs.prev_tag }}"
git worktree add ../prev "$PREV"
for f in build_artifacts.sh build_artifacts.py ensure_pg.sh; do
[ -f "../prev/scripts/$f" ] || cp "scripts/$f" "../prev/scripts/$f"
done
( cd ../prev && nix develop "${{ github.workspace }}#" --command \
bash scripts/build_artifacts.sh \
--version "$PREV" \
--out "${{ github.workspace }}/dist-prev" \
--skip-gpkg )
git worktree remove --force ../prev
- name: Run migra schema diff vs previous tag
if: steps.ver.outputs.prev_tag != ''
run: |
set -euo pipefail
# Explicit filenames; pg-schema-*.sql also matches per-domain
# slices (pg-schema-NN-name-*.sql), so a glob can pick a slice
# that lacks cross-domain FK targets and fail to load.
BASE_BUNDLE="dist-prev/pg-schema-${{ steps.ver.outputs.prev_tag }}.sql"
HEAD_BUNDLE="dist/pg-schema-${{ steps.ver.outputs.tag }}.sql"
nix develop --command python3 scripts/schema_diff.py \
--base-bundle "$BASE_BUNDLE" \
--head-bundle "$HEAD_BUNDLE" \
--version "${{ steps.ver.outputs.tag }}" \
--base-label "${{ steps.ver.outputs.prev_tag }}" \
--head-label "${{ steps.ver.outputs.tag }}" \
--out dist
- name: Generate release notes
run: |
set -euo pipefail
VTAG="${{ steps.ver.outputs.tag }}"
PREV="${{ steps.ver.outputs.prev_tag }}"
{
echo "## $VTAG"
echo ""
if [ -n "$PREV" ]; then
echo "### Migrations since $PREV"
echo ""
echo "**PostgreSQL:**"
for f in $(git diff --name-only "$PREV" "$VTAG" -- 'sql/migrations/pg/v*.sql'); do
echo "- \`$f\`"
done
echo ""
echo "**GeoPackage:**"
for f in $(git diff --name-only "$PREV" "$VTAG" -- 'sql/migrations/gpkg/v*.sql'); do
echo "- \`$f\`"
done
echo ""
if [ -f "dist/schema-diff-${VTAG}.summary.md" ]; then
echo "### Schema diff vs $PREV"
echo ""
cat "dist/schema-diff-${VTAG}.summary.md"
fi
else
echo "Initial release."
fi
echo ""
echo "### What's in this release"
echo ""
echo "- **Composite SQL** (\`pg-schema-${VTAG}.sql\`) — full schema + fixtures, apply to an empty DB."
echo "- **Composite GeoPackage** (\`KartozaInfrastructureMapper-${VTAG}.gpkg\`) — everything in one file for QGIS."
echo "- **Per-domain SQL slices** (13) — bootstrap just one domain (e.g. \`pg-schema-07-fencing-${VTAG}.sql\`)."
echo "- **Per-domain GeoPackages** (13) — one-domain QGIS bundles."
echo "- **Migration tarballs** — apply forward migrations on top of an existing earlier-version DB."
if [ -f "dist/schema-diff-${VTAG}.sql" ]; then
echo "- **Schema diff** (\`schema-diff-${VTAG}.sql\`) — migra-generated ALTER statements."
fi
} > dist/RELEASE_NOTES.md
- name: Publish version-less "-latest" companion assets
# Stable URLs of the form
# https://github.com/<org>/<repo>/releases/latest/download/<file>
# require an exact filename match. Our versioned filenames embed the
# tag, so we ship a parallel set without the version so README/docs
# can hard-link to the always-current asset.
run: |
set -euo pipefail
VTAG="${{ steps.ver.outputs.tag }}"
cd dist
for src in \
"pg-schema-${VTAG}.sql" \
"pg-fixtures-${VTAG}.sql" \
"KartozaInfrastructureMapper-${VTAG}.gpkg" \
"pg-migrations-${VTAG}.tar.gz" \
"gpkg-migrations-${VTAG}.tar.gz" \
"schema-diff-${VTAG}.sql" \
"schema-diff-${VTAG}.summary.md"; do
[ -f "$src" ] || continue
# Strip the "-VTAG" segment from the filename to produce the
# -latest variant (e.g. pg-schema-v0.2.0.sql -> pg-schema-latest.sql).
stable="${src/-${VTAG}/-latest}"
cp "$src" "$stable"
done
# Per-domain slices: pg-schema-07-fencing-v0.2.0.sql -> pg-schema-07-fencing-latest.sql
for src in pg-schema-[0-9][0-9]-*-"${VTAG}".sql; do
[ -f "$src" ] || continue
stable="${src/-${VTAG}/-latest}"
cp "$src" "$stable"
done
for src in KartozaInfrastructureMapper-[0-9][0-9]-*-"${VTAG}".gpkg; do
[ -f "$src" ] || continue
stable="${src/-${VTAG}/-latest}"
cp "$src" "$stable"
done
- name: List release artifacts
run: ls -lh dist/
- name: Create GitHub release
uses: softprops/action-gh-release@v2
with:
name: ${{ steps.ver.outputs.tag }}
body_path: dist/RELEASE_NOTES.md
files: |
dist/pg-schema-${{ steps.ver.outputs.tag }}.sql
dist/pg-fixtures-${{ steps.ver.outputs.tag }}.sql
dist/KartozaInfrastructureMapper-${{ steps.ver.outputs.tag }}.gpkg
dist/pg-schema-*-${{ steps.ver.outputs.tag }}.sql
dist/KartozaInfrastructureMapper-*-${{ steps.ver.outputs.tag }}.gpkg
dist/pg-migrations-${{ steps.ver.outputs.tag }}.tar.gz
dist/gpkg-migrations-${{ steps.ver.outputs.tag }}.tar.gz
dist/schema-diff-${{ steps.ver.outputs.tag }}.sql
dist/schema-diff-${{ steps.ver.outputs.tag }}.summary.md
dist/MANIFEST.json
dist/RELEASE_NOTES.md
dist/pg-schema-latest.sql
dist/pg-fixtures-latest.sql
dist/KartozaInfrastructureMapper-latest.gpkg
dist/pg-schema-*-latest.sql
dist/KartozaInfrastructureMapper-*-latest.gpkg
dist/pg-migrations-latest.tar.gz
dist/gpkg-migrations-latest.tar.gz
dist/schema-diff-latest.sql
dist/schema-diff-latest.summary.md