-
Notifications
You must be signed in to change notification settings - Fork 0
299 lines (254 loc) · 11.2 KB
/
dev-build.yml
File metadata and controls
299 lines (254 loc) · 11.2 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
name: Development Build
on:
workflow_call:
inputs:
version:
description: 'Development version to build (optional - auto-calculated if not provided)'
required: false
type: string
workflow_dispatch:
inputs:
version:
description: 'Development version to build (optional - auto-calculated if not provided)'
required: false
type: string
permissions:
contents: write
jobs:
build-development-packages:
name: Packages
runs-on: self-hosted
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Set development version
id: version
run: |
# Use input version if provided, otherwise auto-calculate
if [ -n "${{ inputs.version }}" ]; then
DEV_VERSION="${{ inputs.version }}"
echo "Using provided version: $DEV_VERSION"
else
# Get current version from package.json
CURRENT_VERSION=$(node -p "require('./package.json').version")
# Split version into parts
IFS='.' read -ra VERSION_PARTS <<< "$CURRENT_VERSION"
MAJOR=${VERSION_PARTS[0]}
MINOR=${VERSION_PARTS[1]}
PATCH=${VERSION_PARTS[2]}
# Increment patch version for development (no -dev suffix in version)
NEW_PATCH=$((PATCH + 1))
DEV_VERSION="${MAJOR}.${MINOR}.${NEW_PATCH}"
echo "Current version: $CURRENT_VERSION"
echo "Auto-calculated development version: $DEV_VERSION"
fi
echo "VERSION=$DEV_VERSION" >> $GITHUB_ENV
echo "PACKAGE_NAME=armor-dev" >> $GITHUB_ENV
echo "ARCH=amd64" >> $GITHUB_ENV
# Debian Build Steps
- name: Checkout for Debian build
uses: actions/checkout@v6
- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version: '22'
cache: 'npm'
- name: Install dependencies
run: npm run cinstall:all
- name: Build frontend
run: npm run build
- name: Remove dev dependencies for packaging
run: |
# Remove dev dependencies after building but before packaging
rm -rf node_modules
npm run cinstall:backend:nodev
cd web && rm -rf node_modules && npm run cinstall:nodev
- name: Create Debian package structure
run: |
mkdir -p "${PACKAGE_NAME}_${VERSION}_${ARCH}"/{opt/armor/web,opt/armor,etc/systemd/system,var/lib/armor,var/log/armor,usr/share/man/man8,usr/share/man/man5,DEBIAN}
- name: Copy application files to Debian package
run: |
cp -r models routes middleware config utils services packaging app.js package.json "${PACKAGE_NAME}_${VERSION}_${ARCH}/opt/armor/"
cp -r node_modules "${PACKAGE_NAME}_${VERSION}_${ARCH}/opt/armor/"
cp -r web/dist "${PACKAGE_NAME}_${VERSION}_${ARCH}/opt/armor/web/dist"
# Keep public assets for Swagger theming
cp -r web/public "${PACKAGE_NAME}_${VERSION}_${ARCH}/opt/armor/web/public"
- name: Copy configuration files to Debian package
run: |
cp packaging/DEBIAN/systemd/armor.service "${PACKAGE_NAME}_${VERSION}_${ARCH}/etc/systemd/system/"
cp packaging/DEBIAN/postinst packaging/DEBIAN/prerm packaging/DEBIAN/postrm "${PACKAGE_NAME}_${VERSION}_${ARCH}/DEBIAN/"
- name: Install man pages
run: |
# Copy and compress man pages following Debian Policy
gzip -9 -c packaging/DEBIAN/man/armor.8 > "${PACKAGE_NAME}_${VERSION}_${ARCH}/usr/share/man/man8/armor.8.gz"
gzip -9 -c packaging/DEBIAN/man/armor.yaml.5 > "${PACKAGE_NAME}_${VERSION}_${ARCH}/usr/share/man/man5/armor.yaml.5.gz"
- name: Create Debian control file
run: |
cat > "${PACKAGE_NAME}_${VERSION}_${ARCH}/DEBIAN/control" << EOF
Package: armor-dev
Version: ${VERSION}
Section: misc
Priority: optional
Architecture: ${ARCH}
Maintainer: MarkProminic <MarkProminic@users.noreply.github.com>
Depends: nodejs (>= 22.0.0), sqlite3, openssl
Conflicts: armor
Description: Armor (Development) - Armor Reliably Manages Online Resources
A secure Node.js file server that provides directory listings with SHA256 checksums and authenticated file upload capabilities over HTTPS.
This is a development version.
Homepage: https://github.com/STARTcloud/armor
EOF
- name: Set Debian package permissions
run: |
find "${PACKAGE_NAME}_${VERSION}_${ARCH}" -type d -exec chmod 755 {} \;
find "${PACKAGE_NAME}_${VERSION}_${ARCH}" -type f -exec chmod 644 {} \;
chmod 755 "${PACKAGE_NAME}_${VERSION}_${ARCH}/DEBIAN"/{postinst,prerm,postrm}
- name: Build Debian package
run: |
dpkg-deb --build "${PACKAGE_NAME}_${VERSION}_${ARCH}" "${PACKAGE_NAME}_${VERSION}_${ARCH}.deb"
# OmniOS Build Steps
- name: Fresh checkout for OmniOS build
uses: actions/checkout@v6
with:
path: omnios-source
clean: true
- name: Clean OmniOS build directory
run: |
ssh ghrunner@omnios.packages.startcloud.com "rm -rf /local/builds/armor-dev/* /local/builds/armor-dev/.*" || true
- name: Sync source code to OmniOS
run: |
rsync -av \
--exclude='.git' \
--exclude='node_modules' \
--exclude='web/node_modules' \
--exclude='web/dist' \
--exclude='*.deb' \
omnios-source/ ghrunner@omnios.packages.startcloud.com:/local/builds/armor-dev/
- name: Build package on OmniOS
run: |
ssh ghrunner@omnios.packages.startcloud.com "
cd /local/builds/armor-dev &&
export PATH=/opt/ooce/bin:/opt/ooce/node-22/bin:\$PATH &&
export MAKE=gmake &&
export DEV_VERSION=${VERSION} &&
chmod +x packaging/omnios/build.sh &&
./packaging/omnios/build.sh
"
- name: Transfer OmniOS package back
run: |
rsync -av ghrunner@omnios.packages.startcloud.com:/local/builds/armor-dev/*.p5p ./ || echo "No .p5p files found"
- name: Upload Debian package to repository server
run: |
rsync -av ${PACKAGE_NAME}_*.deb startcloud@packages.debian.startcloud.com:/tmp/
- name: Add package to repository pool
run: |
ssh startcloud@packages.debian.startcloud.com "
mkdir -p /local/public/debian/pool/main/z/armor-dev
cp /tmp/${PACKAGE_NAME}_*.deb /local/public/debian/pool/main/z/armor-dev/
"
- name: Update repository Packages files for all suites
run: |
ssh startcloud@packages.debian.startcloud.com "
cd /local/public/debian
# Generate Packages files for each suite
for suite in bookworm trixie; do
dpkg-scanpackages --arch amd64 pool/ > dists/\$suite/main/binary-amd64/Packages
gzip -c dists/\$suite/main/binary-amd64/Packages > dists/\$suite/main/binary-amd64/Packages.gz
done
"
- name: Generate Release files for all suites
run: |
ssh startcloud@packages.debian.startcloud.com "
cd /local/public/debian
# Generate Release files for each suite
for suite in bookworm trixie; do
cd dists/\$suite
/local/generate-release.sh \$suite > Release
cd ../..
done
"
- name: Create stable distribution with proper Release file
run: |
ssh startcloud@packages.debian.startcloud.com "
cd /local/public/debian/dists
rm -rf stable 2>/dev/null || true
cp -r trixie stable
cd stable
/local/generate-release.sh stable > Release
"
- name: Sign repository for all suites including stable
run: |
ssh startcloud@packages.debian.startcloud.com "
cd /local/public/debian
# Sign each suite including stable
for suite in bookworm trixie stable; do
cd dists/\$suite
export GNUPGHOME=\$(mktemp -d /local/pgp/pgpkeys-XXXXXX)
cat /local/pgp/pgp-key.private | gpg --import
cat Release | gpg --default-key startcloud -abs > Release.gpg
cat Release | gpg --default-key startcloud -abs --clearsign > InRelease
rm -rf \$GNUPGHOME
cd ../..
done
"
- name: Publish OmniOS package to repository
run: |
ssh ghrunner@omnios.packages.startcloud.com "
cd /local/builds/armor-dev &&
pfexec pkgsend publish -d proto -s file:///local/public/r151054/pkg armor.p5m.final &&
pfexec pkgrepo refresh -s /local/public/r151054/pkg &&
pfexec svcadm restart pkg/server:r151054_STARTcloud
"
- name: Create development draft release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
# Create or update draft release for development version
RELEASE_TAG="v${VERSION}-dev"
RELEASE_TITLE="Development Release ${VERSION}"
RELEASE_NOTES="🚧 **Development Release** 🚧
This is an automated development build from the main branch.
**Version**: ${VERSION}
**Build Date**: $(date -u +%Y-%m-%dT%H:%M:%SZ)
**Commit**: ${{ github.sha }}
⚠️ **Warning**: This is a development release for testing purposes only. Use production releases for stable deployments.
## Packages
- \`armor-dev_${VERSION}_amd64.deb\` - Debian package
- \`armor-dev-${VERSION}.p5p\` - OmniOS package"
# Delete existing dev release if it exists
gh release delete "$RELEASE_TAG" --yes || true
# Create new draft release
gh release create "$RELEASE_TAG" --draft --title "$RELEASE_TITLE" --notes "$RELEASE_NOTES"
- name: Upload development packages to release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
RELEASE_TAG="v${VERSION}-dev"
# Upload Debian package
gh release upload "$RELEASE_TAG" "${PACKAGE_NAME}_${VERSION}_${ARCH}.deb" --clobber
# Upload OmniOS package if it exists
for file in *.p5p; do
if [ -f "$file" ]; then
echo "Uploading $file to draft release..."
gh release upload "$RELEASE_TAG" "$file" --clobber
fi
done
- name: Upload artifacts
uses: actions/upload-artifact@v6
with:
name: 'development-packages'
path: |
*.deb
*.p5p
retention-days: 30
- name: Clean up
run: |
ssh ghrunner@omnios.packages.startcloud.com "rm -rf /local/builds/armor-dev/*"
ssh startcloud@packages.debian.startcloud.com "rm -f /tmp/${PACKAGE_NAME}_*.deb"
- name: Summary
run: |
echo "Development packages built and published:"
echo "- Version: ${VERSION}"
echo "- Debian package: ${PACKAGE_NAME}_${VERSION}_${ARCH}.deb"
echo "- Draft release: v${VERSION}-dev"
echo "- Packages published to repositories"