-
Notifications
You must be signed in to change notification settings - Fork 31
173 lines (156 loc) ยท 6.23 KB
/
debian-artifact.yml
File metadata and controls
173 lines (156 loc) ยท 6.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
name: debian-artifact
on:
push:
tags:
- "v*" # Push events to matching v*, i.e. v1.0, v20.15.10
workflow_dispatch:
permissions:
contents: write
jobs:
build:
name: Debian Artifact - amd64
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Cache cargo dependencies
uses: actions/cache@v4
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-
- name: Extract package name from Cargo.toml
id: package_name
shell: bash
run: |
if [ -f "Cargo.toml" ]; then
PACKAGE_NAME=$(grep -m 1 "^name" Cargo.toml | sed 's/^name = "\(.*\)"$/\1/' | tr -d '"')
echo "name=$PACKAGE_NAME" >> $GITHUB_OUTPUT
echo "Package name extracted: $PACKAGE_NAME"
else
echo "Error: Cargo.toml not found!"
exit 1
fi
- name: Rust toolchain
uses: dtolnay/rust-toolchain@stable
- name: Build project
run: cargo build --release
- name: Install cargo-deb
run: |
# Since v2.0.0 the deb package version will have a "-1" suffix. You can disable this by adding --deb-revision="" flag or revision = "" in Cargo metadata. The default suffix is for compliance with Debian's packaging standard.
if ! command -v cargo-deb &> /dev/null; then
cargo install cargo-deb
else
echo "cargo-deb already installed (from cache)"
cargo-deb --version
fi
- name: Create Debian package
run: |
# Verify binary architecture before packaging
echo "Verifying binary architecture..."
file target/release/${{ steps.package_name.outputs.name }} || true
# Build deb package without rebuilding
cargo deb --no-build
# Verify package was created
DEB_FILE=$(ls target/debian/*.deb 2>/dev/null | head -1)
if [ -z "$DEB_FILE" ]; then
echo "Error: .deb file not found!"
exit 1
fi
echo "Generated package: $DEB_FILE"
- name: Verify .deb file exists
run: |
DEB_FILE=$(ls target/debian/*.deb 2>/dev/null | head -1)
if [ -z "$DEB_FILE" ]; then
echo "Error: .deb file not found!"
exit 1
fi
echo "Found .deb file: $DEB_FILE"
echo "Package name: ${{ steps.package_name.outputs.name }}"
ls -lh "$DEB_FILE"
- name: Test .deb package installation
run: |
DEB_FILE=$(ls target/debian/*.deb 2>/dev/null | head -1)
echo "Testing installation of $DEB_FILE"
# Install dependencies if needed (dpkg may complain about missing deps)
sudo apt-get update
# Verify package structure before installation
echo "=== Package Structure Verification ==="
dpkg-deb -c "$DEB_FILE" | head -20
echo ""
# Check package metadata
echo "=== Package Metadata ==="
dpkg -I "$DEB_FILE" | head -30
echo ""
# Install the package (allow dependencies to be missing for now)
echo "=== Installing Package ==="
sudo dpkg -i "$DEB_FILE" || true
# Fix any missing dependencies
sudo apt-get install -f -y
# Verify the binary exists and is executable
BINARY_NAME="${{ steps.package_name.outputs.name }}"
BINARY_PATH=""
# Find the binary location
if command -v "$BINARY_NAME" &> /dev/null; then
BINARY_PATH=$(command -v "$BINARY_NAME")
echo "โ Binary '$BINARY_NAME' found at: $BINARY_PATH"
elif [ -f "/usr/bin/$BINARY_NAME" ]; then
BINARY_PATH="/usr/bin/$BINARY_NAME"
echo "โ Binary found at: $BINARY_PATH"
elif [ -f "/usr/local/bin/$BINARY_NAME" ]; then
BINARY_PATH="/usr/local/bin/$BINARY_NAME"
echo "โ Binary found at: $BINARY_PATH"
else
echo "โ Error: Binary '$BINARY_NAME' not found after installation"
echo "Files installed by package:"
dpkg -L "$(dpkg -f "$DEB_FILE" Package)" || true
exit 1
fi
# Verify binary is executable
if [ ! -x "$BINARY_PATH" ]; then
echo "โ Error: Binary is not executable"
ls -l "$BINARY_PATH"
exit 1
fi
echo "โ Binary is executable"
# Check binary architecture
if command -v file &> /dev/null; then
BINARY_ARCH=$(file "$BINARY_PATH" | grep -oE "(x86-64|aarch64|ARM|Intel|80386)" || echo "unknown")
echo "Binary architecture: $BINARY_ARCH"
fi
# Test execution
echo "=== Testing Binary Execution ==="
if "$BINARY_PATH" --help &> /dev/null || "$BINARY_PATH" --version &> /dev/null; then
echo "โ Binary responds to --help or --version"
fi
# Verify package info
echo ""
echo "=== Package Verification Summary ==="
dpkg -l | grep "$(dpkg -f "$DEB_FILE" Package)" || true
# Clean up: remove the package
echo ""
echo "=== Cleaning Up ==="
sudo dpkg -r "$(dpkg -f "$DEB_FILE" Package)" || true
echo "โ Package removal successful"
- name: Extract tag name
id: tag
run: |
if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
echo "tag=v0.0.0" >> $GITHUB_OUTPUT
else
echo "tag=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
fi
- name: Create Release
if: always() && github.event_name != 'pull_request'
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ steps.tag.outputs.tag }}
files: target/debian/*.deb
generate_release_notes: true
fail_on_unmatched_files: false