-
Notifications
You must be signed in to change notification settings - Fork 1
266 lines (230 loc) · 7.72 KB
/
_build-package.yml
File metadata and controls
266 lines (230 loc) · 7.72 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
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
name: Reusable Package Build
on:
workflow_call:
inputs:
package_type:
required: true
type: string
description: "Package type: deb, rpm, or ipk"
binary_artifact:
required: true
type: string
description: "Name of the artifact containing the binary"
version:
required: true
type: string
description: "Package version (without 'v' prefix)"
arch:
required: true
type: string
description: "Package architecture (amd64, arm64, etc.)"
artifact_name:
required: true
type: string
description: "Output artifact name"
package_name:
required: false
type: string
default: "https-vpn"
description:
required: false
type: string
default: "HTTPS VPN - Lightweight certification-ready VPN"
maintainer:
required: false
type: string
default: "NativeMind <noreply@nativemind.net>"
outputs:
package_path:
description: "Path to package file"
value: ${{ jobs.package.outputs.package_path }}
jobs:
package:
runs-on: ubuntu-latest
outputs:
package_path: ${{ steps.package.outputs.package_path }}
steps:
- name: Download binary artifact
uses: actions/download-artifact@v4
with:
name: ${{ inputs.binary_artifact }}
path: binary/
- name: Install packaging tools
run: |
sudo apt-get update
case "${{ inputs.package_type }}" in
deb)
sudo apt-get install -y dpkg-dev
;;
rpm)
sudo apt-get install -y rpm
;;
ipk)
# OpenWRT ipk is just a tarball with control files
;;
esac
- name: Extract binary
run: |
cd binary
if [[ -f "*.tar.gz" ]]; then
tar -xzf *.tar.gz
elif [[ -f "*.zip" ]]; then
unzip *.zip
fi
# Find the binary
BINARY=$(find . -name "https-vpn" -o -name "https-vpn.exe" | head -1)
if [[ -z "$BINARY" ]]; then
echo "Binary not found!"
exit 1
fi
cp "$BINARY" ../https-vpn
chmod +x ../https-vpn
- name: Create DEB package
if: inputs.package_type == 'deb'
id: deb
run: |
PKG_NAME="${{ inputs.package_name }}"
PKG_VERSION="${{ inputs.version }}"
PKG_ARCH="${{ inputs.arch }}"
# Map Go arch to Debian arch
case "$PKG_ARCH" in
amd64) DEB_ARCH="amd64" ;;
arm64) DEB_ARCH="arm64" ;;
arm) DEB_ARCH="armhf" ;;
386) DEB_ARCH="i386" ;;
*) DEB_ARCH="$PKG_ARCH" ;;
esac
# Create package structure
PKG_DIR="${PKG_NAME}_${PKG_VERSION}_${DEB_ARCH}"
mkdir -p "${PKG_DIR}/DEBIAN"
mkdir -p "${PKG_DIR}/usr/bin"
mkdir -p "${PKG_DIR}/etc/https-vpn"
mkdir -p "${PKG_DIR}/lib/systemd/system"
# Copy binary
cp https-vpn "${PKG_DIR}/usr/bin/"
chmod 755 "${PKG_DIR}/usr/bin/https-vpn"
# Create control file
cat > "${PKG_DIR}/DEBIAN/control" << EOF
Package: ${PKG_NAME}
Version: ${PKG_VERSION}
Section: net
Priority: optional
Architecture: ${DEB_ARCH}
Maintainer: ${{ inputs.maintainer }}
Description: ${{ inputs.description }}
EOF
# Create systemd service
cat > "${PKG_DIR}/lib/systemd/system/https-vpn.service" << EOF
[Unit]
Description=HTTPS VPN Service
After=network.target
[Service]
Type=simple
ExecStart=/usr/bin/https-vpn run -c /etc/https-vpn/config.json
Restart=on-failure
RestartSec=5
[Install]
WantedBy=multi-user.target
EOF
# Create default config
cat > "${PKG_DIR}/etc/https-vpn/config.json.example" << EOF
{
"inbounds": [{
"port": 443,
"protocol": "https-vpn",
"settings": {}
}],
"outbounds": [{"protocol": "freedom"}]
}
EOF
# Build package
dpkg-deb --build "${PKG_DIR}"
echo "package_path=${PKG_DIR}.deb" >> $GITHUB_OUTPUT
- name: Create RPM package
if: inputs.package_type == 'rpm'
id: rpm
run: |
PKG_NAME="${{ inputs.package_name }}"
PKG_VERSION="${{ inputs.version }}"
PKG_ARCH="${{ inputs.arch }}"
# Map to RPM arch
case "$PKG_ARCH" in
amd64) RPM_ARCH="x86_64" ;;
arm64) RPM_ARCH="aarch64" ;;
arm) RPM_ARCH="armv7hl" ;;
386) RPM_ARCH="i686" ;;
*) RPM_ARCH="$PKG_ARCH" ;;
esac
# Create RPM build structure
mkdir -p rpmbuild/{BUILD,RPMS,SOURCES,SPECS,SRPMS}
cp https-vpn rpmbuild/SOURCES/
# Create spec file
cat > rpmbuild/SPECS/https-vpn.spec << EOF
Name: ${PKG_NAME}
Version: ${PKG_VERSION}
Release: 1
Summary: ${{ inputs.description }}
License: Proprietary
%description
${{ inputs.description }}
%install
mkdir -p %{buildroot}/usr/bin
cp %{_sourcedir}/https-vpn %{buildroot}/usr/bin/
chmod 755 %{buildroot}/usr/bin/https-vpn
%files
/usr/bin/https-vpn
EOF
# Build RPM
rpmbuild -bb --target="${RPM_ARCH}" \
--define "_topdir $(pwd)/rpmbuild" \
rpmbuild/SPECS/https-vpn.spec
RPM_FILE=$(find rpmbuild/RPMS -name "*.rpm" | head -1)
cp "$RPM_FILE" ./
echo "package_path=$(basename $RPM_FILE)" >> $GITHUB_OUTPUT
- name: Create IPK package
if: inputs.package_type == 'ipk'
id: ipk
run: |
PKG_NAME="${{ inputs.package_name }}"
PKG_VERSION="${{ inputs.version }}"
PKG_ARCH="${{ inputs.arch }}"
# Create package structure
mkdir -p ipk/data/usr/bin
mkdir -p ipk/control
cp https-vpn ipk/data/usr/bin/
chmod 755 ipk/data/usr/bin/https-vpn
# Control file
cat > ipk/control/control << EOF
Package: ${PKG_NAME}
Version: ${PKG_VERSION}
Architecture: ${PKG_ARCH}
Maintainer: ${{ inputs.maintainer }}
Description: ${{ inputs.description }}
EOF
# Create data.tar.gz
cd ipk/data && tar -czvf ../data.tar.gz . && cd ../..
# Create control.tar.gz
cd ipk/control && tar -czvf ../control.tar.gz . && cd ../..
# Create debian-binary
echo "2.0" > ipk/debian-binary
# Create ipk (ar archive)
cd ipk && ar -r "../${PKG_NAME}_${PKG_VERSION}_${PKG_ARCH}.ipk" \
debian-binary control.tar.gz data.tar.gz && cd ..
echo "package_path=${PKG_NAME}_${PKG_VERSION}_${PKG_ARCH}.ipk" >> $GITHUB_OUTPUT
- name: Set output
id: package
run: |
case "${{ inputs.package_type }}" in
deb) echo "package_path=${{ steps.deb.outputs.package_path }}" >> $GITHUB_OUTPUT ;;
rpm) echo "package_path=${{ steps.rpm.outputs.package_path }}" >> $GITHUB_OUTPUT ;;
ipk) echo "package_path=${{ steps.ipk.outputs.package_path }}" >> $GITHUB_OUTPUT ;;
esac
- name: Upload package artifact
uses: actions/upload-artifact@v4
with:
name: ${{ inputs.artifact_name }}
path: |
*.deb
*.rpm
*.ipk
if-no-files-found: error