|
| 1 | +name: ARStack Studio Linux AppImage |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + paths: |
| 6 | + - 'apps/arstack_studio/**' |
| 7 | + - '.github/workflows/arstack-studio-linux-appimage.yml' |
| 8 | + - 'scripts/install-linux.sh' |
| 9 | + workflow_dispatch: |
| 10 | + inputs: |
| 11 | + release_tag: |
| 12 | + description: 'Existing GitHub release tag to build, test and attach Linux AppImage; blank = build artifact only' |
| 13 | + required: false |
| 14 | + type: string |
| 15 | + |
| 16 | +permissions: |
| 17 | + contents: read |
| 18 | + |
| 19 | +jobs: |
| 20 | + appimage: |
| 21 | + name: Build and test Linux x86_64 package |
| 22 | + runs-on: ubuntu-22.04 |
| 23 | + timeout-minutes: 55 |
| 24 | + permissions: |
| 25 | + contents: read |
| 26 | + steps: |
| 27 | + - uses: actions/checkout@v4 |
| 28 | + with: |
| 29 | + ref: ${{ github.event_name == 'workflow_dispatch' && inputs.release_tag != '' && inputs.release_tag || github.sha }} |
| 30 | + fetch-depth: 0 |
| 31 | + |
| 32 | + - name: Confirm release identity before packaging |
| 33 | + if: ${{ inputs.release_tag != '' }} |
| 34 | + env: |
| 35 | + GH_TOKEN: ${{ github.token }} |
| 36 | + TAG: ${{ inputs.release_tag }} |
| 37 | + run: | |
| 38 | + set -euo pipefail |
| 39 | + test "$(git rev-parse HEAD)" = "$(git rev-parse "$TAG^{commit}")" |
| 40 | + gh release view "$TAG" --json isDraft,isPrerelease -q 'select(.isDraft==false and .isPrerelease==false)' > release-check.json |
| 41 | + test -s release-check.json |
| 42 | +
|
| 43 | + - name: Install Linux native dependencies |
| 44 | + run: | |
| 45 | + sudo apt-get update |
| 46 | + sudo apt-get install -y --no-install-recommends cmake ninja-build build-essential \ |
| 47 | + libgl1-mesa-dev libxkbcommon-x11-0 libxcb-cursor0 libxcb-xinerama0 \ |
| 48 | + libxcb-xkb1 libxcb-randr0 libxcb-image0 libxcb-keysyms1 libxcb-render-util0 \ |
| 49 | + libfuse2 unzip xvfb libdbus-1-3 |
| 50 | +
|
| 51 | + - name: Install Qt 6 |
| 52 | + uses: jurplel/install-qt-action@v4 |
| 53 | + with: |
| 54 | + version: '6.10.3' |
| 55 | + arch: linux_gcc_64 |
| 56 | + modules: 'qtserialport' |
| 57 | + cache: true |
| 58 | + |
| 59 | + - name: Compile native Linux Studio and smoke test |
| 60 | + run: | |
| 61 | + set -euo pipefail |
| 62 | + cmake -S apps/arstack_studio -B build-studio-linux -G Ninja \ |
| 63 | + -DCMAKE_BUILD_TYPE=Release -DARIEC61850_WARNINGS_AS_ERRORS=ON |
| 64 | + cmake --build build-studio-linux --target arstack_studio --parallel 2 |
| 65 | + test -x build-studio-linux/arstack_studio |
| 66 | + QT_QPA_PLATFORM=offscreen xvfb-run -a build-studio-linux/arstack_studio --check-reference-template |
| 67 | + QT_QPA_PLATFORM=offscreen xvfb-run -a build-studio-linux/arstack_studio --check-p0-policy |
| 68 | +
|
| 69 | + - name: Stage Linux app and matched optional release firmware |
| 70 | + env: |
| 71 | + GH_TOKEN: ${{ github.token }} |
| 72 | + TAG: ${{ inputs.release_tag }} |
| 73 | + run: | |
| 74 | + set -euo pipefail |
| 75 | + mkdir -p AppDir/usr/bin AppDir/usr/share/icons/hicolor/512x512/apps |
| 76 | + cp build-studio-linux/arstack_studio AppDir/usr/bin/ARStackStudio |
| 77 | + cp assets/studio_icon/android-chrome-512x512.png AppDir/usr/share/icons/hicolor/512x512/apps/arstack-studio.png |
| 78 | + cat > arstack-studio.desktop <<'DESKTOP' |
| 79 | + [Desktop Entry] |
| 80 | + Type=Application |
| 81 | + Name=ARStack Studio |
| 82 | + Exec=ARStackStudio |
| 83 | + Icon=arstack-studio |
| 84 | + Categories=Education;Science;Electronics; |
| 85 | + Terminal=false |
| 86 | + DESKTOP |
| 87 | + cp LICENSE NOTICE COPYRIGHT.md THIRD_PARTY_NOTICES.md AppDir/usr/bin/ |
| 88 | + if [ -n "$TAG" ]; then |
| 89 | + mkdir -p release-firmware AppDir/usr/bin/firmware AppDir/usr/bin/tools |
| 90 | + gh release download "$TAG" --dir release-firmware --pattern 'firmware-manifest.json' --pattern '*.bin' |
| 91 | + python3 - <<'PY' |
| 92 | + import hashlib,json,pathlib,shutil |
| 93 | + root=pathlib.Path('release-firmware') |
| 94 | + manifest=json.loads((root/'firmware-manifest.json').read_text()) |
| 95 | + binfiles=list(root.glob('*.bin')) |
| 96 | + assert len(binfiles)==1 and manifest['chip']=='esp32p4', 'Release firmware ambiguity' |
| 97 | + src=binfiles[0] |
| 98 | + assert hashlib.sha256(src.read_bytes()).hexdigest()==manifest['sha256'], 'Firmware hash mismatch' |
| 99 | + output=pathlib.Path('AppDir/usr/bin/firmware') |
| 100 | + shutil.copy2(src,output/manifest['image']) |
| 101 | + shutil.copy2(root/'firmware-manifest.json',output/'firmware-manifest.json') |
| 102 | + (output/'SHA256SUMS.txt').write_text(f"{manifest['sha256']} {manifest['image']}\n") |
| 103 | + PY |
| 104 | + curl -fLsS https://github.com/esp-rs/espflash/releases/download/v4.5.0/espflash-x86_64-unknown-linux-gnu.zip -o espflash.zip |
| 105 | + echo 'dcd7fd822f247df18966935bbb10c7cb4b700c87172349633e9e323ee2542717 espflash.zip' | sha256sum -c - |
| 106 | + unzip -j espflash.zip 'espflash' -d AppDir/usr/bin/tools |
| 107 | + chmod +x AppDir/usr/bin/tools/espflash |
| 108 | + fi |
| 109 | +
|
| 110 | + - name: Bundle Qt and create single-file AppImage |
| 111 | + uses: miurahr/install-linuxdeploy-action@v1.8.0 |
| 112 | + id: linuxdeploy |
| 113 | + with: |
| 114 | + plugins: qt appimage |
| 115 | + |
| 116 | + - name: Generate AppImage and release checksum |
| 117 | + env: |
| 118 | + QML_SOURCES_PATHS: ${{ github.workspace }}/apps/arstack_studio/qml |
| 119 | + VERSION: ${{ inputs.release_tag || 'preview' }} |
| 120 | + run: | |
| 121 | + set -euo pipefail |
| 122 | + export QMAKE="$(command -v qmake6 || command -v qmake)" |
| 123 | + ${{ steps.linuxdeploy.outputs.linuxdeploy }} \ |
| 124 | + --appdir AppDir \ |
| 125 | + --executable AppDir/usr/bin/ARStackStudio \ |
| 126 | + --desktop-file arstack-studio.desktop \ |
| 127 | + --icon-file AppDir/usr/share/icons/hicolor/512x512/apps/arstack-studio.png \ |
| 128 | + --plugin qt --output appimage |
| 129 | + shopt -s nullglob |
| 130 | + images=( ./*.AppImage ) |
| 131 | + test "${#images[@]}" -eq 1 |
| 132 | + mv "${images[0]}" ARStack-Studio-linux-x86_64.AppImage |
| 133 | + chmod +x ARStack-Studio-linux-x86_64.AppImage |
| 134 | + APPIMAGE_EXTRACT_AND_RUN=1 QT_QPA_PLATFORM=offscreen \ |
| 135 | + xvfb-run -a ./ARStack-Studio-linux-x86_64.AppImage --check-reference-template |
| 136 | + sha256sum ARStack-Studio-linux-x86_64.AppImage > ARStack-Studio-linux-x86_64.sha256 |
| 137 | +
|
| 138 | + - name: Upload reviewed Linux artifacts |
| 139 | + uses: actions/upload-artifact@v4 |
| 140 | + with: |
| 141 | + name: arstack-studio-linux-x86_64 |
| 142 | + path: | |
| 143 | + ARStack-Studio-linux-x86_64.AppImage |
| 144 | + ARStack-Studio-linux-x86_64.sha256 |
| 145 | + if-no-files-found: error |
| 146 | + retention-days: 14 |
| 147 | + |
| 148 | + attach-verified-release: |
| 149 | + name: Attach tested Linux package to exact release tag |
| 150 | + needs: appimage |
| 151 | + if: ${{ github.event_name == 'workflow_dispatch' && inputs.release_tag != '' }} |
| 152 | + runs-on: ubuntu-latest |
| 153 | + permissions: |
| 154 | + contents: write |
| 155 | + steps: |
| 156 | + - uses: actions/checkout@v4 |
| 157 | + with: |
| 158 | + ref: ${{ inputs.release_tag }} |
| 159 | + fetch-depth: 0 |
| 160 | + - name: Download Linux build that passed the AppImage checks |
| 161 | + uses: actions/download-artifact@v4 |
| 162 | + with: |
| 163 | + name: arstack-studio-linux-x86_64 |
| 164 | + - name: Verify tag and release before publishing |
| 165 | + env: |
| 166 | + GH_TOKEN: ${{ github.token }} |
| 167 | + TAG: ${{ inputs.release_tag }} |
| 168 | + run: | |
| 169 | + set -euo pipefail |
| 170 | + test "$(git rev-parse HEAD)" = "$(git rev-parse "$TAG^{commit}")" |
| 171 | + gh release view "$TAG" --json isDraft,isPrerelease -q 'select(.isDraft==false and .isPrerelease==false)' > release-check.json |
| 172 | + test -s release-check.json |
| 173 | + sha256sum -c ARStack-Studio-linux-x86_64.sha256 |
| 174 | + gh release upload "$TAG" \ |
| 175 | + ARStack-Studio-linux-x86_64.AppImage \ |
| 176 | + ARStack-Studio-linux-x86_64.sha256 |
0 commit comments