-
Notifications
You must be signed in to change notification settings - Fork 0
425 lines (361 loc) · 12.9 KB
/
build-and-release.yml
File metadata and controls
425 lines (361 loc) · 12.9 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
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
name: Build and Release
on:
push:
branches: [ main, dev ]
tags: [ 'v*' ]
pull_request:
branches: [ main, dev ]
workflow_dispatch:
env:
NODE_VERSION: '18'
REGISTRY_URL: 'https://registry.npmjs.org'
jobs:
build-core:
name: Build Core Package
runs-on: ubuntu-latest
outputs:
core-version: ${{ steps.core-info.outputs.version }}
core-package: ${{ steps.core-info.outputs.package }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'npm'
- name: Install root dependencies
run: npm ci
- name: Build core package
run: npm run build:core
- name: Get core package info
id: core-info
run: |
cd npm
echo "version=$(node -p "require('./package.json').version")" >> $GITHUB_OUTPUT
echo "package=$(node -p "require('./package.json').name")" >> $GITHUB_OUTPUT
- name: Upload core package
uses: actions/upload-artifact@v4
with:
name: core-package
path: npm/
retention-days: 7
build-server:
name: Build Server Package
runs-on: ubuntu-latest
needs: build-core
outputs:
server-version: ${{ steps.server-info.outputs.version }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'npm'
- name: Download core package
uses: actions/download-artifact@v4
with:
name: core-package
path: npm/
- name: Install dependencies
run: npm ci
- name: Build server package
run: npm run build:server
- name: Get server package info
id: server-info
run: |
cd server
echo "version=$(git log -1 --format=%cs | tr '-' '.')" >> $GITHUB_OUTPUT
- name: Upload server artifacts
uses: actions/upload-artifact@v4
with:
name: server-artifacts
path: |
server/
dist/
retention-days: 7
build-docker:
name: Build & Push Docker Image
runs-on: ubuntu-latest
needs: [build-core, build-server]
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ghcr.io/${{ github.repository_owner }}/ldap-gateway
tags: |
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=ref,event=branch
type=raw,value=latest,enable=${{ github.ref == 'refs/heads/main' }}
type=sha,prefix=
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
file: server/test/e2e/Dockerfile.server
platforms: linux/amd64,linux/arm64
push: ${{ github.event_name != 'pull_request' && github.ref != 'refs/heads/dev' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
build-packages:
name: Build Distribution Packages
runs-on: ubuntu-latest
needs: [build-core, build-server]
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'npm'
- name: Install nfpm
run: |
cd /tmp
rm -f nfpm nfpm.tar.gz
curl -L https://github.com/goreleaser/nfpm/releases/download/v2.43.4/nfpm_2.43.4_Linux_x86_64.tar.gz -o nfpm.tar.gz
tar -xzf nfpm.tar.gz nfpm
sudo mv nfpm /usr/local/bin/nfpm
rm nfpm.tar.gz
nfpm --version
- name: Download artifacts
uses: actions/download-artifact@v4
with:
name: server-artifacts
path: ./
- name: Build packages
env:
VERSION: ${{ needs.build-server.outputs.server-version }}
run: |
mkdir -p dist/packages
nfpm package \
--config nfpm/nfpm.yaml \
--packager deb \
--target dist/packages/ldap-gateway_${VERSION}-1_all.deb
nfpm package \
--config nfpm/nfpm.yaml \
--packager rpm \
--target dist/packages/ldap-gateway-${VERSION}-1.noarch.rpm
- name: Verify packages
run: |
echo "Built packages:"
ls -lh dist/packages/
echo "Package info for .deb:"
dpkg-deb --info dist/packages/*.deb || true
echo "Package info for .rpm:"
rpm -qip dist/packages/*.rpm || true
- name: Upload packages
uses: actions/upload-artifact@v4
with:
name: packages
path: dist/packages/
retention-days: 30
create-release:
name: Create Release Assets
runs-on: ubuntu-latest
needs: [build-core, build-server, build-packages]
if: startsWith(github.ref, 'refs/tags/v')
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'npm'
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: ./artifacts
- name: Organize release assets
run: |
# Create dist directory
mkdir -p dist
# Copy packages
cp artifacts/packages/* dist/ 2>/dev/null || echo "No packages"
# Copy binary if needed for tarball creation
cp artifacts/server-artifacts/dist/ldap-gateway dist/ 2>/dev/null || echo "No binary"
# Show what we have
echo "Release assets prepared:"
ls -lh dist/
- name: Install dependencies
run: npm ci
- name: Create release tarball
run: |
./create-release.sh
- name: Generate checksums
run: |
cd dist
sha256sum *.deb *.rpm > checksums.txt 2>/dev/null || echo "No packages to checksum"
cat checksums.txt
- name: Extract version
id: version
run: echo "version=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT
- name: Create GitHub Release
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ github.ref_name }}
name: Release ${{ steps.version.outputs.version }}
draft: false
prerelease: ${{ contains(steps.version.outputs.version, '-') }}
files: |
dist/ldap-gateway_*.deb
dist/ldap-gateway-*.rpm
dist/checksums.txt
body: |
## LDAP Gateway ${{ steps.version.outputs.version }}
### Installation Options
**Binary Release (All Platforms):**
```bash
curl -LO https://github.com/${{ github.repository }}/releases/download/${{ github.ref_name }}/ldap-gateway-${{ steps.version.outputs.version }}.tar.gz
tar -xzf ldap-gateway-${{ steps.version.outputs.version }}.tar.gz
cd ldap-gateway-${{ steps.version.outputs.version }}
sudo ./install.sh
```
**Ubuntu/Debian:**
```bash
curl -LO https://github.com/${{ github.repository }}/releases/download/${{ github.ref_name }}/ldap-gateway_${{ steps.version.outputs.version }}-1_all.deb
sudo dpkg -i ldap-gateway_${{ steps.version.outputs.version }}-1_all.deb
```
**RHEL/CentOS/Fedora:**
```bash
curl -LO https://github.com/${{ github.repository }}/releases/download/${{ github.ref_name }}/ldap-gateway-${{ steps.version.outputs.version }}-1.noarch.rpm
sudo rpm -i ldap-gateway-${{ steps.version.outputs.version }}-1.noarch.rpm
```
### Changes
See [CHANGELOG.md](CHANGELOG.md) for detailed changes.
### Verification
All release assets include SHA256 checksums in `checksums.txt`.
dev-release:
name: Dev Pre-Release
runs-on: ubuntu-latest
needs: [build-core, build-server, build-packages]
if: github.ref == 'refs/heads/dev' && github.event_name == 'push'
permissions:
contents: write
steps:
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: ./artifacts
- name: Organize dev release assets
run: |
mkdir -p dist
cp artifacts/packages/*.deb dist/ 2>/dev/null || true
cp artifacts/packages/*.rpm dist/ 2>/dev/null || true
# Rename packages with dev- prefix for clarity
cd dist
for f in *.deb *.rpm; do
[ -f "$f" ] && mv "$f" "dev-${f}"
done
echo "Dev release assets:"
ls -lh
- name: Generate checksums
run: |
cd dist
sha256sum * > checksums.txt 2>/dev/null || true
cat checksums.txt
- name: Update dev-latest release
uses: softprops/action-gh-release@v1
with:
tag_name: dev-latest
name: "Dev Build (latest from dev branch)"
draft: false
prerelease: true
make_latest: false
files: |
dist/*
body: |
## Dev Build — ${{ github.sha }}
**This is an automated pre-release from the `dev` branch.**
Updated on every push to `dev`. Not for production use.
Commit: ${{ github.sha }}
Date: ${{ github.event.head_commit.timestamp }}
### Install on Proxmox (Debian/Ubuntu)
```bash
ldap-gateway-upgrade --dev
```
Or manually:
```bash
curl -LO https://github.com/${{ github.repository }}/releases/download/dev-latest/dev-ldap-gateway_${{ needs.build-server.outputs.server-version }}-1_all.deb
sudo dpkg -i dev-ldap-gateway_*_all.deb
```
publish-npm:
name: Publish to npm
runs-on: ubuntu-latest
needs: [build-core, build-server]
if: startsWith(github.ref, 'refs/tags/v')
environment: npm-publish
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'npm'
registry-url: ${{ env.REGISTRY_URL }}
- name: Download core package
uses: actions/download-artifact@v4
with:
name: core-package
path: npm/
- name: Install dependencies
run: npm ci
- name: Publish core package
run: |
cd npm
npm publish --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
update-homebrew:
name: Update Homebrew Formula
runs-on: ubuntu-latest
needs: create-release
if: startsWith(github.ref, 'refs/tags/v') && !contains(github.ref_name, '-')
steps:
- name: Extract version and assets
id: release-info
run: |
VERSION=${GITHUB_REF#refs/tags/v}
echo "version=$VERSION" >> $GITHUB_OUTPUT
# Download the tarball to get SHA256
curl -sL "https://github.com/${{ github.repository }}/releases/download/${{ github.ref_name }}/ldap-gateway-$VERSION.tar.gz" | sha256sum | cut -d' ' -f1 > sha256
echo "sha256=$(cat sha256)" >> $GITHUB_OUTPUT
- name: Update Homebrew formula
uses: peter-evans/repository-dispatch@v2
with:
token: ${{ secrets.HOMEBREW_TAP_TOKEN }}
repository: ${{ github.repository_owner }}/homebrew-tap
event-type: update-formula
client-payload: |
{
"formula": "ldap-gateway",
"version": "${{ steps.release-info.outputs.version }}",
"url": "https://github.com/${{ github.repository }}/releases/download/${{ github.ref_name }}/ldap-gateway-${{ steps.release-info.outputs.version }}.tar.gz",
"sha256": "${{ steps.release-info.outputs.sha256 }}"
}