Skip to content

Commit 295f75b

Browse files
packaging: GoReleaser for apt (.deb) and brew (self-hosted tap), no rpm
- .goreleaser.yaml replaces the hand-rolled release job: cross-platform tarballs (scp-and-run unchanged) + .deb with a hardened systemd unit + auto-updated Homebrew tap at githubflyideas/homebrew-tap - brew install githubflyideas/tap/pingping | dpkg -i pingping_*_amd64.deb - TAP_TOKEN secret wired so the tap formula updates itself on each release
1 parent 7fbe2cf commit 295f75b

3 files changed

Lines changed: 115 additions & 32 deletions

File tree

.github/workflows/release.yml

Lines changed: 9 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -5,40 +5,17 @@ on:
55
permissions:
66
contents: write
77
jobs:
8-
build:
8+
goreleaser:
99
runs-on: ubuntu-latest
1010
steps:
1111
- uses: actions/checkout@v4
12+
with: { fetch-depth: 0 }
1213
- uses: actions/setup-go@v5
14+
with: { go-version: '1.22' }
15+
- uses: goreleaser/goreleaser-action@v6
1316
with:
14-
go-version: '1.22'
15-
- name: test
16-
run: go test ./...
17-
- name: build & package
18-
run: |
19-
set -e
20-
for target in linux/amd64 linux/arm64 darwin/amd64 darwin/arm64; do
21-
GOOS=${target%/*}; GOARCH=${target#*/}
22-
dir="pingping-${GITHUB_REF_NAME}-${GOOS}-${GOARCH}"
23-
mkdir -p "$dir"
24-
CGO_ENABLED=0 GOOS=$GOOS GOARCH=$GOARCH \
25-
go build -trimpath -ldflags "-s -w -X main.version=${GITHUB_REF_NAME}" \
26-
-o "$dir/pingping" .
27-
cp LICENSE clean.sh "$dir/"
28-
tar czf "$dir.tar.gz" "$dir"
29-
done
30-
sha256sum pingping-*.tar.gz > SHA256SUMS
31-
- uses: softprops/action-gh-release@v2
32-
with:
33-
files: |
34-
pingping-*.tar.gz
35-
SHA256SUMS
36-
body: |
37-
## 开箱即用
38-
```bash
39-
tar xzf pingping-*.tar.gz && cd pingping-*/
40-
./pingping
41-
```
42-
首次运行自动生成演示配置(探测 www.baidu.com),打开 http://localhost:8517 即见烟雾图。
43-
Linux 静态编译,所有发行版通用;非 root 运行若提示无法创建 ICMP socket,执行
44-
`sudo setcap cap_net_raw+ep ./pingping` 或放开 `net.ipv4.ping_group_range`。
17+
version: '~> v2'
18+
args: release --clean
19+
env:
20+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
21+
TAP_TOKEN: ${{ secrets.TAP_TOKEN }}

.goreleaser.yaml

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
# GoReleaser — one config produces: cross-platform tarballs, .deb packages (apt/dpkg),
2+
# and an auto-updated Homebrew tap. No rpm. Zero-dependency single binary, so packaging
3+
# stays trivial. Run `goreleaser release` on tag push via CI.
4+
version: 2
5+
6+
project_name: pingping
7+
8+
before:
9+
hooks:
10+
- go test ./...
11+
12+
builds:
13+
- id: pingping
14+
main: .
15+
binary: pingping
16+
env:
17+
- CGO_ENABLED=0
18+
flags:
19+
- -trimpath
20+
ldflags:
21+
- -s -w -X main.version={{ .Version }}
22+
goos: [linux, darwin]
23+
goarch: [amd64, arm64]
24+
25+
# Tarballs for the "scp and run" crowd — unchanged experience, plus LICENSE and clean.sh.
26+
archives:
27+
- id: tar
28+
formats: [tar.gz]
29+
name_template: "{{ .ProjectName }}-v{{ .Version }}-{{ .Os }}-{{ .Arch }}"
30+
files:
31+
- LICENSE
32+
- clean.sh
33+
34+
checksum:
35+
name_template: "SHA256SUMS"
36+
37+
# .deb only (apt / dpkg). Static binary → no dependencies, ships a systemd unit.
38+
nfpms:
39+
- id: deb
40+
package_name: pingping
41+
formats: [deb]
42+
maintainer: githubflyideas <githubflyideas@users.noreply.github.com>
43+
description: Single-binary link quality oscilloscope (modern SmokePing alternative).
44+
homepage: https://github.com/githubflyideas/pingping
45+
license: Apache-2.0
46+
bindir: /usr/bin
47+
contents:
48+
- src: clean.sh
49+
dst: /usr/share/pingping/clean.sh
50+
- src: packaging/pingping.service
51+
dst: /lib/systemd/system/pingping.service
52+
type: config
53+
54+
# Homebrew: pushed to githubflyideas/homebrew-tap → `brew install githubflyideas/tap/pingping`.
55+
brews:
56+
- name: pingping
57+
repository:
58+
owner: githubflyideas
59+
name: homebrew-tap
60+
token: "{{ .Env.TAP_TOKEN }}"
61+
directory: Formula
62+
homepage: https://github.com/githubflyideas/pingping
63+
description: Single-binary link quality oscilloscope (modern SmokePing alternative).
64+
license: Apache-2.0
65+
install: |
66+
bin.install "pingping"
67+
test: |
68+
system "#{bin}/pingping", "-version"
69+
70+
release:
71+
github:
72+
owner: githubflyideas
73+
name: pingping
74+
header: |
75+
## Install
76+
77+
**Homebrew** (macOS/Linux):
78+
```bash
79+
brew install githubflyideas/tap/pingping
80+
```
81+
**Debian/Ubuntu** (.deb):
82+
```bash
83+
dpkg -i pingping_*_linux_amd64.deb # then: systemctl enable --now pingping
84+
```
85+
**Or just scp and run** — download a tarball below, extract, `./pingping`. Zero dependencies.

packaging/pingping.service

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
[Unit]
2+
Description=pingping — link quality oscilloscope
3+
After=network-online.target
4+
Wants=network-online.target
5+
6+
[Service]
7+
# Runs from its own dir so data/ and targets/ live under /var/lib/pingping.
8+
WorkingDirectory=/var/lib/pingping
9+
ExecStart=/usr/bin/pingping
10+
Restart=on-failure
11+
RestartSec=5
12+
DynamicUser=yes
13+
StateDirectory=pingping
14+
AmbientCapabilities=CAP_NET_RAW
15+
# Hardening
16+
NoNewPrivileges=yes
17+
ProtectSystem=strict
18+
ProtectHome=yes
19+
20+
[Install]
21+
WantedBy=multi-user.target

0 commit comments

Comments
 (0)