Skip to content

Commit 88b4c63

Browse files
committed
feat(build): add Linux package support and streamline build config
- Add project name and specific binary configuration for https_proxy - Configure DEB and RPM package generation via nfpms - Include systemd service file and installation scripts - Add config file deployment to /etc/https_proxy/ - Limit builds to Linux (amd64, arm64) to focus on target platform - Add ldflags for binary optimization (-s -w) - Remove boilerplate comments and simplify goreleaser config This enables automated creation of distribution packages for Debian and RedHat-based systems with proper systemd integration and configuration management.
1 parent 92264db commit 88b4c63

4 files changed

Lines changed: 70 additions & 24 deletions

File tree

.goreleaser.yaml

Lines changed: 47 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,66 @@
1-
# This is an example .goreleaser.yml file with some sensible defaults.
2-
# Make sure to check the documentation at https://goreleaser.com
3-
4-
# The lines below are called `modelines`. See `:help modeline`
5-
# Feel free to remove those if you don't want/need to use them.
6-
# yaml-language-server: $schema=https://goreleaser.com/static/schema.json
7-
# vim: set ts=2 sw=2 tw=0 fo=cnqoj
8-
91
version: 2
102

3+
project_name: https_proxy
4+
115
before:
126
hooks:
13-
# You may remove this if you don't use go modules.
147
- go mod tidy
15-
# you may remove this if you don't need go generate
168
- go generate ./...
179

1810
builds:
19-
- env:
11+
- id: https-proxy
12+
main: ./main.go
13+
binary: https_proxy
14+
env:
2015
- CGO_ENABLED=0
16+
ldflags:
17+
- -s -w
18+
# - -linkmode external -extldflags '-static'
2119
goos:
2220
- linux
23-
- windows
24-
- darwin
21+
goarch:
22+
- amd64
23+
- arm64
2524

2625
archives:
27-
- formats: [tar.gz]
28-
# this name template makes the OS and Arch compatible with the results of `uname`.
26+
- id: default
27+
formats: [tar.gz]
2928
name_template: >-
30-
{{ .ProjectName }}_
31-
{{- title .Os }}_
32-
{{- if eq .Arch "amd64" }}x86_64
33-
{{- else if eq .Arch "386" }}i386
34-
{{- else }}{{ .Arch }}{{ end }}
35-
{{- if .Arm }}v{{ .Arm }}{{ end }}
36-
# use zip for windows archives
29+
{{ .ProjectName }}_{{- title .Os }}_{{- if eq .Arch "amd64" }}x86_64{{ else }}{{ .Arch }}{{ end }}
3730
format_overrides:
3831
- goos: windows
3932
formats: [zip]
4033

34+
nfpms:
35+
- id: https-proxy
36+
package_name: https-proxy
37+
file_name_template: "{{ .ProjectName }}_{{ .Version }}_{{ .Arch }}"
38+
maintainer: "hightemp <hightemp.unknown@gmail.com>"
39+
description: "Simple HTTP/HTTPS proxy server with basic authentication."
40+
license: MIT
41+
vendor: "hightemp"
42+
homepage: "https://github.com/hightemp/https_proxy"
43+
formats:
44+
- deb
45+
- rpm
46+
builds:
47+
- https-proxy
48+
bindir: /usr/bin
49+
contents:
50+
- src: config.example.yaml
51+
dst: /etc/https_proxy/config.yaml
52+
type: config
53+
file_info:
54+
mode: 0644
55+
- src: packaging/https_proxy.service
56+
dst: /lib/systemd/system/https_proxy.service
57+
type: config
58+
file_info:
59+
mode: 0644
60+
scripts:
61+
postinstall: "packaging/postinstall.sh"
62+
preremove: "packaging/preremove.sh"
63+
4164
changelog:
4265
sort: asc
4366
filters:
@@ -46,8 +69,8 @@ changelog:
4669
- "^test:"
4770

4871
release:
49-
footer: >-
72+
footer: |-
5073
5174
---
5275
53-
Released by [GoReleaser](https://github.com/goreleaser/goreleaser).
76+
Released by GoReleaser.

packaging/https_proxy.service

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
[Unit]
2+
Description=HTTPS proxy
3+
After=network.target
4+
5+
[Service]
6+
ExecStart=/usr/bin/https_proxy --config /etc/https_proxy/config.yaml
7+
Restart=on-failure
8+
9+
[Install]
10+
WantedBy=multi-user.target

packaging/postinstall.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/bin/sh
2+
set -e
3+
4+
if command -v systemctl >/dev/null 2>&1; then
5+
systemctl daemon-reload || true
6+
systemctl enable --now https_proxy.service || true
7+
fi

packaging/preremove.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/bin/sh
2+
if command -v systemctl >/dev/null 2>&1; then
3+
systemctl stop https_proxy.service || true
4+
systemctl disable https_proxy.service || true
5+
systemctl daemon-reload || true
6+
fi

0 commit comments

Comments
 (0)