Skip to content

Commit 7a86119

Browse files
authored
feat(debian, rpm): add package management scripts and metadata (#13)
* feat(debian, rpm): add package management scripts and metadata - Added post-installation and post-removal scripts for Debian and RPM packages - Included configuration for passwordless sudo for required commands - Updated .gitignore to exclude binary packages - Enhanced Cargo.toml with package metadata and descriptions - Improved README with installation instructions for binary packages * feat(release): add GitHub Actions release pipeline - Implement release pipeline for building and publishing packages - Support for both Ubuntu (.deb) and Fedora (.rpm) packages - Include steps for testing, building, and uploading artifacts - Create GitHub release with generated packages and checksums * fix(release): update Fedora dependency installation - Changed step name to clarify installation of system dependencies for Fedora - Added comments to explain the installation of base build tools and runtime dependencies - Ensured runtime dependencies are installed via `make deps` * fix: checkout first * fix(release): update runtime dependencies for Fedora - Replaced `make deps` with direct installation of runtime dependencies - Added installation of `openconnect`, `dbus-devel`, and `pkgconf-pkg-config` * fix(release): improve version handling in release pipeline - Added logic to set version based on GitHub event type - Use short SHA for PRs and branches - Maintain existing behavior for workflow dispatch and tags * fix(package): update version to 1.2.0 - Updated version in Cargo.toml for akon package - Updated version in Cargo.toml for akon-core package * fix(release): extend retention days for release artifacts - Increased retention days for Debian packages from 90 to 120 - Increased retention days for RPM packages from 90 to 120
1 parent 9e1931e commit 7a86119

File tree

12 files changed

+540
-6
lines changed

12 files changed

+540
-6
lines changed

.github/workflows/release.yml

Lines changed: 281 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,281 @@
1+
# Release Pipeline for akon
2+
# Builds and publishes binary packages for Ubuntu and Fedora
3+
---
4+
name: Release
5+
6+
on:
7+
push:
8+
tags:
9+
- 'v*.*.*'
10+
pull_request:
11+
paths:
12+
- '.github/workflows/release.yml'
13+
- 'Cargo.toml'
14+
- 'debian/**'
15+
- 'rpm/**'
16+
workflow_dispatch:
17+
inputs:
18+
version:
19+
description: 'Version to release (e.g., 1.1.1)'
20+
required: true
21+
type: string
22+
23+
env:
24+
CARGO_TERM_COLOR: always
25+
26+
jobs:
27+
# Test package building on PRs (no release)
28+
test-packages:
29+
name: Test Package Building
30+
if: github.event_name == 'pull_request'
31+
strategy:
32+
matrix:
33+
include:
34+
- os: ubuntu-latest
35+
package: deb
36+
- os: ubuntu-latest
37+
package: rpm
38+
container: fedora:latest
39+
runs-on: ${{ matrix.os }}
40+
container: ${{ matrix.container }}
41+
steps:
42+
- name: Checkout repository
43+
uses: actions/checkout@v4
44+
45+
- name: Install system dependencies (Ubuntu)
46+
if: matrix.package == 'deb'
47+
run: make deps
48+
49+
- name: Install system dependencies (Fedora)
50+
if: matrix.package == 'rpm'
51+
run: |
52+
# Install base build tools and package building tools
53+
dnf install -y \
54+
gcc \
55+
gcc-c++ \
56+
make \
57+
openssl-devel \
58+
git \
59+
curl \
60+
rpm-build \
61+
rpmdevtools
62+
# Install runtime dependencies (openconnect + dbus)
63+
dnf install -y \
64+
openconnect \
65+
dbus-devel \
66+
pkgconf-pkg-config
67+
68+
- name: Setup Rust toolchain (Ubuntu)
69+
if: matrix.package == 'deb'
70+
uses: actions-rust-lang/setup-rust-toolchain@v1
71+
with:
72+
toolchain: stable
73+
74+
- name: Setup Rust toolchain (Fedora)
75+
if: matrix.package == 'rpm'
76+
run: |
77+
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs \
78+
| sh -s -- -y
79+
source $HOME/.cargo/env
80+
echo "$HOME/.cargo/bin" >> $GITHUB_PATH
81+
82+
- name: Install packaging tools
83+
run: |
84+
if [ "${{ matrix.package }}" = "deb" ]; then
85+
cargo install cargo-deb
86+
else
87+
source $HOME/.cargo/env
88+
cargo install cargo-generate-rpm
89+
fi
90+
91+
- name: Build release binary
92+
run: |
93+
if [ "${{ matrix.package }}" = "rpm" ]; then
94+
source $HOME/.cargo/env
95+
fi
96+
cargo build --release --verbose
97+
98+
- name: Build package
99+
run: |
100+
if [ "${{ matrix.package }}" = "deb" ]; then
101+
cargo deb --no-build
102+
echo "Package built: $(ls -1 target/debian/*.deb)"
103+
else
104+
source $HOME/.cargo/env
105+
cargo generate-rpm
106+
echo "Package built: $(ls -1 target/generate-rpm/*.rpm)"
107+
fi
108+
109+
- name: Upload test package
110+
uses: actions/upload-artifact@v4
111+
with:
112+
name: test-${{ matrix.package }}-package
113+
path: |
114+
target/debian/*.deb
115+
target/generate-rpm/*.rpm
116+
retention-days: 7
117+
118+
# Build Ubuntu .deb package for release
119+
build-deb:
120+
if: >-
121+
startsWith(github.ref, 'refs/tags/') ||
122+
github.event_name == 'workflow_dispatch'
123+
name: Build Ubuntu .deb Package
124+
runs-on: ubuntu-latest
125+
steps:
126+
- name: Checkout repository
127+
uses: actions/checkout@v4
128+
129+
- name: Install system dependencies
130+
run: make deps
131+
132+
- name: Setup Rust toolchain
133+
uses: actions-rust-lang/setup-rust-toolchain@v1
134+
with:
135+
toolchain: stable
136+
137+
- name: Install cargo-deb
138+
run: cargo install cargo-deb
139+
140+
- name: Build release binary
141+
run: cargo build --release --verbose
142+
143+
- name: Build .deb package
144+
run: cargo deb --no-build
145+
146+
- name: Get package version
147+
id: version
148+
run: |
149+
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
150+
echo "version=${{ inputs.version }}" >> $GITHUB_OUTPUT
151+
elif [[ "$GITHUB_REF" == refs/tags/* ]]; then
152+
echo "version=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT
153+
else
154+
# For PRs and branches, use short SHA
155+
echo "version=$(echo ${{ github.sha }} | cut -c1-8)" >> $GITHUB_OUTPUT
156+
fi
157+
158+
- name: Upload .deb artifact
159+
uses: actions/upload-artifact@v4
160+
with:
161+
name: akon-${{ steps.version.outputs.version }}-amd64.deb
162+
path: target/debian/*.deb
163+
retention-days: 120
164+
165+
# Build Fedora .rpm package
166+
build-rpm:
167+
if: >-
168+
startsWith(github.ref, 'refs/tags/') ||
169+
github.event_name == 'workflow_dispatch'
170+
name: Build Fedora .rpm Package
171+
runs-on: ubuntu-latest
172+
container:
173+
image: fedora:latest
174+
steps:
175+
- name: Checkout repository
176+
uses: actions/checkout@v4
177+
178+
- name: Install build dependencies
179+
run: |
180+
# Install base build tools and package building tools
181+
dnf install -y \
182+
gcc \
183+
gcc-c++ \
184+
make \
185+
openssl-devel \
186+
git \
187+
curl \
188+
rpm-build \
189+
rpmdevtools
190+
# Install runtime dependencies (openconnect + dbus)
191+
dnf install -y \
192+
openconnect \
193+
dbus-devel \
194+
pkgconf-pkg-config
195+
196+
- name: Setup Rust toolchain
197+
run: |
198+
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs \
199+
| sh -s -- -y
200+
source $HOME/.cargo/env
201+
echo "$HOME/.cargo/bin" >> $GITHUB_PATH
202+
203+
- name: Install cargo-generate-rpm
204+
run: |
205+
source $HOME/.cargo/env
206+
cargo install cargo-generate-rpm
207+
208+
- name: Build release binary
209+
run: |
210+
source $HOME/.cargo/env
211+
cargo build --release --verbose
212+
213+
- name: Generate .rpm package
214+
run: |
215+
source $HOME/.cargo/env
216+
cargo generate-rpm
217+
218+
- name: Get package version
219+
id: version
220+
run: |
221+
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
222+
echo "version=${{ inputs.version }}" >> $GITHUB_OUTPUT
223+
elif [[ "$GITHUB_REF" == refs/tags/* ]]; then
224+
echo "version=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT
225+
else
226+
# For PRs and branches, use short SHA
227+
echo "version=$(echo ${{ github.sha }} | cut -c1-8)" >> $GITHUB_OUTPUT
228+
fi
229+
230+
- name: Upload .rpm artifact
231+
uses: actions/upload-artifact@v4
232+
with:
233+
name: akon-${{ steps.version.outputs.version }}-1.x86_64.rpm
234+
path: target/generate-rpm/*.rpm
235+
retention-days: 120
236+
237+
# Create GitHub Release with packages
238+
create-release:
239+
name: Create GitHub Release
240+
runs-on: ubuntu-latest
241+
needs: [build-deb, build-rpm]
242+
if: startsWith(github.ref, 'refs/tags/')
243+
permissions:
244+
contents: write
245+
steps:
246+
- name: Checkout repository
247+
uses: actions/checkout@v4
248+
249+
- name: Get version
250+
id: version
251+
run: echo "version=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT
252+
253+
- name: Download .deb artifact
254+
uses: actions/download-artifact@v4
255+
with:
256+
name: akon-${{ steps.version.outputs.version }}-amd64.deb
257+
path: ./packages
258+
259+
- name: Download .rpm artifact
260+
uses: actions/download-artifact@v4
261+
with:
262+
name: akon-${{ steps.version.outputs.version }}-1.x86_64.rpm
263+
path: ./packages
264+
265+
- name: Generate checksums
266+
run: |
267+
cd packages
268+
sha256sum *.deb *.rpm > SHA256SUMS.txt
269+
270+
- name: Create Release
271+
uses: softprops/action-gh-release@v1
272+
with:
273+
files: |
274+
packages/*.deb
275+
packages/*.rpm
276+
packages/SHA256SUMS.txt
277+
generate_release_notes: true
278+
draft: false
279+
prerelease: false
280+
env:
281+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.gitignore

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
.github
2-
!.github/workflows/
3-
!.github/workflows/*.yml
1+
.github/prompts
42
debug/
53
traces/
64
# Added by cargo
@@ -33,6 +31,13 @@ build.rs
3331
*.dylib
3432
*.dll
3533

34+
# Binary packages
35+
*.deb
36+
*.rpm
37+
*.tar.gz
38+
*.zip
39+
SHA256SUMS.txt
40+
3641
# Configuration files that may contain secrets (never commit)
3742
config.toml
3843
*.key

Cargo.toml

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,54 @@ resolver = "2"
44

55
[package]
66
name = "akon"
7-
version = "1.1.1"
7+
version = "1.2.0"
88
edition = "2021"
9+
authors = ["vcwild"]
10+
description = "A CLI tool for managing VPN connections with OpenConnect"
11+
license = "MIT"
12+
repository = "https://github.com/vcwild/akon"
13+
homepage = "https://github.com/vcwild/akon"
14+
readme = "README.md"
15+
keywords = ["vpn", "openconnect", "cli", "networking"]
16+
categories = ["command-line-utilities", "network-programming"]
917

1018
[lints.rust]
1119
dead_code = "deny"
1220

21+
# Debian package metadata for cargo-deb
22+
[package.metadata.deb]
23+
maintainer = "vcwild"
24+
copyright = "2025, vcwild"
25+
license-file = ["LICENSE", "4"]
26+
extended-description = """\
27+
akon is a command-line tool for managing VPN connections using OpenConnect.
28+
It provides an easy-to-use interface for connecting to VPN servers with support
29+
for automatic reconnection, health checks, and daemon mode operation."""
30+
depends = "openconnect, procps"
31+
section = "net"
32+
priority = "optional"
33+
assets = [
34+
["target/release/akon", "usr/bin/", "755"],
35+
["README.md", "usr/share/doc/akon/", "644"],
36+
["LICENSE", "usr/share/doc/akon/", "644"],
37+
]
38+
maintainer-scripts = "debian/"
39+
40+
# RPM package metadata for cargo-generate-rpm
41+
[package.metadata.generate-rpm]
42+
assets = [
43+
{ source = "target/release/akon", dest = "/usr/bin/akon", mode = "755" },
44+
{ source = "README.md", dest = "/usr/share/doc/akon/README.md", mode = "644" },
45+
{ source = "LICENSE", dest = "/usr/share/doc/akon/LICENSE", mode = "644" },
46+
]
47+
post_install_script = "rpm/post-install.sh"
48+
pre_uninstall_script = "rpm/pre-uninstall.sh"
49+
post_uninstall_script = "rpm/post-uninstall.sh"
50+
51+
[package.metadata.generate-rpm.requires]
52+
openconnect = "*"
53+
procps-ng = "*"
54+
1355
[[bin]]
1456
name = "akon"
1557
path = "src/main.rs"

0 commit comments

Comments
 (0)