forked from CityOfBoston/OpenContext
-
Notifications
You must be signed in to change notification settings - Fork 0
321 lines (277 loc) · 10.6 KB
/
release.yml
File metadata and controls
321 lines (277 loc) · 10.6 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
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
---
name: Release
on:
push:
tags:
- "v*.*.*" # Triggers on version tags like v1.0.0, v2.1.3, etc.
workflow_dispatch: # Allows manual triggering
inputs:
version:
description: "Version tag (e.g., v1.0.0)"
required: true
type: string
env:
BINARY_NAME: opencontext-client
GO_VERSION: "1.21"
jobs:
build:
name: Build binaries
runs-on: ubuntu-latest
permissions:
contents: write # Required to create releases and upload assets
strategy:
matrix:
include:
- goos: darwin
goarch: amd64
output: opencontext-client-darwin-amd64
- goos: darwin
goarch: arm64
output: opencontext-client-darwin-arm64
- goos: linux
goarch: amd64
output: opencontext-client-linux-amd64
- goos: linux
goarch: arm64
output: opencontext-client-linux-arm64
- goos: windows
goarch: amd64
output: opencontext-client-windows-amd64.exe
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0 # Fetch all history for proper versioning
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
- name: Get version from tag
id: get_version
run: |
if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
VERSION="${{ github.event.inputs.version }}"
else
VERSION=${GITHUB_REF#refs/tags/}
fi
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "Version: $VERSION"
- name: Build binary
working-directory: ./client
env:
GOOS: ${{ matrix.goos }}
GOARCH: ${{ matrix.goarch }}
CGO_ENABLED: 0
run: |
go build -ldflags="-s -w -X main.version=${{ steps.get_version.outputs.version }}" \
-o ../${{ matrix.output }} \
main.go
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.output }}
path: ${{ matrix.output }}
retention-days: 7
build-lambda-zip:
name: Build Lambda ZIP
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python 3.11
uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Install uv
uses: astral-sh/setup-uv@v4
- name: Get version from tag
id: get_version
run: |
if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
VERSION="${{ github.event.inputs.version }}"
else
VERSION=${GITHUB_REF#refs/tags/}
fi
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "Version: $VERSION"
- name: Install Python dependencies into package directory
# Pin --python-version and --python-platform so wheel resolution is
# independent of the runner's ambient interpreter and OS. Matches
# the uv path in scripts/deploy.sh and the python3.11 runtime pinned
# in terraform/aws/main.tf.
run: |
uv pip install -r requirements.txt \
--target ./package \
--python-platform x86_64-manylinux2014 \
--python-version 3.11 \
--no-compile
- name: Copy application code into package
run: |
cp -r server/ package/server/
cp -r plugins/ package/plugins/
cp -r core/ package/core/
cp examples/boston-opendata/config.yaml package/config.yaml
- name: Create Lambda ZIP
# Use Python stdlib zipfile to match scripts/deploy.sh and
# .github/workflows/infra.yml — avoids depending on the `zip` binary.
run: |
cd package
python - "../opencontext-lambda-${{ steps.get_version.outputs.version }}.zip" <<'PY'
import os
import sys
import zipfile
zip_path = sys.argv[1]
with zipfile.ZipFile(zip_path, "w", zipfile.ZIP_DEFLATED) as z:
for root, _, files in os.walk("."):
for name in files:
path = os.path.join(root, name)
z.write(path, os.path.relpath(path, "."))
PY
- name: Upload Lambda ZIP artifact
uses: actions/upload-artifact@v4
with:
name: lambda-zip
path: opencontext-lambda-${{ steps.get_version.outputs.version }}.zip
retention-days: 7
release:
name: Create release
needs: [build, build-lambda-zip]
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Get version from tag
id: get_version
run: |
if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
VERSION="${{ github.event.inputs.version }}"
else
VERSION=${GITHUB_REF#refs/tags/}
fi
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "Version: $VERSION"
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: ./artifacts
- name: Debug - Show artifact structure before flattening
run: |
echo "=== Artifact structure before flattening ==="
find artifacts -type f -o -type d | sort
echo ""
echo "=== Directory tree ==="
tree artifacts || find artifacts -print | sed -e 's;[^/]*/;|____;g;s;____|; |;g'
- name: Flatten artifact structure
run: |
cd artifacts
echo "=== Flattening artifacts ==="
# Find all release files (binaries + lambda zip) in subdirectories and move to root
find . -mindepth 2 -type f \( -name "opencontext-client-*" -o -name "opencontext-lambda-*" \) | while read file; do
filename=$(basename "$file")
dirname=$(dirname "$file")
tempname=".tmp_${filename}"
echo "Moving: $file to $filename (via $tempname)"
mv "$file" "$tempname"
rmdir "$dirname" 2>/dev/null || true
mv "$tempname" "$filename"
done
# Remove any remaining empty subdirectories
find . -mindepth 1 -type d -empty -delete
echo "=== Flattening complete ==="
- name: Debug - Show artifact structure after flattening
run: |
echo "=== Artifact structure after flattening ==="
ls -lah artifacts/
echo ""
echo "=== Finding all binaries ==="
find artifacts -type f -name "opencontext-client-*"
- name: Generate checksums
run: |
cd artifacts
echo "=== Generating checksums ==="
find . -maxdepth 1 -type f \( -name "opencontext-client-*" -o -name "opencontext-lambda-*" \) -exec sha256sum {} \; > checksums.txt
echo "=== Checksums file contents ==="
cat checksums.txt
echo ""
echo "=== Verifying checksums.txt exists ==="
ls -lah checksums.txt
- name: Verify files before upload
run: |
echo "=== Files to be uploaded ==="
ls -lah artifacts/
echo ""
echo "=== Checking each release file ==="
for file in artifacts/opencontext-client-darwin-amd64 \
artifacts/opencontext-client-darwin-arm64 \
artifacts/opencontext-client-linux-amd64 \
artifacts/opencontext-client-linux-arm64 \
artifacts/opencontext-client-windows-amd64.exe; do
if [ -f "$file" ]; then
echo "Found: $file ($(du -h "$file" | cut -f1))"
else
echo "Missing: $file"
fi
done
LAMBDA_ZIP=$(find artifacts -maxdepth 1 -name "opencontext-lambda-*.zip" | head -1)
if [ -n "$LAMBDA_ZIP" ]; then
echo "Found: $LAMBDA_ZIP ($(du -h "$LAMBDA_ZIP" | cut -f1))"
else
echo "Missing: Lambda ZIP"
exit 1
fi
if [ -f "artifacts/checksums.txt" ]; then
echo "Found: artifacts/checksums.txt"
else
echo "Missing: artifacts/checksums.txt"
exit 1
fi
- name: Create Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ steps.get_version.outputs.version }}
name: Release ${{ steps.get_version.outputs.version }}
body: |
## Release ${{ steps.get_version.outputs.version }}
### Binaries
This release includes pre-built binaries for the following platforms:
- **macOS** (Intel): `opencontext-client-darwin-amd64`
- **macOS** (Apple Silicon): `opencontext-client-darwin-arm64`
- **Linux** (amd64): `opencontext-client-linux-amd64`
- **Linux** (arm64): `opencontext-client-linux-arm64`
- **Windows** (amd64): `opencontext-client-windows-amd64.exe`
### Lambda Package
- `opencontext-lambda-${{ steps.get_version.outputs.version }}.zip` — deploy-ready AWS Lambda package
### Installation
Download the appropriate binary for your platform and make it executable:
```bash
# macOS/Linux
chmod +x opencontext-client-<platform>
# Windows
# No action needed, .exe is ready to use
```
### Checksums
Verify your download using the checksums in `checksums.txt`:
```bash
sha256sum -c checksums.txt
```
### Usage
```bash
opencontext-client <lambda_url>
# Or set OPENCONTEXT_LAMBDA_URL environment variable
```
See the [README](https://github.com/${{ github.repository }}/blob/main/README.md) for more details.
files: |
artifacts/opencontext-client-darwin-amd64
artifacts/opencontext-client-darwin-arm64
artifacts/opencontext-client-linux-amd64
artifacts/opencontext-client-linux-arm64
artifacts/opencontext-client-windows-amd64.exe
artifacts/opencontext-lambda-*.zip
artifacts/checksums.txt
draft: false
prerelease: ${{ contains(steps.get_version.outputs.version, '-') || contains(steps.get_version.outputs.version, 'alpha') || contains(steps.get_version.outputs.version, 'beta') || contains(steps.get_version.outputs.version, 'rc') }}
generate_release_notes: true