github: fix build-deb-packages #27
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: Determine Version | |
id: version | |
run: | | |
LATEST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "v0.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: Build AppImage | |
run: | | |
docker run --rm -v $(pwd):/workspace -w /workspace centos:7 /bin/bash -c " | |
set -eux | |
# Update repository URLs to use the vault since CentOS 7 has reached EOL | |
echo 'Updating repository URLs...' | |
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 | |
# Install EPEL repository first | |
echo 'Installing epel-release...' | |
yum install -y epel-release | |
# Install all required packages | |
echo 'Installing dependencies...' | |
yum install -y gcc make automake autoconf gtk3-devel \ | |
gettext-devel libtool fuse fuse-libs patchelf wget | |
# Download appimagetool | |
echo 'Downloading appimagetool...' | |
wget https://github.com/AppImage/AppImageKit/releases/download/continuous/appimagetool-x86_64 -O appimagetool | |
chmod +x appimagetool | |
ls -l appimagetool # Ensure it was downloaded correctly | |
# Prepare directories | |
echo 'Preparing directories...' | |
mkdir -p AppDir/usr/bin AppDir/usr/share/icons/hicolor/scalable/apps AppDir/usr/share/applications | |
# Build the application | |
echo 'Building the application...' | |
./autogen.sh && ./configure && make | |
make install DESTDIR=$(pwd)/AppDir | |
# Copy necessary resources | |
echo 'Copying 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/ | |
# Create AppRun script | |
echo 'Creating AppRun script...' | |
echo '#!/bin/bash' > AppDir/AppRun | |
echo 'exec /usr/bin/xnec2c \"$@\"' >> AppDir/AppRun | |
chmod +x AppDir/AppRun | |
# Create AppImage | |
echo 'Creating AppImage...' | |
./appimagetool AppDir xnec2c-v${VERSION}${DIST}.AppImage | |
if [ ! -f "xnec2c-v${VERSION}${DIST}.AppImage" ]; then | |
echo 'AppImage creation failed.' | |
echo 'Directory listing:' | |
ls -l | |
exit 1 | |
fi | |
# Finalize and rename the AppImage | |
echo 'Finalizing 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 |