From 3542eec2778ac726d8ea04fde16e8c524ef242cb Mon Sep 17 00:00:00 2001 From: Huakun Shen Date: Thu, 3 Apr 2025 16:46:40 -0400 Subject: [PATCH] feat: add GitHub Actions workflow for desktop test builds --- .github/workflows/test-build.yml | 121 +++++++++++++++++++++++++++++++ 1 file changed, 121 insertions(+) create mode 100644 .github/workflows/test-build.yml diff --git a/.github/workflows/test-build.yml b/.github/workflows/test-build.yml new file mode 100644 index 0000000..cb8931a --- /dev/null +++ b/.github/workflows/test-build.yml @@ -0,0 +1,121 @@ +name: "Desktop Test build" + +on: + push: + branches: + - "test-build" + tags: + - "v*" + workflow_dispatch: + +jobs: + publish-tauri: + permissions: + contents: write + strategy: + fail-fast: false + matrix: + settings: + - platform: "macos-14" # for Arm based macs (M1 and above). + args: "--target aarch64-apple-darwin --verbose --config src-tauri/tauri.conf.publish.json" + - platform: "macos-13" # for Intel based macs. + args: "--target x86_64-apple-darwin --verbose --config src-tauri/tauri.conf.publish.json" + # Universal Build no longer supported after adding openssl, which is not cross-compilable. + - platform: "macos-14" # for Both Arm and Intel based macs. + args: "--target universal-apple-darwin --verbose --config src-tauri/tauri.conf.publish.json" + - platform: "ubuntu-22.04" # for Tauri v1 you could replace this with ubuntu-20.04. + args: "--verbose --config src-tauri/tauri.conf.publish.json" + - platform: "windows-latest" + args: "--verbose --config src-tauri/tauri.conf.publish.json" + + runs-on: ${{ matrix.settings.platform }} + steps: + - uses: actions/checkout@v4 + with: + submodules: "true" + + - name: Install Dependencies (ubuntu only) + if: matrix.settings.platform == 'ubuntu-22.04' # This must match the platform value defined above. + run: | + sudo apt-get update + sudo apt-get install -y libwebkit2gtk-4.1-dev libappindicator3-dev librsvg2-dev patchelf libxdo-dev + # You can remove the one that doesn't apply to your app to speed up the workflow a bit. + - name: Install protobuf (Mac) + if: startsWith(matrix.settings.platform, 'macos') + run: | + brew install protobuf + brew install openssl + - name: Install Protobuf (Ubuntu) + if: matrix.settings.platform == 'ubuntu-22.04' + run: | + sudo apt install -y protobuf-compiler + - uses: pnpm/action-setup@v4 + - name: Setup Node + uses: actions/setup-node@v4 + with: + node-version: lts/* + cache: "pnpm" # Set this to npm, yarn or pnpm. + cache-dependency-path: ./pnpm-lock.yaml + - name: Install protoc and openssl for windows + if: matrix.settings.platform == 'windows-latest' + run: | + choco install protoc + choco install openssl + echo OPENSSL_DIR='C:\Program Files\OpenSSL' >> $env:GITHUB_ENV + echo OPENSSL_INCLUDE_DIR='C:\Program Files\OpenSSL\include' >> $env:GITHUB_ENV + echo OPENSSL_LIB_DIR='C:\Program Files\OpenSSL\lib\VC\x64\MDd' >> $env:GITHUB_ENV + + - name: Install Rust stable + uses: dtolnay/rust-toolchain@stable + with: + # Those targets are only used on macos runners so it's in an `if` to slightly speed up windows and linux builds. + targets: ${{ matrix.settings.platform == 'macos-14' && 'aarch64-apple-darwin,x86_64-apple-darwin' || '' }} + - name: Add rust target (macos only) + if: matrix.settings.platform == 'macos-14' + run: | + rustup target add aarch64-apple-darwin + rustup target add x86_64-apple-darwin + - name: Rust Cache + uses: swatinem/rust-cache@v2 + with: + workspaces: ". -> target" + - uses: oven-sh/setup-bun@v1 + with: + bun-version: latest + - name: Install Dependencies + run: pnpm install + - name: Environment Check + run: | + # pnpm --filter=@kksh/ci run ci-env-check + bun packages/ci/scripts/ci-env-check.ts + - name: Build Packages + env: + NODE_OPTIONS: --max-old-space-size=4096 + run: pnpm build + - name: Get App Version + if: matrix.settings.platform == 'windows-latest' + id: appversion + run: | + echo "version=$(node -p "require('./apps/desktop/package.json').version")" >> $env:GITHUB_OUTPUT + - uses: tauri-apps/tauri-action@v0 + env: + CI: false + KUNKUN_PUBLISH: true + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + NODE_OPTIONS: --max-old-space-size=4096 + APPLE_CERTIFICATE: ${{ secrets.APPLE_CERTIFICATE }} + APPLE_CERTIFICATE_PASSWORD: ${{ secrets.APPLE_CERTIFICATE_PASSWORD }} + APPLE_SIGNING_IDENTITY: ${{ secrets.APPLE_SIGNING_IDENTITY }} + APPLE_ID: ${{ secrets.APPLE_ID }} + APPLE_PASSWORD: ${{ secrets.APPLE_PASSWORD }} + APPLE_TEAM_ID: ${{ secrets.APPLE_TEAM_ID }} + TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY }} + TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY_PASSWORD }} + with: + tagName: Kunkun-v__VERSION__ # the action automatically replaces \_\_VERSION\_\_ with the app version. + releaseName: "Kunkun v__VERSION__" + releaseBody: "See the assets to download this version and install." + releaseDraft: false + prerelease: false + args: ${{ matrix.settings.args }} ${{ contains(steps.appversion.outputs.version, 'beta') && matrix.settings.platform == 'windows-latest' && '-b nsis' || '' }} + projectPath: "./apps/desktop"