Build Linux + Windows + macOS + Mac ARM #33
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: Build Linux + Windows + macOS + Mac ARM | |
| on: | |
| workflow_dispatch: | |
| jobs: | |
| build-linux: | |
| permissions: write-all | |
| runs-on: ubuntu-latest | |
| env: | |
| ELECTRON_CACHE: ${{ github.workspace }}/.cache/electron | |
| ELECTRON_BUILDER_CACHE: ${{ github.workspace }}/.cache/electron-builder | |
| ADS_URLS: ${{ secrets.ADS_URLS }} | |
| VK_APP_ID: ${{ secrets.VK_APP_ID }} | |
| API_ENDPOINT_URL: ${{ secrets.API_ENDPOINT_URL }} | |
| STATIC_ENDPOINT_URL: ${{ secrets.STATIC_ENDPOINT_URL }} | |
| DISCORD_CLIENT_ID: ${{ secrets.DISCORD_CLIENT_ID }} | |
| EXT_API_SERVER: ${{ secrets.EXT_API_SERVER }} | |
| CACHE_HASHES_URL: ${{ secrets.CACHE_HASHES_URL }} | |
| API_ID: ${{ secrets.API_ID }} | |
| API_HASH: ${{ secrets.API_HASH }} | |
| BOT_TOKEN: ${{ secrets.BOT_TOKEN }} | |
| CACHE_URL: ${{ secrets.CACHE_URL }} | |
| DEFAULT_V1_TV: ${{ secrets.DEFAULT_V1_TV }} | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v3 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v3 | |
| with: | |
| node-version: 14.x | |
| cache: 'yarn' | |
| - name: Install system dependencies | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y \ | |
| build-essential \ | |
| gcc-multilib \ | |
| g++-multilib \ | |
| elfutils \ | |
| software-properties-common \ | |
| flatpak-builder \ | |
| flatpak \ | |
| jq | |
| - name: Setup Flatpak with current runtimes | |
| run: | | |
| sudo flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo | |
| # Install current stable runtimes instead of EOL versions | |
| sudo flatpak install -y \ | |
| org.freedesktop.Platform//24.08 \ | |
| org.freedesktop.Sdk//24.08 \ | |
| org.electronjs.Electron2.BaseApp/x86_64/stable | |
| flatpak remote-add --if-not-exists --user flathub https://flathub.org/repo/flathub.flatpakrepo | |
| git config --global --add protocol.file.allow always | |
| # Only install additional architectures if needed | |
| sudo flatpak install -y \ | |
| org.freedesktop.Platform//24.08 \ | |
| org.freedesktop.Sdk//24.08 \ | |
| org.freedesktop.Platform/aarch64/24.08 \ | |
| org.freedesktop.Platform/x86_64/24.08 \ | |
| org.freedesktop.Sdk/x86_64/24.08 \ | |
| org.electronjs.Electron2.BaseApp/x86_64/stable | |
| - name: Cache Electron and dependencies | |
| uses: actions/cache@v3 | |
| with: | |
| path: | | |
| ${{ env.ELECTRON_CACHE }} | |
| ${{ env.ELECTRON_BUILDER_CACHE }} | |
| ~/.cache/yarn | |
| key: ${{ runner.os }}-node-${{ matrix.node-version }}-electron-${{ hashFiles('yarn.lock') }} | |
| restore-keys: | | |
| ${{ runner.os }}-node-${{ matrix.node-version }}-electron- | |
| - name: Install project dependencies | |
| run: yarn install --ignore-platform --ignore-engines | |
| - name: Build Linux application | |
| run: | | |
| yarn run release:linux | |
| rm release/*.snap | |
| - name: Prepare build application (Snap) | |
| run: | | |
| jq '.build.linux = { | |
| "icon": "build/icons/app/anilibria.icns", | |
| "category": "Video", | |
| "target": [{ | |
| "target": "snap", | |
| "arch": ["x64"] | |
| }] | |
| }' package.json > package.json.tmp && mv package.json.tmp package.json | |
| jq '.name = "anilibrix-plus"' package.json > package.json.tmp && mv package.json.tmp package.json | |
| yarn | |
| - name: Build application (Linux Snap) | |
| run: yarn run release:linux | |
| - name: Zip Linux unpacked folders | |
| run: | | |
| mkdir -p bundle/linux | |
| cp -r release/linux-unpacked bundle/linux/ 2>/dev/null || true | |
| cp -r release/linux-ia32-unpacked bundle/linux/ 2>/dev/null || true | |
| cp -r release/linux-arm64-unpacked bundle/linux/ 2>/dev/null || true | |
| (cd bundle && zip -r ../linux-unpacked.zip linux/) | |
| rm -rf bundle | |
| - name: Upload Linux artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: linux-artifacts | |
| path: | | |
| release/*.rpm | |
| release/*.deb | |
| release/*.snap | |
| release/*.AppImage | |
| release/*.flatpak | |
| linux-unpacked.zip | |
| retention-days: 5 | |
| build-windows: | |
| permissions: write-all | |
| runs-on: ubuntu-latest | |
| needs: build-linux | |
| env: | |
| ELECTRON_CACHE: ${{ github.workspace }}/.cache/electron | |
| ELECTRON_BUILDER_CACHE: ${{ github.workspace }}/.cache/electron-builder | |
| ADS_URLS: ${{ secrets.ADS_URLS }} | |
| VK_APP_ID: ${{ secrets.VK_APP_ID }} | |
| API_ENDPOINT_URL: ${{ secrets.API_ENDPOINT_URL }} | |
| STATIC_ENDPOINT_URL: ${{ secrets.STATIC_ENDPOINT_URL }} | |
| DISCORD_CLIENT_ID: ${{ secrets.DISCORD_CLIENT_ID }} | |
| EXT_API_SERVER: ${{ secrets.EXT_API_SERVER }} | |
| CACHE_HASHES_URL: ${{ secrets.CACHE_HASHES_URL }} | |
| API_ID: ${{ secrets.API_ID }} | |
| API_HASH: ${{ secrets.API_HASH }} | |
| BOT_TOKEN: ${{ secrets.BOT_TOKEN }} | |
| CACHE_URL: ${{ secrets.CACHE_URL }} | |
| DEFAULT_V1_TV: ${{ secrets.DEFAULT_V1_TV }} | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v3 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v3 | |
| with: | |
| node-version: 14.x | |
| cache: 'yarn' | |
| - name: Install Wine and Windows dependencies | |
| run: | | |
| sudo dpkg --add-architecture i386 | |
| sudo mkdir -p /etc/apt/keyrings | |
| sudo wget -O /etc/apt/keyrings/winehq-archive.key https://dl.winehq.org/wine-builds/winehq.key | |
| echo "deb [arch=amd64,i386 signed-by=/etc/apt/keyrings/winehq-archive.key] https://dl.winehq.org/wine-builds/ubuntu/ noble main" | sudo tee /etc/apt/sources.list.d/winehq.list | |
| sudo apt-get update | |
| sudo apt-get install -y winehq-stable | |
| - name: Cache Electron and dependencies | |
| uses: actions/cache@v3 | |
| with: | |
| path: | | |
| ${{ env.ELECTRON_CACHE }} | |
| ${{ env.ELECTRON_BUILDER_CACHE }} | |
| ~/.cache/yarn | |
| key: ${{ runner.os }}-node-${{ matrix.node-version }}-electron-${{ hashFiles('yarn.lock') }} | |
| restore-keys: | | |
| ${{ runner.os }}-node-${{ matrix.node-version }}-electron- | |
| - name: Prepare build application (Windows) | |
| run: | | |
| jq '.name = "anilibrix-plus"' package.json > package.json.tmp && mv package.json.tmp package.json | |
| - name: Install project dependencies | |
| run: yarn install --ignore-platform --ignore-engines | |
| - name: Build Windows application | |
| run: yarn run release:windows | |
| - name: Zip Windows unpacked folders | |
| run: | | |
| mkdir -p bundle/win | |
| cp -r release/win-unpacked bundle/win/ 2>/dev/null || true | |
| cp -r release/win-ia32-unpacked bundle/win/ 2>/dev/null || true | |
| cp -r release/win-arm64-unpacked bundle/win/ 2>/dev/null || true | |
| (cd bundle && zip -r ../win-unpacked.zip win/) | |
| rm -rf bundle | |
| - name: Upload Windows artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: windows-artifacts | |
| path: | | |
| release/*.exe | |
| win-unpacked.zip | |
| retention-days: 5 | |
| build-macos: | |
| permissions: write-all | |
| runs-on: macos-14 | |
| needs: [] | |
| env: | |
| ELECTRON_CACHE: ${{ github.workspace }}/.cache/electron | |
| ELECTRON_BUILDER_CACHE: ${{ github.workspace }}/.cache/electron-builder | |
| ADS_URLS: ${{ secrets.ADS_URLS }} | |
| VK_APP_ID: ${{ secrets.VK_APP_ID }} | |
| SENTRY_DSN: ${{ secrets.SENTRY_DSN }} | |
| API_ENDPOINT_URL: ${{ secrets.API_ENDPOINT_URL }} | |
| YANDEX_TRACKING_ID: ${{ secrets.YANDEX_TRACKING_ID }} | |
| STATIC_ENDPOINT_URL: ${{ secrets.STATIC_ENDPOINT_URL }} | |
| DISCORD_CLIENT_ID: ${{ secrets.DISCORD_CLIENT_ID }} | |
| EXT_API_SERVER: ${{ secrets.EXT_API_SERVER }} | |
| CACHE_HASHES_URL: ${{ secrets.CACHE_HASHES_URL }} | |
| PYTHON: python3.10 | |
| NODE_GYP_FORCE_PYTHON: python3.10 | |
| OPERA_PROXY_RELEASE_URL: https://github.com/Snawoot/opera-proxy/releases/download/v1.3.1 | |
| steps: | |
| - name: Check out Git repository | |
| uses: actions/checkout@v4 | |
| - name: Enable Rosetta 2 emulation | |
| run: | | |
| softwareupdate --install-rosetta --agree-to-license | |
| echo "RUNNER_ARCH=$(uname -m)" >> $GITHUB_ENV | |
| - name: Setup Node.js 14.x (x64 via Rosetta) | |
| uses: actions/setup-node@v3 | |
| with: | |
| node-version: '14.x' | |
| architecture: x64 | |
| check-latest: true | |
| - name: Verify Node.js architecture | |
| run: | | |
| echo "Node.js version: $(node -v)" | |
| echo "Node.js architecture: $(node -p "process.arch")" | |
| echo "System architecture: $(uname -m)" | |
| - name: Get yarn cache | |
| id: yarn-cache | |
| run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT | |
| - name: Cache Node.js modules | |
| uses: actions/cache@v3 | |
| with: | |
| path: ${{ steps.yarn-cache.outputs.dir }} | |
| key: ${{ runner.os }}-node14-x64-yarn-${{ hashFiles('yarn.lock') }} | |
| restore-keys: | | |
| ${{ runner.os }}-node14-x64-yarn- | |
| - name: Cache Electron | |
| uses: actions/cache@v3 | |
| with: | |
| path: ${{ github.workspace }}/.cache/electron | |
| key: ${{ runner.os }}-node14-x64-electron-cache-${{ hashFiles('yarn.lock') }} | |
| restore-keys: | | |
| ${{ runner.os }}-node14-x64-electron-cache- | |
| - name: Cache Electron-Builder | |
| uses: actions/cache@v3 | |
| with: | |
| path: ${{ github.workspace }}/.cache/electron-builder | |
| key: ${{ runner.os }}-node14-x64-electron-builder-cache-${{ hashFiles('yarn.lock') }} | |
| restore-keys: | | |
| ${{ runner.os }}-node14-x64-electron-builder-cache- | |
| - name: Install Python 3.10 | |
| run: | | |
| brew install python@3.10 | |
| echo "$(brew --prefix python@3.10)/bin" >> $GITHUB_PATH | |
| - name: Install dependencies | |
| run: yarn --ignore-platform --ignore-engines | |
| - name: Download opera proxy | |
| run: yarn run proxies-download | |
| - name: Run build | |
| run: npm run release:mac | |
| - name: Zip macOS unpacked folders | |
| run: | | |
| mkdir -p bundle/macos | |
| # Copy macOS unpacked directories if they exist | |
| cp -r release/mac-unpacked bundle/macos/ 2>/dev/null || true | |
| cp -r release/mac-arm64-unpacked bundle/macos/ 2>/dev/null || true | |
| cp -r release/mac-universal-unpacked bundle/macos/ 2>/dev/null || true | |
| (cd bundle && zip -r ../macos-unpacked.zip macos/) | |
| rm -rf bundle | |
| - name: Upload macOS artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: macos-artifacts | |
| path: | | |
| release/*.dmg | |
| release/*.zip | |
| release/*.pkg | |
| macos-unpacked.zip | |
| if-no-files-found: error | |
| retention-days: 5 | |
| create-release: | |
| permissions: write-all | |
| runs-on: ubuntu-latest | |
| needs: [build-linux, build-windows, build-macos] | |
| if: always() | |
| steps: | |
| - name: Download all artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| path: artifacts/ | |
| - name: List downloaded artifacts | |
| run: find artifacts/ -type f | |
| - name: Create Release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| draft: true | |
| files: | | |
| artifacts/linux-artifacts/** | |
| artifacts/windows-artifacts/** | |
| artifacts/macos-artifacts/** |