Skip to content

Commit cae7a12

Browse files
committed
adding the auto release ci job
1 parent 668314b commit cae7a12

10 files changed

Lines changed: 718 additions & 24 deletions

File tree

.github/workflows/packaging.yml

Lines changed: 212 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,212 @@
1+
name: Packaging
2+
3+
on:
4+
push:
5+
tags: ['v*']
6+
workflow_dispatch:
7+
inputs:
8+
tag:
9+
description: 'Release tag (e.g. v1.0.0, v1.2.0)'
10+
required: true
11+
12+
jobs:
13+
version:
14+
name: Determine Version
15+
runs-on: ubuntu-latest
16+
outputs:
17+
tag: ${{ steps.version.outputs.tag }}
18+
version: ${{ steps.version.outputs.version }}
19+
steps:
20+
- name: Determine version
21+
id: version
22+
run: |
23+
if [ -n "${{ github.event.inputs.tag }}" ]; then
24+
VERSION="${{ github.event.inputs.tag }}"
25+
else
26+
VERSION="${GITHUB_REF#refs/tags/}"
27+
fi
28+
echo "tag=${VERSION}" >> "$GITHUB_OUTPUT"
29+
echo "version=${VERSION#v}" >> "$GITHUB_OUTPUT"
30+
31+
deb:
32+
name: Build DEB packages
33+
runs-on: ubuntu-22.04
34+
needs: version
35+
36+
steps:
37+
- name: Install dependencies
38+
run: |
39+
sudo apt-get update
40+
sudo apt-get install -y \
41+
gcc-13 g++-13 cmake \
42+
dpkg-dev fakeroot
43+
44+
- name: Checkout
45+
uses: actions/checkout@v4
46+
47+
- name: Build library
48+
run: |
49+
cmake -B build \
50+
-DCMAKE_BUILD_TYPE=Release \
51+
-DCMAKE_C_COMPILER=gcc-13 \
52+
-DCMAKE_CXX_COMPILER=g++-13 \
53+
-DCMAKE_INSTALL_PREFIX=/usr
54+
cmake --build build -j$(nproc)
55+
56+
- name: Build runtime DEB package
57+
run: |
58+
PKG_DIR="$(pwd)/libdynemit_${{ needs.version.outputs.version }}_amd64"
59+
mkdir -p "${PKG_DIR}/usr/lib"
60+
mkdir -p "${PKG_DIR}/usr/share/doc/libdynemit"
61+
mkdir -p "${PKG_DIR}/DEBIAN"
62+
63+
# Install shared libraries (runtime)
64+
cp build/libdynemit.so.${{ needs.version.outputs.version }} "${PKG_DIR}/usr/lib/"
65+
ln -s libdynemit.so.${{ needs.version.outputs.version }} "${PKG_DIR}/usr/lib/libdynemit.so.1"
66+
67+
cp build/src/libdynemit_core.so.${{ needs.version.outputs.version }} "${PKG_DIR}/usr/lib/"
68+
ln -s libdynemit_core.so.${{ needs.version.outputs.version }} "${PKG_DIR}/usr/lib/libdynemit_core.so.1"
69+
70+
find build/features -name "*.so.${{ needs.version.outputs.version }}" -exec cp {} "${PKG_DIR}/usr/lib/" \;
71+
for lib in "${PKG_DIR}"/usr/lib/*.so.${{ needs.version.outputs.version }}; do
72+
base=$(basename "$lib" .so.${{ needs.version.outputs.version }})
73+
ln -s "$(basename $lib)" "${PKG_DIR}/usr/lib/${base}.so.1"
74+
done
75+
76+
# Install documentation
77+
cp README.md "${PKG_DIR}/usr/share/doc/libdynemit/"
78+
cp LICENSE "${PKG_DIR}/usr/share/doc/libdynemit/"
79+
80+
# Generate control file from template
81+
sed "s/{{VERSION}}/${{ needs.version.outputs.version }}/g" \
82+
pkg/deb/runtime/control > "${PKG_DIR}/DEBIAN/control"
83+
84+
# Copy copyright
85+
cp pkg/deb/common/copyright "${PKG_DIR}/usr/share/doc/libdynemit/"
86+
87+
# Build package
88+
dpkg-deb --build "${PKG_DIR}"
89+
90+
- name: Build dev DEB package
91+
run: |
92+
PKG_DIR="$(pwd)/libdynemit-dev_${{ needs.version.outputs.version }}_amd64"
93+
mkdir -p "${PKG_DIR}/usr/lib"
94+
mkdir -p "${PKG_DIR}/usr/include/dynemit"
95+
mkdir -p "${PKG_DIR}/usr/lib/pkgconfig"
96+
mkdir -p "${PKG_DIR}/usr/share/doc/libdynemit-dev"
97+
mkdir -p "${PKG_DIR}/DEBIAN"
98+
99+
# Install static libraries
100+
cp build/libdynemit.a "${PKG_DIR}/usr/lib/"
101+
cp build/src/libdynemit_core.a "${PKG_DIR}/usr/lib/"
102+
find build/features -name "*.a" -exec cp {} "${PKG_DIR}/usr/lib/" \;
103+
104+
# Install development symlinks for shared libraries
105+
ln -s libdynemit.so.1 "${PKG_DIR}/usr/lib/libdynemit.so"
106+
ln -s libdynemit_core.so.1 "${PKG_DIR}/usr/lib/libdynemit_core.so"
107+
for lib in build/features/*/*.so.${{ needs.version.outputs.version }}; do
108+
base=$(basename "$lib" .so.${{ needs.version.outputs.version }})
109+
ln -s "${base}.so.1" "${PKG_DIR}/usr/lib/${base}.so"
110+
done
111+
112+
# Install headers
113+
cp include/dynemit.h "${PKG_DIR}/usr/include/"
114+
cp include/dynemit/*.h "${PKG_DIR}/usr/include/dynemit/"
115+
116+
# Install pkg-config file
117+
cp build/libdynemit.pc "${PKG_DIR}/usr/lib/pkgconfig/"
118+
119+
# Install documentation
120+
cp README.md "${PKG_DIR}/usr/share/doc/libdynemit-dev/"
121+
cp LICENSE "${PKG_DIR}/usr/share/doc/libdynemit-dev/"
122+
123+
# Generate control file from template
124+
sed "s/{{VERSION}}/${{ needs.version.outputs.version }}/g" \
125+
pkg/deb/dev/control > "${PKG_DIR}/DEBIAN/control"
126+
127+
# Copy copyright
128+
cp pkg/deb/common/copyright "${PKG_DIR}/usr/share/doc/libdynemit-dev/"
129+
130+
# Build package
131+
dpkg-deb --build "${PKG_DIR}"
132+
133+
- name: Verify DEB packages
134+
run: |
135+
dpkg-deb --info "libdynemit_${{ needs.version.outputs.version }}_amd64.deb"
136+
dpkg-deb --info "libdynemit-dev_${{ needs.version.outputs.version }}_amd64.deb"
137+
138+
- name: Upload DEB artifacts
139+
uses: actions/upload-artifact@v4
140+
with:
141+
name: deb-packages
142+
path: "*.deb"
143+
144+
rpm:
145+
name: Build RPM packages
146+
runs-on: ubuntu-latest
147+
container: fedora:40
148+
needs: version
149+
150+
steps:
151+
- name: Install dependencies
152+
run: |
153+
dnf install -y \
154+
git gcc gcc-c++ cmake \
155+
ca-certificates \
156+
rpm-build
157+
158+
- name: Checkout
159+
uses: actions/checkout@v4
160+
161+
- name: Build library
162+
run: |
163+
cmake -B build \
164+
-DCMAKE_BUILD_TYPE=Release \
165+
-DCMAKE_INSTALL_PREFIX=/usr
166+
cmake --build build -j$(nproc)
167+
168+
- name: Setup RPM build tree
169+
run: |
170+
mkdir -p ~/rpmbuild/{BUILD,RPMS,SOURCES,SPECS,SRPMS}
171+
172+
# Copy built libraries
173+
mkdir -p ~/rpmbuild/BUILD/build
174+
175+
# Shared libraries
176+
cp build/libdynemit.so.${{ needs.version.outputs.version }} ~/rpmbuild/BUILD/build/
177+
cp build/src/libdynemit_core.so.${{ needs.version.outputs.version }} ~/rpmbuild/BUILD/build/
178+
find build/features -name "*.so.${{ needs.version.outputs.version }}" -exec cp {} ~/rpmbuild/BUILD/build/ \;
179+
180+
# Static libraries
181+
cp build/libdynemit.a ~/rpmbuild/BUILD/build/
182+
cp build/src/libdynemit_core.a ~/rpmbuild/BUILD/build/
183+
find build/features -name "*.a" -exec cp {} ~/rpmbuild/BUILD/build/ \;
184+
185+
# Headers
186+
mkdir -p ~/rpmbuild/BUILD/include/dynemit
187+
cp include/dynemit.h ~/rpmbuild/BUILD/include/
188+
cp include/dynemit/*.h ~/rpmbuild/BUILD/include/dynemit/
189+
190+
# pkg-config
191+
cp build/libdynemit.pc ~/rpmbuild/BUILD/
192+
193+
# Documentation
194+
cp LICENSE README.md ~/rpmbuild/BUILD/
195+
196+
- name: Build RPM packages
197+
run: |
198+
rpmbuild -bb \
199+
--define "version ${{ needs.version.outputs.version }}" \
200+
--define "release 1" \
201+
--define "_topdir $HOME/rpmbuild" \
202+
--buildroot "$HOME/rpmbuild/BUILDROOT/libdynemit-${{ needs.version.outputs.version }}-1.x86_64" \
203+
pkg/rpm/libdynemit.spec
204+
205+
- name: Copy RPM to workspace
206+
run: find ~/rpmbuild/RPMS -name '*.rpm' -exec cp {} . \;
207+
208+
- name: Upload RPM artifacts
209+
uses: actions/upload-artifact@v4
210+
with:
211+
name: rpm-packages
212+
path: "*.rpm"

0 commit comments

Comments
 (0)