From 7cbc21fd3ea0249a3de7a51534ee86e20c5b927f Mon Sep 17 00:00:00 2001 From: geekgeekrun Date: Sat, 13 Apr 2024 09:22:44 +0800 Subject: [PATCH] try to fix windows build error due to pnpm cannot run by electron builder --- .github/workflows/release-ui.yml | 67 +++++++++++++++++++------------- 1 file changed, 40 insertions(+), 27 deletions(-) diff --git a/.github/workflows/release-ui.yml b/.github/workflows/release-ui.yml index 84bc957..b7b45a0 100644 --- a/.github/workflows/release-ui.yml +++ b/.github/workflows/release-ui.yml @@ -7,36 +7,49 @@ on: - "ui-v*" # Push events to matching v*, i.e. v1.0, v20.15.10 jobs: - # build_on_windows: - # env: - # PUPPETEER_SKIP_DOWNLOAD: 'true' - # runs-on: windows-latest - # permissions: write-all + build_on_windows: + env: + PUPPETEER_SKIP_DOWNLOAD: 'true' + runs-on: windows-latest + permissions: write-all - # # Steps represent a sequence of tasks that will be executed as part of the job - # steps: - # # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it - # - name: Checkout source - # uses: actions/checkout@v2 + # Steps represent a sequence of tasks that will be executed as part of the job + steps: + # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it + - name: Checkout source + uses: actions/checkout@v2 - # - name: Install dependencies - # run: | - # npm i pnpm@^8.6.9 -g - # cd packages/ui - # pnpm i --force + - name: Install dependencies + run: | + npm i pnpm@^8.6.9 -g + cd packages/ui + pnpm i --force + + - name: Patch pnpm + uses: actions/github-script@v3 + with: + GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} + script: | + // https://github.com/pnpm/pnpm/issues/5638 + const path = require('path') + const fs = require('fs') + const pnpmCjsFilePath = path.join(process.env.APPDATA, 'npm/node_modules/pnpm/bin/pnpm.cjs') + let pnpmCjsFileContent = fs.readFileSync(pnpmCjsFilePath).toString() + pnpmCjsFileContent = pnpmCjsFileContent.replace(/^(#!\/usr\/bin\/env node)/, '#!node') + fs.writeFileSync(pnpmCjsFilePath, pnpmCjsFileContent) - # - name: Build - # run: | - # cd packages/ui - # node ./scripts/github-ci-build.mjs + - name: Build + run: | + cd packages/ui + node ./scripts/github-ci-build.mjs - # - name: Upload artifact - # uses: actions/upload-artifact@v4 - # with: - # name: binary-geekgeekrun-ui-windows-${{ github.sha }} - # path: | - # ${{ github.workspace }}/packages/ui/dist/*.exe - # overwrite: true + - name: Upload artifact + uses: actions/upload-artifact@v4 + with: + name: binary-geekgeekrun-ui-windows-${{ github.sha }} + path: | + ${{ github.workspace }}/packages/ui/dist/*.exe + overwrite: true build_on_macos: env: @@ -107,7 +120,7 @@ jobs: needs: - build_on_linux - build_on_macos - # - build_on_windows + - build_on_windows steps: - name: Download artifact