diff --git a/.github/workflows/build-appimage.yml b/.github/workflows/build-appimage.yml index 30e74d9..de5bd39 100644 --- a/.github/workflows/build-appimage.yml +++ b/.github/workflows/build-appimage.yml @@ -1,4 +1,4 @@ -name: Build AppImage +name: Build and Test AppImage on: push: @@ -13,17 +13,22 @@ on: jobs: build: runs-on: ubuntu-latest - steps: - name: Checkout code uses: actions/checkout@v2 with: - fetch-depth: 0 # Fetch full Git history and tags + fetch-depth: 0 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 - - name: Determine version and dist + - name: Determine Version id: version run: | - LATEST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "0.0.0") + # 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 @@ -37,43 +42,62 @@ jobs: echo "VERSION=$VERSION" >> $GITHUB_ENV echo "DIST=$DIST" >> $GITHUB_ENV - - name: Set up CentOS 7 Docker + - name: Build AppImage run: | docker run --rm -v $(pwd):/workspace -w /workspace centos:7 /bin/bash -c " # 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 groupinstall -y 'Development Tools' yum install -y gtk3-devel glib2-devel gettext-devel desktop-file-utils \ patchelf wget libtool autoconf automake pkgconfig fuse fuse-libs - wget https://github.com/AppImage/AppImageKit/releases/download/continuous/appimagetool-x86_64.AppImage - chmod +x appimagetool-x86_64.AppImage + # 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 - mkdir -p AppDir/usr/bin + # 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/ - # Build the AppImage with embedded runtime and include version in filename - ./appimagetool-x86_64.AppImage AppDir --runtime-arch=x86_64 -n --embed-runtime - mv xnec2c*.AppImage xnec2c-${VERSION}-${{ github.sha }}.AppImage + # 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 - chmod +x xnec2c-${VERSION}-${{ github.sha }}.AppImage - ./xnec2c-${VERSION}-${{ github.sha }}.AppImage --appimage-extract-and-run -h + # 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: Upload the 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}-${{ github.sha }}.AppImage + name: xnec2c-appimage + path: xnec2c-${VERSION}${DIST}.AppImage