|
| 1 | +name: Package for Linux |
| 2 | +description: Create Linux packages for Freesm Launcher |
| 3 | + |
| 4 | +inputs: |
| 5 | + version: |
| 6 | + description: Launcher version |
| 7 | + required: true |
| 8 | + build-type: |
| 9 | + description: Type for the build |
| 10 | + required: true |
| 11 | + default: Debug |
| 12 | + artifact-name: |
| 13 | + description: Name of the uploaded artifact |
| 14 | + required: true |
| 15 | + default: Linux |
| 16 | + qt-version: |
| 17 | + description: Version of Qt to use |
| 18 | + required: true |
| 19 | + gpg-private-key: |
| 20 | + description: Private key for AppImage signing |
| 21 | + required: false |
| 22 | + gpg-private-key-id: |
| 23 | + description: ID for the gpg-private-key, to select the signing key |
| 24 | + required: false |
| 25 | + |
| 26 | +runs: |
| 27 | + using: composite |
| 28 | + |
| 29 | + steps: |
| 30 | + - name: Setup build variables |
| 31 | + shell: bash |
| 32 | + run: | |
| 33 | + # Fixup architecture naming for AppImages |
| 34 | + dpkg_arch="$(dpkg-architecture -q DEB_HOST_ARCH_CPU)" |
| 35 | + case "$dpkg_arch" in |
| 36 | + "amd64") |
| 37 | + APPIMAGE_ARCH="x86_64" |
| 38 | + ;; |
| 39 | + "arm64") |
| 40 | + APPIMAGE_ARCH="aarch64" |
| 41 | + ;; |
| 42 | + *) |
| 43 | + echo "# 🚨 The Debian architecture \"$deb_arch\" is not recognized!" >> "$GITHUB_STEP_SUMMARY" |
| 44 | + exit 1 |
| 45 | + ;; |
| 46 | + esac |
| 47 | + echo "APPIMAGE_ARCH=$APPIMAGE_ARCH" >> "$GITHUB_ENV" |
| 48 | +
|
| 49 | + # Used for the file paths of libraries |
| 50 | + echo "DEB_HOST_MULTIARCH=$(dpkg-architecture -q DEB_HOST_MULTIARCH)" >> "$GITHUB_ENV" |
| 51 | +
|
| 52 | + - name: Package AppImage |
| 53 | + shell: bash |
| 54 | + env: |
| 55 | + VERSION: ${{ github.ref_type == 'tag' && github.ref_name || inputs.version }} |
| 56 | + BUILD_DIR: build |
| 57 | + INSTALL_APPIMAGE_DIR: install-appdir |
| 58 | + |
| 59 | + GPG_PRIVATE_KEY: ${{ inputs.gpg-private-key }} |
| 60 | + run: | |
| 61 | + cmake --install ${{ env.BUILD_DIR }} --config ${{ inputs.build-type }} --prefix ${{ env.INSTALL_APPIMAGE_DIR }} |
| 62 | +
|
| 63 | + if [ '${{ inputs.gpg-private-key-id }}' != '' ]; then |
| 64 | + echo "$GPG_PRIVATE_KEY" > privkey.asc |
| 65 | + gpg --import privkey.asc |
| 66 | + gpg --export --armor 9C7A2C9B62603299 > pubkey.asc |
| 67 | + else |
| 68 | + echo ":warning: Skipped code signing for Linux AppImage, as gpg key was not present." >> $GITHUB_STEP_SUMMARY |
| 69 | + fi |
| 70 | +
|
| 71 | + sharun lib4bin \ |
| 72 | + --hard-links \ |
| 73 | + --with-hooks \ |
| 74 | + --dst-dir "$INSTALL_APPIMAGE_DIR" \ |
| 75 | + "$INSTALL_APPIMAGE_DIR"/bin/* "$QT_PLUGIN_PATH"/*/*.so |
| 76 | +
|
| 77 | + cp ~/bin/AppImageUpdate.AppImage "$INSTALL_APPIMAGE_DIR"/bin/ |
| 78 | + # FIXME(@getchoo): gamemode doesn't seem to be very portable with DBus. Find a way to make it work! |
| 79 | + find "$INSTALL_APPIMAGE_DIR" -name '*gamemode*' -exec rm {} + |
| 80 | +
|
| 81 | + ln -s org.freesmTeam.freesmlauncher.metainfo.xml "$INSTALL_APPIMAGE_DIR"/share/metainfo/org.freesmTeam.freesmlauncher.appdata.xml |
| 82 | + ln -s share/applications/org.freesmTeam.freesmlauncher.desktop "$INSTALL_APPIMAGE_DIR" |
| 83 | + ln -s share/icons/hicolor/256x256/apps/org.freesmTeam.freesmlauncher.png "$INSTALL_APPIMAGE_DIR" |
| 84 | + mv "$INSTALL_APPIMAGE_DIR"/{sharun,AppRun} |
| 85 | + ls -la "$INSTALL_APPIMAGE_DIR" |
| 86 | +
|
| 87 | + if [[ "${{ github.ref_type }}" == "tag" ]]; then |
| 88 | + APPIMAGE_DEST="FreesmLauncher-Linux-$APPIMAGE_ARCH.AppImage" |
| 89 | + else |
| 90 | + APPIMAGE_DEST="FreesmLauncher-Linux-$VERSION-${{ inputs.build-type }}-$APPIMAGE_ARCH.AppImage" |
| 91 | + fi |
| 92 | +
|
| 93 | + mkappimage \ |
| 94 | + --updateinformation "gh-releases-zsync|${{ github.repository_owner }}|${{ github.event.repository.name }}|latest|FreesmLauncher-Linux-$APPIMAGE_ARCH.AppImage.zsync" \ |
| 95 | + "$INSTALL_APPIMAGE_DIR" \ |
| 96 | + "$APPIMAGE_DEST" |
| 97 | +
|
| 98 | + - name: Package portable tarball |
| 99 | + shell: bash |
| 100 | + env: |
| 101 | + BUILD_DIR: build |
| 102 | + |
| 103 | + INSTALL_PORTABLE_DIR: install-portable |
| 104 | + run: | |
| 105 | + cmake --install ${{ env.BUILD_DIR }} --config ${{ inputs.build-type }} --prefix ${{ env.INSTALL_PORTABLE_DIR }} |
| 106 | + cmake --install ${{ env.BUILD_DIR }} --config ${{ inputs.build-type }} --prefix ${{ env.INSTALL_PORTABLE_DIR }} --component portable |
| 107 | +
|
| 108 | + sharun lib4bin \ |
| 109 | + --with-hooks \ |
| 110 | + --hard-links \ |
| 111 | + --dst-dir "$INSTALL_PORTABLE_DIR" \ |
| 112 | + "$INSTALL_PORTABLE_DIR"/bin/* "$QT_PLUGIN_PATH"/*/*.so |
| 113 | +
|
| 114 | + # FIXME(@getchoo): gamemode doesn't seem to be very portable with DBus. Find a way to make it work! |
| 115 | + find "$INSTALL_PORTABLE_DIR" -name '*gamemode*' -exec rm {} + |
| 116 | +
|
| 117 | + for l in $(find ${{ env.INSTALL_PORTABLE_DIR }} -type f -o -type l); do l=${l#$(pwd)/}; l=${l#${{ env.INSTALL_PORTABLE_DIR }}/}; l=${l#./}; echo $l; done > ${{ env.INSTALL_PORTABLE_DIR }}/manifest.txt |
| 118 | + cd ${{ env.INSTALL_PORTABLE_DIR }} |
| 119 | + tar -czf ../FreesmLauncher-portable.tar.gz * |
| 120 | +
|
| 121 | + - name: Upload binary tarball |
| 122 | + uses: actions/upload-artifact@v6 |
| 123 | + with: |
| 124 | + name: FreesmLauncher-${{ inputs.artifact-name }}-Qt6-Portable-${{ inputs.version }}-${{ inputs.build-type }} |
| 125 | + path: FreesmLauncher-portable.tar.gz |
| 126 | + |
| 127 | + - name: Upload AppImage |
| 128 | + uses: actions/upload-artifact@v6 |
| 129 | + with: |
| 130 | + name: FreesmLauncher-${{ runner.os }}-${{ inputs.version }}-${{ inputs.build-type }}-${{ env.APPIMAGE_ARCH }}.AppImage |
| 131 | + path: FreesmLauncher-${{ runner.os }}-*${{ env.APPIMAGE_ARCH }}.AppImage |
| 132 | + |
| 133 | + - name: Upload AppImage Zsync |
| 134 | + uses: actions/upload-artifact@v6 |
| 135 | + with: |
| 136 | + name: FreesmLauncher-${{ runner.os }}-${{ inputs.version }}-${{ inputs.build-type }}-${{ env.APPIMAGE_ARCH }}.AppImage.zsync |
| 137 | + path: FreesmLauncher-${{ runner.os }}-*${{ env.APPIMAGE_ARCH }}.AppImage.zsync |
0 commit comments