Handle static Qt AppImage packaging #9
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: release binaries | |
| on: | |
| push: | |
| tags: | |
| - "v*" | |
| workflow_dispatch: | |
| inputs: | |
| tag_name: | |
| description: "Release tag to create, for example v0.1.0-native.1" | |
| required: true | |
| type: string | |
| prerelease: | |
| description: "Mark the GitHub Release as a prerelease" | |
| default: true | |
| required: true | |
| type: boolean | |
| permissions: | |
| contents: write | |
| jobs: | |
| build: | |
| name: ${{ matrix.name }} | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - name: windows-x64 | |
| os: windows-latest | |
| triplet: x64-windows | |
| artifact: rembg-gui-windows-x64.zip | |
| - name: linux-x64 | |
| os: ubuntu-22.04 | |
| triplet: x64-linux | |
| artifact: rembg-gui-linux-x64.AppImage | |
| env: | |
| VCPKG_DEFAULT_TRIPLET: ${{ matrix.triplet }} | |
| VCPKG_INSTALLED_DIR: ${{ github.workspace }}/vcpkg_installed | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Install Linux build packages | |
| if: runner.os == 'Linux' | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y \ | |
| autoconf \ | |
| autoconf-archive \ | |
| automake \ | |
| build-essential \ | |
| libfuse2 \ | |
| libgl1-mesa-dev \ | |
| libtool \ | |
| libx11-dev \ | |
| libxcb1-dev \ | |
| libxcb-cursor-dev \ | |
| libxcb-icccm4-dev \ | |
| libxcb-image0-dev \ | |
| libxcb-keysyms1-dev \ | |
| libxcb-randr0-dev \ | |
| libxcb-render-util0-dev \ | |
| libxcb-shape0-dev \ | |
| libxcb-shm0-dev \ | |
| libxcb-sync-dev \ | |
| libxcb-xfixes0-dev \ | |
| libxcb-xkb-dev \ | |
| libxkbcommon-dev \ | |
| libxkbcommon-x11-dev \ | |
| patchelf \ | |
| pkg-config | |
| - name: Restore vcpkg cache | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| ${{ github.workspace }}/vcpkg | |
| ${{ github.workspace }}/vcpkg_installed | |
| key: vcpkg-${{ matrix.triplet }}-${{ hashFiles('src_cpp/vcpkg.json') }} | |
| - name: Bootstrap vcpkg on Windows | |
| if: runner.os == 'Windows' | |
| shell: pwsh | |
| run: | | |
| if (!(Test-Path vcpkg)) { | |
| git clone https://github.com/microsoft/vcpkg.git | |
| } | |
| ./vcpkg/bootstrap-vcpkg.bat | |
| - name: Bootstrap vcpkg on Linux | |
| if: runner.os == 'Linux' | |
| run: | | |
| if [ ! -d vcpkg ]; then | |
| git clone https://github.com/microsoft/vcpkg.git | |
| fi | |
| ./vcpkg/bootstrap-vcpkg.sh | |
| - name: Build and package Linux AppImage | |
| if: runner.os == 'Linux' | |
| env: | |
| ARTIFACT_NAME: ${{ matrix.artifact }} | |
| run: bash src_cpp/scripts/ci-linux.sh | |
| - name: Configure | |
| if: runner.os == 'Windows' | |
| run: > | |
| cmake -S src_cpp -B build | |
| -DCMAKE_BUILD_TYPE=Release | |
| -DCMAKE_TOOLCHAIN_FILE=${{ github.workspace }}/vcpkg/scripts/buildsystems/vcpkg.cmake | |
| -DVCPKG_TARGET_TRIPLET=${{ matrix.triplet }} | |
| -DVCPKG_INSTALLED_DIR=${{ github.workspace }}/vcpkg_installed | |
| - name: Build | |
| if: runner.os == 'Windows' | |
| run: cmake --build build --config Release --parallel | |
| - name: Test | |
| if: runner.os == 'Windows' | |
| env: | |
| REMBG_NATIVE_RUN_MODEL_TESTS: "1" | |
| U2NET_HOME: ${{ github.workspace }}/build/model-cache | |
| run: ctest --test-dir build --output-on-failure -C Release | |
| - name: Install Windows bundle | |
| if: runner.os == 'Windows' | |
| run: cmake --install build --config Release --prefix ${{ github.workspace }}/dist/rembg-gui | |
| - name: Package Windows bundle | |
| if: runner.os == 'Windows' | |
| shell: pwsh | |
| run: Compress-Archive -Path dist/rembg-gui/* -DestinationPath ${{ matrix.artifact }} | |
| - name: Upload artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: ${{ matrix.name }} | |
| path: ${{ matrix.artifact }} | |
| publish: | |
| name: publish GitHub release | |
| needs: build | |
| runs-on: ubuntu-22.04 | |
| if: github.event_name == 'push' || github.event_name == 'workflow_dispatch' | |
| steps: | |
| - name: Download binary artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| path: release-assets | |
| - name: Publish GitHub Release | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| TAG_NAME: ${{ github.event_name == 'workflow_dispatch' && inputs.tag_name || github.ref_name }} | |
| IS_PRERELEASE: ${{ github.event_name == 'workflow_dispatch' && inputs.prerelease || false }} | |
| run: | | |
| set -euo pipefail | |
| assets=( | |
| "release-assets/windows-x64/rembg-gui-windows-x64.zip" | |
| "release-assets/linux-x64/rembg-gui-linux-x64.AppImage" | |
| ) | |
| for asset in "${assets[@]}"; do | |
| test -f "$asset" | |
| done | |
| release_flags=() | |
| if [ "$IS_PRERELEASE" = "true" ]; then | |
| release_flags+=(--prerelease) | |
| fi | |
| if gh release view "$TAG_NAME" >/dev/null 2>&1; then | |
| gh release upload "$TAG_NAME" "${assets[@]}" --clobber | |
| else | |
| gh release create "$TAG_NAME" "${assets[@]}" \ | |
| --target "$GITHUB_SHA" \ | |
| --title "$TAG_NAME" \ | |
| --generate-notes \ | |
| "${release_flags[@]}" | |
| fi |