Skip to content

Commit

Permalink
Add CI workflows for DEB, RPM, and AppImage builds
Browse files Browse the repository at this point in the history
- Added `build-deb-packages.yml` to automate the creation of DEB
  packages using `debuild` for all supported Ubuntu and Debian versions.

- Added `build-rpm-packages.yml` to automate the creation of RPM
  packages using `rpmbuild` for all supported Fedora and AlmaLinux
  versions.

- Added `build-appimage.yml` to build an AppImage on CentOS 7, ensuring
  compatibility with systems using `glibc <= 2.17`.

Each workflow includes automated tests and artifact uploads, improving
the packaging and distribution process across multiple Linux
distributions.
  • Loading branch information
Eric Wheeler committed Aug 14, 2024
1 parent ba85930 commit 48f5d94
Show file tree
Hide file tree
Showing 3 changed files with 284 additions and 0 deletions.
109 changes: 109 additions & 0 deletions .github/workflows/build-appimage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
name: Build and Test AppImage

on:
push:
branches:
- main
- master
pull_request:
branches:
- main
- master

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Determine Version
id: version
run: |
# Get the most recent tag
LATEST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "v0.0.0")
# Check if the latest commit is tagged
TAGGED_COMMIT=$(git describe --tags --exact-match 2>/dev/null || echo "notag")
if [ "$TAGGED_COMMIT" = "notag" ]; then
VERSION="${LATEST_TAG}+"
DIST="-git"
else
VERSION=$LATEST_TAG
DIST=""
fi
echo "VERSION=$VERSION" >> $GITHUB_ENV
echo "DIST=$DIST" >> $GITHUB_ENV
- name: Build AppImage
run: |
docker run --rm -v $(pwd):/workspace -w /workspace centos:7 /bin/bash -c "
set -x
# Update repository URLs to use the vault since CentOS 7 has reached EOL
sed -i 's|^mirrorlist=|#mirrorlist=|g' /etc/yum.repos.d/CentOS-*.repo
sed -i 's|^#baseurl=http://mirror.centos.org/centos/\$releasever|baseurl=http://vault.centos.org/7.9.2009|g' /etc/yum.repos.d/CentOS-*.repo
yum clean all
yum makecache
yum install -y epel-release
yum install -y gcc make automake autoconf gtk3-devel gettext-devel libtool fuse fuse-libs
yum install -y gtk3-devel glib2-devel gettext-devel desktop-file-utils \
patchelf wget
# Download AppImageTool
wget https://github.com/AppImage/AppImageKit/releases/download/continuous/appimagetool-x86_64 -O appimagetool
chmod +x appimagetool
# Prepare directories
mkdir -p AppDir/usr/bin
mkdir -p AppDir/usr/share/icons/hicolor/scalable/apps
mkdir -p AppDir/usr/share/applications
# Run autogen.sh and build
./autogen.sh
./configure
make
# Install to AppDir
make install DESTDIR=$(pwd)/AppDir
# Copy additional resources
cp src/xnec2c AppDir/usr/bin/
cp resources/xnec2c.svg AppDir/usr/share/icons/hicolor/scalable/apps/
cp files/xnec2c.desktop AppDir/usr/share/applications/
# Add AppRun script
echo '#!/bin/bash' > AppDir/AppRun
echo 'exec /usr/bin/xnec2c "$@"' >> AppDir/AppRun
chmod +x AppDir/AppRun
# Create AppImage
./appimagetool AppDir xnec2c-v${VERSION}${DIST}.AppImage
ls -latr
# Verify creation and permissions
ls -l xnec2c-v${VERSION}${DIST}.AppImage
chmod +x xnec2c-v${VERSION}${DIST}.AppImage
mv xnec2c-v${VERSION}${DIST}.AppImage xnec2c-${VERSION}${DIST}.AppImage
"
- name: Test AppImage
run: |
chmod +x xnec2c-${VERSION}${DIST}.AppImage
./xnec2c-${VERSION}${DIST}.AppImage -h
- name: Upload AppImage
uses: actions/upload-artifact@v2
with:
name: xnec2c-appimage
path: xnec2c-${VERSION}${DIST}.AppImage
92 changes: 92 additions & 0 deletions .github/workflows/build-deb-packages.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
name: Build DEB Packages

on:
push:
branches:
- main
- master
pull_request:
branches:
- main
- master

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
os: ["ubuntu-24.04", "ubuntu-22.04", "ubuntu-20.04", "ubuntu-18.04", "debian-11", "debian-10", "debian-9"]

steps:
- name: Checkout code
uses: actions/checkout@v2
with:
fetch-depth: 0 # Fetch full Git history and tags

- name: Set up the build environment
run: |
sudo apt-get update
sudo apt-get install -y build-essential autoconf automake libtool \
libgtk-3-dev libglib2.0-dev gettext desktop-file-utils devscripts fakeroot lintian autopoint dh-make dh-autoreconf
- name: Determine version and dist
id: version
run: |
LATEST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "0.0.0")
TAGGED_COMMIT=$(git describe --tags --exact-match 2>/dev/null || echo "notag")
if [ "$TAGGED_COMMIT" = "notag" ]; then
VERSION="${LATEST_TAG}+"
DIST="-git"
else
VERSION=$LATEST_TAG
DIST=""
fi
echo "VERSION=$VERSION" >> $GITHUB_ENV
echo "DIST=$DIST" >> $GITHUB_ENV
- name: Generate Debian Packaging Files
run: |
if [ ! -d "debian" ]; then
dh_make --createorig -y --single --native --packagename xnec2c_$VERSION
echo -e '#!/usr/bin/make -f\n%:\n\tdh $@' > debian/rules
chmod +x debian/rules
echo "9" > debian/compat
echo "xnec2c ($VERSION) unstable; urgency=low\n\n * Initial release.\n\n -- Your Name <[email protected]> $(date -R)" > debian/changelog
cat > debian/control <<EOL
Source: xnec2c
Section: utils
Priority: optional
Maintainer: Your Name <[email protected]>
Build-Depends: debhelper (>= 9), autotools-dev, automake, autoconf, libtool, libgtk-3-dev, libglib2.0-dev, gettext, desktop-file-utils
Standards-Version: 3.9.6
Homepage: https://www.example.com

Package: xnec2c
Architecture: any
Depends: \${shlibs:Depends}, \${misc:Depends}
Description: A multi-threaded EM tool to model antenna near- and far-field radiation patterns.
Xnec2c is a high-performance multi-threaded electromagnetic simulation
package to model antenna near- and far-field radiation patterns for
Linux and UNIX operating systems.
EOL
fi

- name: Build the DEB package using debuild
run: |
./autogen.sh
./configure
make
debuild -us -uc -b
- name: Test DEB package
run: |
dpkg -i ../xnec2c_*.deb || true
xnec2c -h
- name: Upload the DEB package
uses: actions/upload-artifact@v2
with:
name: xnec2c-${{ matrix.os }}.deb
path: ../xnec2c_*.deb
83 changes: 83 additions & 0 deletions .github/workflows/build-rpm-packages.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
name: Build RPM Package

on:
push:
branches:
- main
- master
pull_request:
branches:
- main
- master

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Determine Version
id: version
run: |
# Get the most recent tag
LATEST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "v0.0.0")
# Check if the latest commit is tagged
TAGGED_COMMIT=$(git describe --tags --exact-match 2>/dev/null || echo "notag")
if [ "$TAGGED_COMMIT" = "notag" ]; then
VERSION="${LATEST_TAG}+"
DIST="-git"
else
VERSION=$LATEST_TAG
DIST=""
fi
echo "VERSION=$VERSION" >> $GITHUB_ENV
echo "DIST=$DIST" >> $GITHUB_ENV
- name: Build RPM
run: |
docker run --rm -v $(pwd):/workspace -w /workspace almalinux:9 /bin/bash -c "
set -x
# Install dependencies
dnf install -y epel-release
dnf install -y gcc make automake autoconf gtk3-devel gettext-devel libtool \
rpm-build rpmdevtools git
# Prepare the RPM build environment
rpmdev-setuptree
# Generate the spec file
./autogen.sh
# Build the RPM
rpmbuild -ba --define \"_version ${VERSION}\" --define \"_dist ${DIST}\" \
--define \"_topdir /root/rpmbuild\" xnec2c.spec
# Check the RPM files
ls -l /root/rpmbuild/RPMS/x86_64
"
- name: Install and Test RPM
run: |
docker run --rm -v $(pwd):/workspace -w /workspace almalinux:9 /bin/bash -c "
# Install the RPM package
dnf install -y /root/rpmbuild/RPMS/x86_64/xnec2c-*.rpm
# Run the test to verify the package
xnec2c -h
"
- name: Upload RPM
uses: actions/upload-artifact@v2
with:
name: xnec2c-rpm
path: /root/rpmbuild/RPMS/x86_64/xnec2c-*.rpm

0 comments on commit 48f5d94

Please sign in to comment.