Build Linux binaries via Github Actions #18
Workflow file for this run
This file contains hidden or 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 Qt6 App for Linux | |
| on: | |
| push: | |
| branches: | |
| - master | |
| tags: | |
| - "*" | |
| pull_request: | |
| jobs: | |
| build: | |
| runs-on: ubuntu-22.04 | |
| env: | |
| QT_VERSION: 6.6.0 | |
| APP_NAME: subtivals | |
| BUILD_TYPE: Release | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Get latest tag version | |
| run: echo "PACKAGE_VERSION=$(git describe --tags --abbrev=0 || echo 0.0.0)" >> $GITHUB_ENV | |
| - name: Install dependencies | |
| run: | | |
| sudo apt update | |
| sudo apt install -y \ | |
| qt6-base-dev qt6-tools-dev qt6-tools-dev-tools \ | |
| qt6-declarative-dev \ | |
| libqt6svg6-dev \ | |
| libqt6core5compat6-dev \ | |
| libqt6websockets6-dev \ | |
| libgl1-mesa-dev \ | |
| build-essential cmake \ | |
| patchelf dpkg fakeroot \ | |
| squashfs-tools xz-utils \ | |
| libfuse2 \ | |
| wget curl python3-pip imagemagick | |
| - name: Install Qt using aqtinstall | |
| run: | | |
| python3 -m pip install --upgrade pip | |
| python3 -m pip install aqtinstall | |
| python3 -m aqt install-qt --outputdir "$HOME/Qt" linux desktop "$QT_VERSION" gcc_64 -m all | |
| python3 -m aqt list-qt linux desktop --long-modules "$QT_VERSION" gcc_64 | |
| echo "$HOME/Qt/${QT_VERSION}/gcc_64/bin" >> $GITHUB_PATH | |
| - name: Download linuxdeployqt | |
| run: | | |
| wget https://github.com/probonopd/linuxdeployqt/releases/download/continuous/linuxdeployqt-continuous-x86_64.AppImage | |
| chmod +x linuxdeployqt-continuous-x86_64.AppImage | |
| sudo mv linuxdeployqt-continuous-x86_64.AppImage /usr/local/bin/linuxdeployqt | |
| - name: Configure and build | |
| run: | | |
| which qmake6 | |
| qmake6 --version | |
| qmake6 -query QT_INSTALL_LIBS | |
| mkdir -p build && cd build | |
| qmake6 ../src/${APP_NAME}.pro CONFIG+=release CONFIG+=static | |
| make -j$(nproc) | |
| - name: Prepare AppDir for AppImage | |
| run: | | |
| APPDIR=AppDir | |
| mkdir -p $APPDIR/usr/bin | |
| mkdir -p $APPDIR/usr/share/applications | |
| mkdir -p $APPDIR/usr/share/icons/hicolor/256x256/apps | |
| # Copy binary | |
| cp build/${APP_NAME} $APPDIR/usr/bin/ | |
| # Convert .ico to .png and copy it | |
| convert resources/${APP_NAME}.ico -resize 256x256 $APPDIR/usr/share/icons/hicolor/256x256/apps/${APP_NAME}.png | |
| # Create .desktop file | |
| cat <<EOF > $APPDIR/usr/share/applications/${APP_NAME}.desktop | |
| [Desktop Entry] | |
| Name=${APP_NAME} | |
| Exec=${APP_NAME} | |
| Icon=${APP_NAME} | |
| Type=Application | |
| Categories=Utility; | |
| EOF | |
| - name: Run linuxdeployqt | |
| run: | | |
| linuxdeployqt AppDir/usr/share/applications/${APP_NAME}.desktop -appimage | |
| # Rename output | |
| mv *.AppImage "${APP_NAME}-${PACKAGE_VERSION}.AppImage" | |
| - name: Package as .deb | |
| run: | | |
| mkdir -p package/DEBIAN package/usr/local/bin | |
| cp build/${APP_NAME} package/usr/local/bin/ | |
| cat <<EOF > package/DEBIAN/control | |
| Package: ${APP_NAME} | |
| Version: ${PACKAGE_VERSION} | |
| Architecture: amd64 | |
| Maintainer: Mathieu Leplatre <[email protected]> | |
| Description: A program to project subtitles. | |
| EOF | |
| dpkg-deb --build package "${APP_NAME}-${PACKAGE_VERSION}.deb" | |
| - name: Upload artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: ${{ env.APP_NAME }}-artifacts | |
| path: | | |
| build/${{ env.APP_NAME }} | |
| ${{ env.APP_NAME }}-${{ env.PACKAGE_VERSION }}.deb | |
| ${{ env.APP_NAME }}-${{ env.PACKAGE_VERSION }}.AppImage | |
| release: | |
| needs: build | |
| if: startsWith(github.ref, 'refs/tags/') | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Download built artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: subtivals-artifacts | |
| path: release/ | |
| - name: Create GitHub Release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| files: release/* | |
| tag_name: ${{ github.ref_name }} | |
| name: "Release ${{ github.ref_name }}" | |
| body: "Automated release for version ${{ github.ref_name }}" | |
| draft: false | |
| prerelease: false |