Skip to content

Commit 2ab81b9

Browse files
committed
Add workflows to build external-pcap-service rpm, deb, and arch packages.
1 parent f370aa1 commit 2ab81b9

11 files changed

+897
-9
lines changed
Lines changed: 218 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,218 @@
1+
name: Build External PCap Service
2+
3+
on:
4+
# Trigger on version tags (e.g., v1.0.1, v1.2.0)
5+
push:
6+
tags:
7+
- "v*"
8+
9+
# Manual trigger for testing or emergency releases
10+
workflow_dispatch:
11+
inputs:
12+
version:
13+
description: "Version to build (e.g., 1.0.1)"
14+
required: true
15+
type: string
16+
create_release:
17+
description: "Create GitHub release"
18+
required: true
19+
default: true
20+
type: boolean
21+
22+
jobs:
23+
build-linux:
24+
runs-on: ubuntu-latest
25+
26+
steps:
27+
- name: Checkout repository
28+
uses: actions/checkout@v4
29+
with:
30+
submodules: true
31+
32+
- name: Install dependencies
33+
run: |
34+
sudo apt-get update -q
35+
sudo apt-get install -y -q \
36+
libpcap-dev \
37+
build-essential \
38+
dpkg-dev \
39+
rpm \
40+
devscripts \
41+
debhelper \
42+
libsystemd-dev \
43+
libcap-dev \
44+
fakeroot \
45+
binutils
46+
47+
- name: Extract version from tag or input
48+
id: version
49+
run: |
50+
if [[ "${{ github.event_name }}" == "push" && "${{ github.ref }}" == refs/tags/v* ]]; then
51+
# Extract version from tag (v1.0.1 -> 1.0.1)
52+
VERSION=${GITHUB_REF#refs/tags/v}
53+
echo "Extracted version from tag: $VERSION"
54+
elif [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
55+
# Use manually provided version
56+
VERSION="${{ github.event.inputs.version }}"
57+
echo "Using manually provided version: $VERSION"
58+
else
59+
echo "Unable to determine version"
60+
exit 1
61+
fi
62+
63+
echo "version=$VERSION" >> $GITHUB_OUTPUT
64+
echo "PCAP_SERVICE_VERSION=$VERSION" >> $GITHUB_ENV
65+
66+
- name: Verify version matches source code
67+
run: |
68+
SOURCE_VERSION=$(grep '#define PCAP_SERVICE_VERSION ' pcapservice.h | awk -F '"' '{print $2}')
69+
70+
echo "Source code version: $SOURCE_VERSION"
71+
echo "Build version: ${{ steps.version.outputs.version }}"
72+
73+
if [ "$SOURCE_VERSION" != "${{ steps.version.outputs.version }}" ]; then
74+
echo "⚠️ Version mismatch detected!"
75+
echo "Source code defines version: $SOURCE_VERSION"
76+
echo "Tag/input specifies version: ${{ steps.version.outputs.version }}"
77+
echo ""
78+
echo "Please update the PCAP_SERVICE_VERSION in pcapservice.h to match the tag version,"
79+
echo "or use the correct tag that matches the source code version."
80+
exit 1
81+
fi
82+
83+
echo "✓ Version verification passed"
84+
85+
- name: Build external PCap service
86+
run: |
87+
echo "Building External PCap Service v${{ steps.version.outputs.version }}..."
88+
89+
# Clean and build
90+
make clean
91+
make shared
92+
make dist-source
93+
94+
# Verify binary was created
95+
if [ ! -f "whatpulse-pcap-service" ]; then
96+
echo "Error: Binary not found after build"
97+
exit 1
98+
fi
99+
100+
echo "✓ Build completed successfully"
101+
102+
- name: Build Debian package
103+
run: |
104+
chmod +x scripts/build-deb.sh
105+
./scripts/build-deb.sh ${{ steps.version.outputs.version }}
106+
107+
echo "Debian package build completed"
108+
109+
- name: Build RPM package
110+
run: |
111+
chmod +x scripts/build-rpm.sh
112+
./scripts/build-rpm.sh ${{ steps.version.outputs.version }}
113+
114+
echo "RPM package build completed"
115+
116+
- name: Build Arch package
117+
run: |
118+
chmod +x scripts/build-arch.sh
119+
./scripts/build-arch.sh ${{ steps.version.outputs.version }}
120+
121+
echo "Arch package build completed"
122+
123+
- name: Create standalone binary
124+
run: |
125+
# Create versioned binary
126+
cp whatpulse-pcap-service whatpulse-pcap-service-${{ steps.version.outputs.version }}-linux-amd64
127+
strip whatpulse-pcap-service-${{ steps.version.outputs.version }}-linux-amd64
128+
chmod +x whatpulse-pcap-service-${{ steps.version.outputs.version }}-linux-amd64
129+
130+
echo "✓ Standalone binary created"
131+
132+
- name: Collect artifacts
133+
run: |
134+
mkdir -p dist/packages
135+
136+
# Copy packages from script build directories
137+
find scripts -name "*.deb" -exec cp {} dist/packages/ \; 2>/dev/null || echo "No .deb files found"
138+
find scripts -name "*.rpm" -exec cp {} dist/packages/ \; 2>/dev/null || echo "No .rpm files found"
139+
find scripts -name "*.pkg.tar.*" -exec cp {} dist/packages/ \; 2>/dev/null || echo "No .pkg.tar.* files found"
140+
141+
# Copy source distribution and standalone binary
142+
cp -v dist/*.tar.gz dist/packages/ 2>/dev/null || echo "No .tar.gz files found"
143+
cp -v whatpulse-pcap-service-${{ steps.version.outputs.version }}-linux-amd64 dist/packages/
144+
145+
echo "📦 Final artifacts:"
146+
ls -la ../dist/packages/
147+
148+
- name: Generate checksums
149+
run: |
150+
cd dist/packages
151+
sha256sum * > SHA256SUMS
152+
echo "✓ Checksums generated"
153+
154+
- name: Upload build artifacts
155+
uses: actions/upload-artifact@v4
156+
with:
157+
name: pcap-service-packages-${{ steps.version.outputs.version }}
158+
path: dist/packages/
159+
retention-days: 30
160+
161+
- name: Create GitHub Release
162+
if: |
163+
(github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')) ||
164+
(github.event_name == 'workflow_dispatch' && github.event.inputs.create_release == 'true')
165+
uses: softprops/action-gh-release@v1
166+
with:
167+
tag_name: ${{ github.event_name == 'workflow_dispatch' && format('v{0}', steps.version.outputs.version) || github.ref_name }}
168+
name: "WhatPulse PCap Service v${{ steps.version.outputs.version }}"
169+
body: |
170+
# WhatPulse External PCap Service v${{ steps.version.outputs.version }}
171+
172+
This release contains the external PCap service that provides network packet capture capabilities for WhatPulse when running in containerized environments (AppImage, Flatpak) where direct PCap access is not available.
173+
174+
---
175+
176+
**Built from commit:** ${{ github.sha }}
177+
**Build date:** $(date -u +"%Y-%m-%d %H:%M:%S UTC")
178+
files: |
179+
dist/packages/*
180+
draft: false
181+
prerelease: false
182+
generate_release_notes: true
183+
env:
184+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
185+
186+
- name: Summary
187+
run: |
188+
echo "## 🎉 Build Summary" >> $GITHUB_STEP_SUMMARY
189+
echo "" >> $GITHUB_STEP_SUMMARY
190+
echo "**Version:** ${{ steps.version.outputs.version }}" >> $GITHUB_STEP_SUMMARY
191+
echo "**Commit:** ${{ github.sha }}" >> $GITHUB_STEP_SUMMARY
192+
echo "" >> $GITHUB_STEP_SUMMARY
193+
echo "### 📦 Generated Packages" >> $GITHUB_STEP_SUMMARY
194+
echo "" >> $GITHUB_STEP_SUMMARY
195+
196+
cd dist/packages
197+
for file in *; do
198+
if [[ -f "$file" && "$file" != "SHA256SUMS" ]]; then
199+
size=$(du -h "$file" | cut -f1)
200+
echo "- **$file** ($size)" >> $GITHUB_STEP_SUMMARY
201+
fi
202+
done
203+
204+
echo "" >> $GITHUB_STEP_SUMMARY
205+
echo "### ✅ Next Steps" >> $GITHUB_STEP_SUMMARY
206+
echo "" >> $GITHUB_STEP_SUMMARY
207+
208+
if [[ "${{ github.event_name }}" == "push" ]]; then
209+
echo "- 🚀 GitHub release created automatically" >> $GITHUB_STEP_SUMMARY
210+
elif [[ "${{ github.event.inputs.create_release }}" == "true" ]]; then
211+
echo "- 🚀 GitHub release created manually" >> $GITHUB_STEP_SUMMARY
212+
else
213+
echo "- 📋 Artifacts uploaded to workflow (no release created)" >> $GITHUB_STEP_SUMMARY
214+
fi
215+
216+
echo "- 📥 Download packages from the release or workflow artifacts" >> $GITHUB_STEP_SUMMARY
217+
echo "- 🔧 Test installation on target systems" >> $GITHUB_STEP_SUMMARY
218+
echo "- 📖 Update documentation if needed" >> $GITHUB_STEP_SUMMARY

Makefile

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,19 +43,21 @@ dist-source:
4343
mkdir -p dist
4444
tar czf dist/$(TARGET)-$(VERSION)-source.tar.gz \
4545
*.cpp *.h Makefile README.md LICENSE \
46-
whatpulse-pcap-service.service install.sh uninstall.sh
46+
whatpulse-pcap-service.service whatpulse-pcap-service-manual.service \
47+
install.sh uninstall.sh scripts/
4748

4849
# Clean target
4950
clean:
5051
rm -f $(TARGET)
5152
rm -rf dist/
5253
rm -rf packaging/*/build/
5354

54-
# Install target (requires root)
55+
# Install target (requires root) - for manual installation
5556
install: $(TARGET)
5657
install -m 755 $(TARGET) /usr/local/bin/
57-
install -m 644 whatpulse-pcap-service.service /etc/systemd/system/ || echo "Service file not found, skipping systemd service installation"
58+
install -m 644 whatpulse-pcap-service-manual.service /etc/systemd/system/whatpulse-pcap-service.service
5859
systemctl daemon-reload || echo "Failed to reload systemd daemon"
60+
echo "Manual installation complete. To start: sudo systemctl enable --now whatpulse-pcap-service"
5961

6062
# Uninstall target
6163
uninstall:

README.md

Lines changed: 38 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ A companion service that enables network monitoring for WhatPulse when running i
77
When WhatPulse runs as an AppImage or in other restricted environments, it may not have direct access to capture network packets. This service runs alongside WhatPulse to provide network monitoring capabilities by:
88

99
- Capturing network traffic using system-level access
10-
- Filtering and processing packet data safely
10+
- Filtering and processing packet data safely
1111
- Forwarding relevant statistics to WhatPulse via local connection
1212

1313
## Installation
@@ -23,7 +23,7 @@ sudo dpkg -i whatpulse-pcap-service_1.0.0_amd64.deb
2323
sudo apt-get install -f # Fix any missing dependencies
2424
```
2525

26-
#### Red Hat/Fedora/CentOS (.rpm)
26+
#### Red Hat/Fedora/CentOS (.rpm)
2727
```bash
2828
wget https://releases.whatpulse.org/latest/external-pcap-service/whatpulse-pcap-service-1.0.0-1.x86_64.rpm
2929
sudo rpm -ivh whatpulse-pcap-service-1.0.0-1.x86_64.rpm
@@ -62,6 +62,17 @@ make
6262
sudo make install
6363
```
6464

65+
## Installation Paths
66+
67+
The service uses different paths depending on the installation method:
68+
69+
- **Package installations** (deb, rpm, etc.): Binary at `/usr/bin/whatpulse-pcap-service`
70+
- **Manual installations** (make install, install.sh): Binary at `/usr/local/bin/whatpulse-pcap-service`
71+
72+
Both use the same systemd service name: `whatpulse-pcap-service`
73+
74+
The appropriate systemd service file is automatically selected during installation.
75+
6576
## Usage
6677

6778
### Starting the Service
@@ -115,7 +126,7 @@ sudo whatpulse-pcap-service --verbose
115126
# Debian/Ubuntu
116127
sudo apt-get remove whatpulse-pcap-service
117128

118-
# Red Hat/Fedora/CentOS
129+
# Red Hat/Fedora/CentOS
119130
sudo rpm -e whatpulse-pcap-service
120131

121132
# Arch Linux
@@ -153,3 +164,27 @@ See the [LICENSE](LICENSE) file for complete terms and conditions.
153164
- ❌ Protocol circumvention or data injection
154165

155166
For commercial licensing inquiries: [email protected]
167+
168+
169+
## Release Process
170+
171+
Releases are automated via GitHub Actions. Follow these steps to create a new release:
172+
173+
**Update version:**
174+
```bash
175+
# Edit pcapservice.h
176+
# Change PCAP_SERVICE_VERSION to your new version (e.g., "1.0.1")
177+
```
178+
179+
**Commit and push changes:**
180+
```bash
181+
git add pcapservice.h
182+
git commit -m "bump version to 1.0.1"
183+
git push origin master
184+
```
185+
186+
**Create and push version tag:**
187+
```bash
188+
git tag v1.0.1
189+
git push origin v1.0.1
190+
```

install.sh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,10 @@ if ! ./whatpulse-pcap-service --version >/dev/null 2>&1; then
5959
fi
6060

6161
# Install the service
62-
echo "Installing service..."
63-
sudo make install
62+
# Install systemd service
63+
echo "Installing systemd service..."
64+
sudo cp whatpulse-pcap-service-manual.service /etc/systemd/system/whatpulse-pcap-service.service
65+
sudo systemctl daemon-reload
6466

6567
echo ""
6668
echo "Installation completed successfully!"

0 commit comments

Comments
 (0)