|
| 1 | +name: Build Linux AppImage |
| 2 | + |
| 3 | +on: |
| 4 | + # Build on releases |
| 5 | + release: |
| 6 | + types: [published] |
| 7 | + # Allow manual trigger |
| 8 | + workflow_dispatch: |
| 9 | + inputs: |
| 10 | + build_type: |
| 11 | + description: 'Build type (all, minimal, ocr, hardsubx)' |
| 12 | + required: false |
| 13 | + default: 'all' |
| 14 | + # Build on pushes to workflow file for testing |
| 15 | + push: |
| 16 | + paths: |
| 17 | + - '.github/workflows/build_appimage.yml' |
| 18 | + - 'linux/build_appimage.sh' |
| 19 | + |
| 20 | +jobs: |
| 21 | + build-appimage: |
| 22 | + runs-on: ubuntu-22.04 |
| 23 | + strategy: |
| 24 | + fail-fast: false |
| 25 | + matrix: |
| 26 | + build_type: [minimal, ocr, hardsubx] |
| 27 | + |
| 28 | + steps: |
| 29 | + - name: Check if should build this variant |
| 30 | + id: should_build |
| 31 | + run: | |
| 32 | + if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then |
| 33 | + INPUT_TYPE="${{ github.event.inputs.build_type }}" |
| 34 | + if [ "$INPUT_TYPE" = "all" ] || [ "$INPUT_TYPE" = "${{ matrix.build_type }}" ]; then |
| 35 | + echo "should_build=true" >> $GITHUB_OUTPUT |
| 36 | + else |
| 37 | + echo "should_build=false" >> $GITHUB_OUTPUT |
| 38 | + fi |
| 39 | + else |
| 40 | + echo "should_build=true" >> $GITHUB_OUTPUT |
| 41 | + fi |
| 42 | +
|
| 43 | + - name: Checkout repository |
| 44 | + if: steps.should_build.outputs.should_build == 'true' |
| 45 | + uses: actions/checkout@v4 |
| 46 | + |
| 47 | + - name: Install base dependencies |
| 48 | + if: steps.should_build.outputs.should_build == 'true' |
| 49 | + run: | |
| 50 | + sudo apt-get update |
| 51 | + sudo apt-get install -y --no-install-recommends \ |
| 52 | + build-essential \ |
| 53 | + cmake \ |
| 54 | + pkg-config \ |
| 55 | + wget \ |
| 56 | + file \ |
| 57 | + libfuse2 \ |
| 58 | + zlib1g-dev \ |
| 59 | + libpng-dev \ |
| 60 | + libjpeg-dev \ |
| 61 | + libfreetype-dev \ |
| 62 | + libxml2-dev \ |
| 63 | + libcurl4-gnutls-dev \ |
| 64 | + libssl-dev \ |
| 65 | + clang \ |
| 66 | + libclang-dev |
| 67 | +
|
| 68 | + - name: Install OCR dependencies |
| 69 | + if: steps.should_build.outputs.should_build == 'true' && (matrix.build_type == 'ocr' || matrix.build_type == 'hardsubx') |
| 70 | + run: | |
| 71 | + sudo apt-get install -y --no-install-recommends \ |
| 72 | + tesseract-ocr \ |
| 73 | + libtesseract-dev \ |
| 74 | + libleptonica-dev \ |
| 75 | + tesseract-ocr-eng |
| 76 | +
|
| 77 | + - name: Install FFmpeg dependencies (HardSubX) |
| 78 | + if: steps.should_build.outputs.should_build == 'true' && matrix.build_type == 'hardsubx' |
| 79 | + run: | |
| 80 | + sudo apt-get install -y --no-install-recommends \ |
| 81 | + libavcodec-dev \ |
| 82 | + libavformat-dev \ |
| 83 | + libavutil-dev \ |
| 84 | + libswscale-dev \ |
| 85 | + libswresample-dev \ |
| 86 | + libavfilter-dev |
| 87 | +
|
| 88 | + - name: Install Rust toolchain |
| 89 | + if: steps.should_build.outputs.should_build == 'true' |
| 90 | + uses: dtolnay/rust-action@stable |
| 91 | + |
| 92 | + - name: Cache GPAC build |
| 93 | + if: steps.should_build.outputs.should_build == 'true' |
| 94 | + id: cache-gpac |
| 95 | + uses: actions/cache@v4 |
| 96 | + with: |
| 97 | + path: /usr/local/lib/libgpac* |
| 98 | + key: gpac-v2.4.0-ubuntu22 |
| 99 | + |
| 100 | + - name: Build and install GPAC |
| 101 | + if: steps.should_build.outputs.should_build == 'true' && steps.cache-gpac.outputs.cache-hit != 'true' |
| 102 | + run: | |
| 103 | + git clone -b v2.4.0 --depth 1 https://github.com/gpac/gpac |
| 104 | + cd gpac |
| 105 | + ./configure |
| 106 | + make -j$(nproc) lib |
| 107 | + sudo make install-lib |
| 108 | + sudo ldconfig |
| 109 | +
|
| 110 | + - name: Update library cache |
| 111 | + if: steps.should_build.outputs.should_build == 'true' |
| 112 | + run: sudo ldconfig |
| 113 | + |
| 114 | + - name: Build AppImage |
| 115 | + if: steps.should_build.outputs.should_build == 'true' |
| 116 | + run: | |
| 117 | + cd linux |
| 118 | + chmod +x build_appimage.sh |
| 119 | + BUILD_TYPE=${{ matrix.build_type }} ./build_appimage.sh |
| 120 | +
|
| 121 | + - name: Get AppImage name |
| 122 | + if: steps.should_build.outputs.should_build == 'true' |
| 123 | + id: appimage_name |
| 124 | + run: | |
| 125 | + case "${{ matrix.build_type }}" in |
| 126 | + minimal) |
| 127 | + echo "name=ccextractor-minimal-x86_64.AppImage" >> $GITHUB_OUTPUT |
| 128 | + ;; |
| 129 | + ocr) |
| 130 | + echo "name=ccextractor-x86_64.AppImage" >> $GITHUB_OUTPUT |
| 131 | + ;; |
| 132 | + hardsubx) |
| 133 | + echo "name=ccextractor-hardsubx-x86_64.AppImage" >> $GITHUB_OUTPUT |
| 134 | + ;; |
| 135 | + esac |
| 136 | +
|
| 137 | + - name: Test AppImage |
| 138 | + if: steps.should_build.outputs.should_build == 'true' |
| 139 | + run: | |
| 140 | + chmod +x linux/${{ steps.appimage_name.outputs.name }} |
| 141 | + linux/${{ steps.appimage_name.outputs.name }} --version |
| 142 | +
|
| 143 | + - name: Upload AppImage artifact |
| 144 | + if: steps.should_build.outputs.should_build == 'true' |
| 145 | + uses: actions/upload-artifact@v4 |
| 146 | + with: |
| 147 | + name: ${{ steps.appimage_name.outputs.name }} |
| 148 | + path: linux/${{ steps.appimage_name.outputs.name }} |
| 149 | + |
| 150 | + - name: Upload to Release |
| 151 | + if: steps.should_build.outputs.should_build == 'true' && github.event_name == 'release' |
| 152 | + uses: softprops/action-gh-release@v1 |
| 153 | + with: |
| 154 | + files: linux/${{ steps.appimage_name.outputs.name }} |
| 155 | + env: |
| 156 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
0 commit comments