Skip to content

Commit e8a6bcc

Browse files
committed
Build packages with custom user
1 parent 366bbc3 commit e8a6bcc

14 files changed

Lines changed: 353 additions & 30 deletions

File tree

.github/workflows/lint-web.yml

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,20 +28,30 @@ jobs:
2828
uses: actions/checkout@v6
2929
with:
3030
submodules: recursive
31-
- uses: actions/setup-node@v6
31+
32+
- name: Install NodeJS
33+
uses: actions/setup-node@v6
3234
with:
3335
node-version: 25
34-
- name: install deps
35-
working-directory: ./web
36-
run: |
37-
npm i -g pnpm
38-
pnpm i --frozen-lockfile
36+
37+
- name: Install pnpm
38+
uses: pnpm/action-setup@v6
39+
with:
40+
cache: true
41+
version: 10
42+
43+
- name: Install deps
44+
working-directory: web
45+
run: pnpm install --frozen-lockfile
46+
3947
- name: Build translations
40-
working-directory: ./web
48+
working-directory: web
4149
run: pnpm dlx @inlang/paraglide-js compile --project ./project.inlang --outdir ./src/paraglide
50+
4251
- name: Lint
43-
working-directory: ./web
52+
working-directory: web
4453
run: pnpm lint
54+
4555
- name: Audit
46-
working-directory: ./web
56+
working-directory: web
4757
run: pnpm audit --prod --ignore-unfixable

.github/workflows/release.yml

Lines changed: 54 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
name: Make a new release
22
on:
33
push:
4+
branches:
5+
- pkg
46
tags:
57
- v*.*.*
68

@@ -55,6 +57,8 @@ jobs:
5557
with:
5658
draft: true
5759
generate_release_notes: true
60+
release_name: pkg
61+
tag_name: pkg
5862

5963
create-sbom:
6064
needs:
@@ -141,45 +145,85 @@ jobs:
141145
with:
142146
fpm_args:
143147
"defguard-proxy-${{ env.VERSION }}-x86_64-unknown-linux-gnu=/usr/bin/defguard-proxy
144-
defguard-proxy.service=/usr/lib/systemd/system/defguard-proxy.service
148+
linux/defguard-proxy.service=/usr/lib/systemd/system/defguard-proxy.service
145149
example-config.toml=/etc/defguard/proxy.toml"
146-
fpm_opts: "--architecture amd64 --output-type deb --version ${{ env.VERSION }} --package defguard-proxy-${{ env.VERSION }}-x86_64-unknown-linux-gnu.deb"
150+
fpm_opts:
151+
"--architecture amd64
152+
--output-type deb
153+
--version ${{ env.VERSION }}
154+
--package defguard-proxy-${{ env.VERSION }}-x86_64-unknown-linux-gnu.deb
155+
--before-install linux/preinst
156+
--after-install linux/postinst
157+
--before-remove linux/prerm
158+
--after-remove linux/postrm"
147159

148160
- name: Build aarch64 DEB package
149161
uses: defGuard/fpm-action@main
150162
with:
151163
fpm_args:
152164
"defguard-proxy-${{ env.VERSION }}-aarch64-unknown-linux-gnu=/usr/bin/defguard-proxy
153-
defguard-proxy.service=/usr/lib/systemd/system/defguard-proxy.service
165+
linux/defguard-proxy.service=/usr/lib/systemd/system/defguard-proxy.service
154166
example-config.toml=/etc/defguard/proxy.toml"
155-
fpm_opts: "--architecture arm64 --output-type deb --version ${{ env.VERSION }} --package defguard-proxy-${{ env.VERSION }}-aarch64-unknown-linux-gnu.deb"
167+
fpm_opts:
168+
"--architecture arm64
169+
--output-type deb
170+
--version ${{ env.VERSION }}
171+
--package defguard-proxy-${{ env.VERSION }}-aarch64-unknown-linux-gnu.deb
172+
--before-install linux/preinst
173+
--after-install linux/postinst
174+
--before-remove linux/prerm
175+
--after-remove linux/postrm"
156176

157177
- name: Build x86_64 RPM package
158178
uses: defGuard/fpm-action@main
159179
with:
160180
fpm_args:
161181
"defguard-proxy-${{ env.VERSION }}-x86_64-unknown-linux-gnu=/usr/bin/defguard-proxy
162-
defguard-proxy.service=/usr/lib/systemd/system/defguard-proxy.service
182+
linux/defguard-proxy.service=/usr/lib/systemd/system/defguard-proxy.service
163183
example-config.toml=/etc/defguard/proxy.toml"
164-
fpm_opts: "--architecture amd64 --output-type rpm --version ${{ env.VERSION }} --package defguard-proxy-${{ env.VERSION }}-x86_64-unknown-linux-gnu.rpm"
184+
fpm_opts:
185+
"--architecture amd64
186+
--output-type rpm
187+
--version ${{ env.VERSION }}
188+
--package defguard-proxy-${{ env.VERSION }}-x86_64-unknown-linux-gnu.rpm
189+
--before-install linux/preinst
190+
--after-install linux/postinst
191+
--before-remove linux/prerm
192+
--after-remove linux/postrm"
165193

166194
- name: Build aarch64 RPM package
167195
uses: defGuard/fpm-action@main
168196
with:
169197
fpm_args:
170198
"defguard-proxy-${{ env.VERSION }}-aarch64-unknown-linux-gnu=/usr/bin/defguard-proxy
171-
defguard-proxy.service=/usr/lib/systemd/system/defguard-proxy.service
199+
linux/defguard-proxy.service=/usr/lib/systemd/system/defguard-proxy.service
172200
example-config.toml=/etc/defguard/proxy.toml"
173-
fpm_opts: "--architecture arm64 --output-type rpm --version ${{ env.VERSION }} --package defguard-proxy-${{ env.VERSION }}-aarch64-unknown-linux-gnu.rpm"
201+
fpm_opts:
202+
"--architecture arm64
203+
--output-type rpm
204+
--version ${{ env.VERSION }}
205+
--package defguard-proxy-${{ env.VERSION }}-aarch64-unknown-linux-gnu.rpm
206+
--before-install linux/preinst
207+
--after-install linux/postinst
208+
--before-remove linux/prerm
209+
--after-remove linux/postrm"
174210

175211
- name: Build FreeBSD package
176212
uses: defGuard/fpm-action@main
177213
with:
178214
fpm_args:
179215
"defguard-proxy-${{ env.VERSION }}-x86_64-unknown-freebsd=/usr/local/bin/defguard-proxy
180-
defguard-proxy.service.freebsd=/usr/local/etc/rc.d/defguard-proxy
216+
freebsd/defguard-proxy=/usr/local/etc/rc.d/defguard-proxy
181217
example-config.toml=/etc/defguard/proxy.toml"
182-
fpm_opts: "--architecture amd64 --output-type freebsd --version ${{ env.VERSION }} --package defguard-proxy-${{ env.VERSION }}_x86_64-unknown-freebsd.pkg --freebsd-osversion '*' --depends openssl"
218+
fpm_opts:
219+
"--architecture amd64
220+
--output-type freebsd
221+
--version ${{ env.VERSION }}
222+
--package defguard-proxy-${{ env.VERSION }}_x86_64-unknown-freebsd.pkg
223+
--freebsd-osversion '*'
224+
--depends openssl
225+
--before-install freebsd/preinst
226+
--after-install freebsd/postinst"
183227

184228
- name: Upload Linux x86_64 archive
185229
uses: shogo82148/actions-upload-release-asset@v1

Cargo.lock

Lines changed: 7 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ rustls-pki-types = "1"
1515
# base `axum` deps
1616
axum = { version = "0.8", features = ["ws"] }
1717
axum-client-ip = "0.7"
18-
axum-extra = { version = "0.10", features = [
18+
axum-extra = { version = "0.12", features = [
1919
"cookie",
2020
"cookie-private",
2121
"typed-header",

freebsd/postrm

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/sh
2+
set -e
3+
4+
USERNAME=defguard
5+
6+
if id -u ${USERNAME} >/dev/null 2>&1
7+
then
8+
pw user del -n ${USERNAME}
9+
fi

freebsd/preinst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/sh
2+
set -e
3+
4+
USERNAME=defguard
5+
6+
if ! id -u ${USERNAME} >/dev/null 2>&1
7+
then
8+
pw -q user add -n ${USERNAME} -g nogroup -c "Defguard" -d /nonexistent -s /usr/sbin/nologin
9+
fi
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
[Unit]
2-
Description=defguard proxy service
2+
Description=Defguard Edge service
33
Documentation=https://defguard.gitbook.io/defguard/
44
Wants=network-online.target
55
After=network-online.target
66

77
[Service]
8-
DynamicUser=yes
98
User=defguard
9+
Group=defguard
1010
ExecReload=/bin/kill -HUP $MAINPID
1111
ExecStart=/usr/bin/defguard-proxy --config /etc/defguard/proxy.toml
1212
KillMode=process

linux/postinst

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/bin/sh
2+
set -e
3+
4+
SERVICE_NAME='defguard-proxy'
5+
6+
case "${1}" in
7+
1 | configure)
8+
if [ -x /usr/bin/systemctl ]; then
9+
/usr/bin/systemctl daemon-reload
10+
/usr/bin/systemctl enable ${SERVICE_NAME}
11+
/usr/bin/systemctl --no-block start ${SERVICE_NAME}
12+
fi
13+
;;
14+
abort-upgrade | abort-remove | abort-deconfigure)
15+
if [ -x /usr/bin/systemctl ]; then
16+
/usr/bin/systemctl daemon-reload
17+
if /usr/bin/systemctl is-enabled ${SERVICE_NAME} >/dev/null 2>&1; then
18+
/usr/bin/systemctl start ${SERVICE_NAME} || true
19+
fi
20+
fi
21+
;;
22+
esac

linux/postrm

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/bin/sh
2+
set -e
3+
4+
USERNAME=defguard
5+
6+
case $1 in
7+
0)
8+
if [ "${1}" = 'purge' ]; then
9+
userdel ${USERNAME} >/dev/null || true
10+
fi
11+
;;
12+
1)
13+
if [ -x /usr/bin/systemctl ]; then
14+
/usr/bin/systemctl daemon-reload >/dev/null 2>&1 || true
15+
fi
16+
;;
17+
esac

0 commit comments

Comments
 (0)