ci: copy only required scrcpy binaries into the macOS bundle #13
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 | |
| on: | |
| push: | |
| tags: | |
| - "v*" | |
| workflow_dispatch: | |
| permissions: | |
| contents: write | |
| env: | |
| SCRCPY_VERSION: "3.3.4" | |
| PLATFORM_TOOLS_VERSION: "37.0.0" | |
| jobs: | |
| build: | |
| strategy: | |
| matrix: | |
| include: | |
| - os: windows-latest | |
| target: windows | |
| - os: ubuntu-latest | |
| target: linux | |
| - os: macos-latest | |
| target: darwin | |
| runs-on: ${{ matrix.os }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v6 | |
| - name: Set up Go | |
| uses: actions/setup-go@v6 | |
| with: | |
| go-version-file: go.mod | |
| - name: Install Fyne CLI | |
| run: go install fyne.io/tools/cmd/fyne@latest | |
| - name: Install Linux dependencies | |
| if: matrix.target == 'linux' | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y gcc libgl1-mesa-dev xorg-dev libxkbcommon-dev | |
| - name: Download dependencies | |
| shell: bash | |
| run: | | |
| mkdir -p _bundled | |
| case "${{ matrix.target }}" in | |
| windows) | |
| curl -L -o pt.zip "https://dl.google.com/android/repository/platform-tools_r${PLATFORM_TOOLS_VERSION}-win.zip" | |
| unzip -j pt.zip "platform-tools/adb.exe" "platform-tools/AdbWinApi.dll" "platform-tools/AdbWinUsbApi.dll" -d _bundled | |
| curl -L -o scrcpy.zip "https://github.com/Genymobile/scrcpy/releases/download/v${SCRCPY_VERSION}/scrcpy-win64-v${SCRCPY_VERSION}.zip" | |
| unzip -o -j scrcpy.zip -d _bundled | |
| rm -f _bundled/open_a_terminal_here.bat _bundled/scrcpy-console.bat _bundled/scrcpy-noconsole.vbs | |
| cp assets/icon.png _bundled/icon.png | |
| ;; | |
| linux) | |
| curl -L -o pt.zip "https://dl.google.com/android/repository/platform-tools_r${PLATFORM_TOOLS_VERSION}-linux.zip" | |
| unzip -j pt.zip "platform-tools/adb" -d _bundled | |
| chmod +x _bundled/adb | |
| curl -L -o scrcpy.tar.gz "https://github.com/Genymobile/scrcpy/releases/download/v${SCRCPY_VERSION}/scrcpy-linux-x86_64-v${SCRCPY_VERSION}.tar.gz" | |
| tar --strip-components=1 -xzf scrcpy.tar.gz -C _bundled | |
| ;; | |
| darwin) | |
| curl -L -o pt.zip "https://dl.google.com/android/repository/platform-tools_r${PLATFORM_TOOLS_VERSION}-darwin.zip" | |
| unzip -j pt.zip "platform-tools/adb" -d _bundled | |
| chmod +x _bundled/adb | |
| curl -L -o scrcpy.tar.gz "https://github.com/Genymobile/scrcpy/releases/download/v${SCRCPY_VERSION}/scrcpy-macos-aarch64-v${SCRCPY_VERSION}.tar.gz" | |
| tar --strip-components=1 -xzf scrcpy.tar.gz -C _bundled | |
| ;; | |
| esac | |
| - name: Package | |
| run: fyne package --target ${{ matrix.target }} --release | |
| - name: Rename binary (Windows) | |
| if: matrix.target == 'windows' | |
| run: | | |
| Copy-Item "Mirroid.exe" "mirroid-windows-amd64.exe" | |
| - name: Install InnoSetup (Windows) | |
| if: matrix.target == 'windows' | |
| run: choco install innosetup -y | |
| - name: Build installer (Windows) | |
| if: matrix.target == 'windows' | |
| run: | | |
| & "C:\Program Files (x86)\Inno Setup 6\ISCC.exe" /DMyAppVersion="${{ github.ref_name }}" packaging\windows\mirroid.iss | |
| - name: Create portable zip (Windows) | |
| if: matrix.target == 'windows' | |
| shell: bash | |
| run: | | |
| mkdir -p _portable | |
| cp Mirroid.exe _portable/ | |
| cp _bundled/* _portable/ | |
| cd _portable && 7z a -tzip ../mirroid-windows-amd64-portable.zip . | |
| - name: Upload raw binary (Windows) | |
| if: matrix.target == 'windows' | |
| uses: actions/upload-artifact@v6 | |
| with: | |
| name: mirroid-windows-amd64.exe | |
| path: mirroid-windows-amd64.exe | |
| - name: Upload installer (Windows) | |
| if: matrix.target == 'windows' | |
| uses: actions/upload-artifact@v6 | |
| with: | |
| name: mirroid-windows-amd64-setup.exe | |
| path: mirroid-windows-amd64-setup.exe | |
| - name: Upload portable zip (Windows) | |
| if: matrix.target == 'windows' | |
| uses: actions/upload-artifact@v6 | |
| with: | |
| name: mirroid-windows-amd64-portable.zip | |
| path: mirroid-windows-amd64-portable.zip | |
| - name: Extract binary for packaging (Linux) | |
| if: matrix.target == 'linux' | |
| run: | | |
| mkdir -p _extracted | |
| tar xf Mirroid.tar.xz -C _extracted | |
| BINARY=$(find _extracted -type f -executable | head -1) | |
| echo "MIRROID_BINARY=$BINARY" >> "$GITHUB_ENV" | |
| echo "Found binary at: $BINARY" | |
| - name: Create tarball with deps (Linux) | |
| if: matrix.target == 'linux' | |
| shell: bash | |
| run: | | |
| mkdir -p _tar/mirroid | |
| cp "$MIRROID_BINARY" _tar/mirroid/mirroid | |
| cp _bundled/* _tar/mirroid/ | |
| cd _tar && tar cJf ../mirroid-linux-amd64.tar.xz mirroid/ | |
| - name: Build .deb (Linux) | |
| if: matrix.target == 'linux' | |
| run: | | |
| chmod +x packaging/linux/build-deb.sh | |
| packaging/linux/build-deb.sh "${{ github.ref_name }}" "$MIRROID_BINARY" | |
| - name: Build AppImage (Linux) | |
| if: matrix.target == 'linux' | |
| run: | | |
| chmod +x packaging/linux/build-appimage.sh | |
| packaging/linux/build-appimage.sh "${{ github.ref_name }}" "$MIRROID_BINARY" | |
| - name: Upload tarball (Linux) | |
| if: matrix.target == 'linux' | |
| uses: actions/upload-artifact@v6 | |
| with: | |
| name: mirroid-linux-amd64.tar.xz | |
| path: mirroid-linux-amd64.tar.xz | |
| - name: Upload .deb (Linux) | |
| if: matrix.target == 'linux' | |
| uses: actions/upload-artifact@v6 | |
| with: | |
| name: mirroid-deb | |
| path: mirroid_*.deb | |
| - name: Upload AppImage (Linux) | |
| if: matrix.target == 'linux' | |
| uses: actions/upload-artifact@v6 | |
| with: | |
| name: mirroid-appimage | |
| path: Mirroid-*.AppImage | |
| - name: Copy raw binary (Linux) | |
| if: matrix.target == 'linux' | |
| run: cp _tar/mirroid/mirroid mirroid-linux-amd64 | |
| - name: Upload raw binary (Linux) | |
| if: matrix.target == 'linux' | |
| uses: actions/upload-artifact@v6 | |
| with: | |
| name: mirroid-linux-amd64 | |
| path: mirroid-linux-amd64 | |
| - name: Inject deps into app bundle (macOS) | |
| if: matrix.target == 'darwin' | |
| shell: bash | |
| run: | | |
| cp _bundled/adb _bundled/scrcpy _bundled/scrcpy-server Mirroid.app/Contents/MacOS/ | |
| chmod +x Mirroid.app/Contents/MacOS/adb Mirroid.app/Contents/MacOS/scrcpy | |
| - name: Ad-hoc codesign app bundle (macOS) | |
| if: matrix.target == 'darwin' | |
| run: | | |
| codesign --force --sign - Mirroid.app/Contents/MacOS/adb | |
| codesign --force --sign - Mirroid.app/Contents/MacOS/scrcpy | |
| codesign --force --sign - Mirroid.app | |
| - name: Zip app bundle (macOS) | |
| if: matrix.target == 'darwin' | |
| run: zip -r mirroid-macos-arm64.zip Mirroid.app | |
| - name: Install create-dmg (macOS) | |
| if: matrix.target == 'darwin' | |
| run: brew install create-dmg | |
| - name: Build DMG (macOS) | |
| if: matrix.target == 'darwin' | |
| run: | | |
| chmod +x packaging/macos/build-dmg.sh | |
| packaging/macos/build-dmg.sh "${{ github.ref_name }}" "Mirroid.app" | |
| - name: Upload zip (macOS) | |
| if: matrix.target == 'darwin' | |
| uses: actions/upload-artifact@v6 | |
| with: | |
| name: mirroid-macos-arm64.zip | |
| path: mirroid-macos-arm64.zip | |
| - name: Upload DMG (macOS) | |
| if: matrix.target == 'darwin' | |
| uses: actions/upload-artifact@v6 | |
| with: | |
| name: mirroid-macos-arm64.dmg | |
| path: mirroid-macos-arm64.dmg | |
| - name: Copy raw binary (macOS) | |
| if: matrix.target == 'darwin' | |
| run: cp Mirroid.app/Contents/MacOS/Mirroid mirroid-macos-arm64 | |
| - name: Upload raw binary (macOS) | |
| if: matrix.target == 'darwin' | |
| uses: actions/upload-artifact@v6 | |
| with: | |
| name: mirroid-macos-arm64 | |
| path: mirroid-macos-arm64 | |
| release: | |
| needs: build | |
| runs-on: ubuntu-latest | |
| if: startsWith(github.ref, 'refs/tags/') | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v6 | |
| with: | |
| fetch-depth: 0 | |
| - name: Generate release notes | |
| id: notes | |
| run: | | |
| CURRENT_TAG="${{ github.ref_name }}" | |
| PREV_TAG=$(git tag --sort=-v:refname | sed -n '2p') | |
| if [ -z "$PREV_TAG" ]; then | |
| RANGE="$CURRENT_TAG" | |
| else | |
| RANGE="${PREV_TAG}..${CURRENT_TAG}" | |
| fi | |
| FEATURES="" | |
| FIXES="" | |
| CHORES="" | |
| CL_FEATURES="" | |
| CL_FIXES="" | |
| CL_CHORES="" | |
| while IFS= read -r line; do | |
| hash=$(echo "$line" | cut -d' ' -f1) | |
| msg=$(echo "$line" | cut -d' ' -f2-) | |
| case "$msg" in | |
| feat:*|feat\(*) | |
| clean=$(echo "$msg" | sed 's/^feat[^:]*: *//') | |
| clean="$(echo "${clean:0:1}" | tr '[:lower:]' '[:upper:]')${clean:1}" | |
| FEATURES="${FEATURES}- \`${hash}\` ${clean}\n" | |
| CL_FEATURES="${CL_FEATURES}- ${clean}\n" | |
| ;; | |
| fix:*|fix\(*) | |
| clean=$(echo "$msg" | sed 's/^fix[^:]*: *//') | |
| clean="$(echo "${clean:0:1}" | tr '[:lower:]' '[:upper:]')${clean:1}" | |
| FIXES="${FIXES}- \`${hash}\` ${clean}\n" | |
| CL_FIXES="${CL_FIXES}- ${clean}\n" | |
| ;; | |
| *) | |
| clean=$(echo "$msg" | sed 's/^[a-z]*[^:]*: *//') | |
| clean="$(echo "${clean:0:1}" | tr '[:lower:]' '[:upper:]')${clean:1}" | |
| CHORES="${CHORES}- \`${hash}\` ${clean}\n" | |
| CL_CHORES="${CL_CHORES}- ${clean}\n" | |
| ;; | |
| esac | |
| done < <(git log "$RANGE" --pretty=format:"%h %s" --reverse) | |
| # Build download table | |
| BASE_URL="https://github.com/EverythingSuckz/Mirroid/releases/download/${CURRENT_TAG}" | |
| DEB_VERSION="${CURRENT_TAG#v}" | |
| DOWNLOADS="## Downloads\n\n" | |
| DOWNLOADS+="### Windows\n" | |
| DOWNLOADS+="| Variant | Download |\n" | |
| DOWNLOADS+="|---------|----------|\n" | |
| DOWNLOADS+="| Installer (recommended) | [mirroid-windows-amd64-setup.exe](${BASE_URL}/mirroid-windows-amd64-setup.exe) |\n" | |
| DOWNLOADS+="| Portable | [mirroid-windows-amd64-portable.zip](${BASE_URL}/mirroid-windows-amd64-portable.zip) |\n\n" | |
| DOWNLOADS+="### Linux\n" | |
| DOWNLOADS+="| Variant | Download |\n" | |
| DOWNLOADS+="|---------|----------|\n" | |
| DOWNLOADS+="| AppImage | [Mirroid-${CURRENT_TAG}-x86_64.AppImage](${BASE_URL}/Mirroid-${CURRENT_TAG}-x86_64.AppImage) |\n" | |
| DOWNLOADS+="| Debian | [mirroid_${DEB_VERSION}_amd64.deb](${BASE_URL}/mirroid_${DEB_VERSION}_amd64.deb) |\n" | |
| DOWNLOADS+="| Tarball | [mirroid-linux-amd64.tar.xz](${BASE_URL}/mirroid-linux-amd64.tar.xz) |\n\n" | |
| DOWNLOADS+="### macOS (Apple Silicon)\n" | |
| DOWNLOADS+="| Variant | Download |\n" | |
| DOWNLOADS+="|---------|----------|\n" | |
| DOWNLOADS+="| DMG (recommended) | [mirroid-macos-arm64.dmg](${BASE_URL}/mirroid-macos-arm64.dmg) |\n" | |
| DOWNLOADS+="| App Bundle | [mirroid-macos-arm64.zip](${BASE_URL}/mirroid-macos-arm64.zip) |\n\n" | |
| DOWNLOADS+="> All artifacts are GPG-signed. Download the corresponding \`.asc\` file to verify.\n\n---\n\n" | |
| BODY="${DOWNLOADS}" | |
| if [ -n "$FEATURES" ] || [ -n "$FIXES" ] || [ -n "$CHORES" ]; then | |
| BODY="${BODY}## Changelog\n\n" | |
| fi | |
| if [ -n "$FEATURES" ]; then | |
| BODY="${BODY}### Features\n${FEATURES}\n" | |
| fi | |
| if [ -n "$FIXES" ]; then | |
| BODY="${BODY}### Bug Fixes\n${FIXES}\n" | |
| fi | |
| if [ -n "$CHORES" ]; then | |
| BODY="${BODY}### Chores\n${CHORES}\n" | |
| fi | |
| # Write clean changelog for in-app updater (no hashes, no download table) | |
| CHANGELOG="" | |
| if [ -n "$CL_FEATURES" ]; then | |
| CHANGELOG="${CHANGELOG}### Features\n${CL_FEATURES}\n" | |
| fi | |
| if [ -n "$CL_FIXES" ]; then | |
| CHANGELOG="${CHANGELOG}### Bug Fixes\n${CL_FIXES}\n" | |
| fi | |
| if [ -n "$CL_CHORES" ]; then | |
| CHANGELOG="${CHANGELOG}### Other Changes\n${CL_CHORES}\n" | |
| fi | |
| if [ -n "$CHANGELOG" ]; then | |
| echo -e "$CHANGELOG" > changelog.txt | |
| else | |
| echo "No changes recorded." > changelog.txt | |
| fi | |
| { | |
| echo "body<<EOF" | |
| echo -e "$BODY" | |
| echo "EOF" | |
| } >> "$GITHUB_OUTPUT" | |
| - name: Download all artifacts | |
| uses: actions/download-artifact@v8 | |
| with: | |
| path: artifacts | |
| merge-multiple: true | |
| - name: Add changelog to artifacts | |
| run: cp changelog.txt artifacts/ | |
| - name: Import GPG key | |
| uses: crazy-max/ghaction-import-gpg@v7 | |
| with: | |
| gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }} | |
| passphrase: ${{ secrets.GPG_PASSPHRASE }} | |
| - name: Sign artifacts | |
| run: | | |
| for file in artifacts/*; do | |
| [ -f "$file" ] || continue | |
| gpg --batch --yes --detach-sign --armor "$file" | |
| done | |
| - name: Create release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| body: ${{ steps.notes.outputs.body }} | |
| files: | | |
| artifacts/* |