summaryrefslogtreecommitdiff
path: root/.github/actions/meshmc/package/linux/action.yml
blob: f6eb6f455eca561d49e64e93f0a1182df6e3731b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
name: Package for Linux
description: Create Linux packages for MeshMC

inputs:
  version:
    description: Launcher version
    required: true
  build-type:
    description: Type for the build
    required: true
    default: Debug
  artifact-name:
    description: Name of the uploaded artifact
    required: true
    default: Linux
  qt-version:
    description: Version of Qt to use
    required: true
  gpg-private-key:
    description: Private key for AppImage signing
    required: false
  gpg-private-key-id:
    description: ID for the gpg-private-key, to select the signing key
    required: false

runs:
  using: composite

  steps:
    - name: Cleanup Qt installation on Linux
      shell: bash
      run: |
        rm -rf "$QT_PLUGIN_PATH"/printsupport
        rm -rf "$QT_PLUGIN_PATH"/sqldrivers
        rm -rf "$QT_PLUGIN_PATH"/help
        rm -rf "$QT_PLUGIN_PATH"/designer
        rm -rf "$QT_PLUGIN_PATH"/qmltooling
        rm -rf "$QT_PLUGIN_PATH"/qmlls
        rm -rf "$QT_PLUGIN_PATH"/qmllint
        rm -rf "$QT_PLUGIN_PATH"/platformthemes/libqgtk3.so

    - name: Setup build variables
      shell: bash
      run: |
        # Fixup architecture naming for AppImages
        dpkg_arch="$(dpkg-architecture -q DEB_HOST_ARCH_CPU)"
        case "$dpkg_arch" in
          "amd64")
            APPIMAGE_ARCH="x86_64"
            ;;
          "arm64")
            APPIMAGE_ARCH="aarch64"
            ;;
          *)
            echo "# 🚨 The Debian architecture \"$deb_arch\" is not recognized!" >> "$GITHUB_STEP_SUMMARY"
            exit 1
            ;;
        esac
        echo "APPIMAGE_ARCH=$APPIMAGE_ARCH" >> "$GITHUB_ENV"

        # Used for the file paths of libraries
        echo "DEB_HOST_MULTIARCH=$(dpkg-architecture -q DEB_HOST_MULTIARCH)" >> "$GITHUB_ENV"

    - name: Package AppImage
      shell: bash
      env:
        VERSION: ${{ github.ref_type == 'tag' && github.ref_name || inputs.version }}
        BUILD_DIR: meshmc/build
        INSTALL_APPIMAGE_DIR: meshmc/install-appdir

        GPG_PRIVATE_KEY: ${{ inputs.gpg-private-key }}
      run: |
        cmake --install ${{ env.BUILD_DIR }} --config ${{ inputs.build-type }} --prefix ${{ env.INSTALL_APPIMAGE_DIR }}

        if [ '${{ inputs.gpg-private-key-id }}' != '' ]; then
          echo "$GPG_PRIVATE_KEY" > privkey.asc
          gpg --import privkey.asc
          gpg --export --armor ${{ inputs.gpg-private-key-id }} > pubkey.asc
        else
          echo ":warning: Skipped code signing for Linux AppImage, as gpg key was not present." >> $GITHUB_STEP_SUMMARY
        fi

        sharun lib4bin \
          --hard-links \
          --with-hooks \
          --dst-dir "$INSTALL_APPIMAGE_DIR" \
          "$INSTALL_APPIMAGE_DIR"/bin/* "$QT_PLUGIN_PATH"/*/*.so

        cp ~/bin/AppImageUpdate.AppImage "$INSTALL_APPIMAGE_DIR"/bin/
        # FIXME(@YongDo-Hyun): gamemode doesn't seem to be very portable with DBus. Find a way to make it work!
        find "$INSTALL_APPIMAGE_DIR" -name '*gamemode*' -exec rm {} +

        #disable OpenGL and Vulkan launcher features until https://github.com/VHSgunzo/sharun/issues/35
        echo "LAUNCHER_DISABLE_GLVULKAN=1" > "$INSTALL_APPIMAGE_DIR"/.env
        #makes the launcher use portals for file picking
        echo "QT_QPA_PLATFORMTHEME=xdgdesktopportal" > "$INSTALL_APPIMAGE_DIR"/.env
        ln -s org.projecttick.MeshMC.metainfo.xml "$INSTALL_APPIMAGE_DIR"/share/metainfo/org.projecttick.MeshMC.appdata.xml
        ln -s share/applications/org.projecttick.MeshMC.desktop "$INSTALL_APPIMAGE_DIR"
        ln -s share/icons/hicolor/256x256/apps/org.projecttick.MeshMC.png "$INSTALL_APPIMAGE_DIR"
        mv "$INSTALL_APPIMAGE_DIR"/{sharun,AppRun}
        ls -la "$INSTALL_APPIMAGE_DIR"

        if [[ "${{ github.ref_type }}" == "tag" ]]; then
          APPIMAGE_DEST="MeshMC-Linux-$APPIMAGE_ARCH.AppImage"
        else
          APPIMAGE_DEST="MeshMC-Linux-$VERSION-${{ inputs.build-type }}-$APPIMAGE_ARCH.AppImage"
        fi

        mkappimage \
          --updateinformation "gh-releases-zsync|${{ github.repository_owner }}|${{ github.event.repository.name }}|latest|MeshMC-Linux-$APPIMAGE_ARCH.AppImage.zsync" \
          "$INSTALL_APPIMAGE_DIR" \
          "$APPIMAGE_DEST"

    - name: Package portable tarball
      shell: bash
      env:
        BUILD_DIR: meshmc/build

        INSTALL_PORTABLE_DIR: meshmc/install-portable
      run: |
        cmake --install ${{ env.BUILD_DIR }} --config ${{ inputs.build-type }} --prefix ${{ env.INSTALL_PORTABLE_DIR }}
        cmake --install ${{ env.BUILD_DIR }} --config ${{ inputs.build-type }} --prefix ${{ env.INSTALL_PORTABLE_DIR }} --component portable

        sharun lib4bin \
          --with-hooks \
          --hard-links \
          --dst-dir "$INSTALL_PORTABLE_DIR" \
          "$INSTALL_PORTABLE_DIR"/bin/* "$QT_PLUGIN_PATH"/*/*.so

        # FIXME(@YongDo-Hyun): gamemode doesn't seem to be very portable with DBus. Find a way to make it work!
        find "$INSTALL_PORTABLE_DIR" -name '*gamemode*' -exec rm {} +

        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
        cd ${{ env.INSTALL_PORTABLE_DIR }}
        tar -czf ../MeshMC-portable.tar.gz *

    - name: Upload binary tarball
      uses: actions/upload-artifact@v7
      with:
        name: MeshMC-${{ inputs.artifact-name }}-Qt6-Portable-${{ inputs.version }}-${{ inputs.build-type }}
        path: meshmc/MeshMC-portable.tar.gz

    - name: Upload AppImage
      uses: actions/upload-artifact@v7
      with:
        name: MeshMC-${{ runner.os }}-${{ inputs.version }}-${{ inputs.build-type }}-${{ env.APPIMAGE_ARCH }}.AppImage
        path: meshmc/MeshMC-${{ runner.os }}-*${{ env.APPIMAGE_ARCH }}.AppImage

    - name: Upload AppImage Zsync
      uses: actions/upload-artifact@v7
      with:
        name: MeshMC-${{ runner.os }}-${{ inputs.version }}-${{ inputs.build-type }}-${{ env.APPIMAGE_ARCH }}.AppImage.zsync
        path: meshmc/MeshMC-${{ runner.os }}-*${{ env.APPIMAGE_ARCH }}.AppImage.zsync