Skip to content

Commit

Permalink
build: fix electron release build process
Browse files Browse the repository at this point in the history
  • Loading branch information
Brooooooklyn committed May 17, 2023
1 parent cb863c4 commit 6a1f20d
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 55 deletions.
5 changes: 2 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -337,12 +337,11 @@ jobs:
shell: bash
run: |
rm -rf apps/electron/node_modules/better-sqlite3/build
yarn workspace @affine/electron rebuild:for-electron
yarn workspace @affine/electron rebuild:for-electron --arch=${{ matrix.spec.arch }}
- name: Run desktop tests
if: ${{ matrix.spec.test && matrix.spec.os == 'ubuntu-latest' }}
run: xvfb-run --auto-servernum --server-args="-screen 0 1280x960x24" -- yarn test
working-directory: apps/electron
run: xvfb-run --auto-servernum --server-args="-screen 0 1280x960x24" -- yarn workspace @affine/electron test
env:
COVERAGE: true

Expand Down
57 changes: 34 additions & 23 deletions .github/workflows/nightly-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,28 +73,36 @@ jobs:
name: before-make-web-static
path: apps/electron/resources/web-static

- name: Upload Artifact (electron dist)
uses: actions/upload-artifact@v3
with:
name: before-make-electron-dist
path: apps/electron/dist

- name: Upload YML Build Script
uses: actions/upload-artifact@v3
with:
name: release-yml-build-script
path: apps/electron/scripts/generate-yml.js

make-distribution:
environment: production
strategy:
# all combinations: macos-latest x64, macos-latest arm64, windows-latest x64, ubuntu-latest x64
matrix:
spec:
- { os: macos-latest, platform: macos, arch: x64 }
- { os: macos-latest, platform: macos, arch: arm64 }
- { os: ubuntu-latest, platform: linux, arch: x64 }
- { os: windows-latest, platform: windows, arch: x64 }
- {
os: macos-latest,
platform: macos,
arch: x64,
target: x86_64-apple-darwin,
}
- {
os: macos-latest,
platform: macos,
arch: arm64,
target: aarch64-apple-darwin,
}
- {
os: ubuntu-latest,
platform: linux,
arch: x64,
target: x86_64-unknown-linux-gnu,
}
- {
os: windows-latest,
platform: windows,
arch: x64,
target: x86_64-pc-windows-msvc,
}
runs-on: ${{ matrix.spec.os }}
needs:
- before-make
Expand All @@ -114,10 +122,14 @@ jobs:
with:
name: before-make-web-static
path: apps/electron/resources/web-static
- uses: actions/download-artifact@v3
with:
name: before-make-electron-dist
path: apps/electron/dist
- name: Rebuild Electron dependences
shell: bash
run: |
rm -rf apps/electron/node_modules/better-sqlite3/build
yarn workspace @affine/electron rebuild:for-electron --arch=${{ matrix.spec.arch }}
- name: Build layers
run: yarn workspace @affine/electron build-layers

- name: Signing By Apple Developer ID
if: ${{ matrix.spec.platform == 'macos' }}
Expand All @@ -127,8 +139,7 @@ jobs:
p12-password: ${{ secrets.CERTIFICATES_P12_PASSWORD }}

- name: make
run: yarn make-${{ matrix.spec.platform }}-${{ matrix.spec.arch }}
working-directory: apps/electron
run: yarn workspace @affine/electron make --platform=${{ matrix.spec.platform }} --arch=${{ matrix.spec.arch }}

- name: Save artifacts (mac)
if: ${{ matrix.spec.platform == 'macos' }}
Expand Down Expand Up @@ -195,7 +206,7 @@ jobs:
node-version: 18
- name: Generate Release yml
run: |
node generate-yml.js
node ./apps/electron/scripts/generate-yml.js
env:
RELEASE_VERSION: ${{ needs.set-build-version.outputs.version }}
- name: Create Release Draft
Expand Down
36 changes: 14 additions & 22 deletions .github/workflows/release-desktop-app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,7 @@ jobs:
- name: Setup Node.js
uses: ./.github/actions/setup-node
- name: generate-assets
working-directory: apps/electron
run: yarn generate-assets
run: yarn workspace @affine/electron generate-assets
env:
NEXT_PUBLIC_FIREBASE_API_KEY: ${{ secrets.NEXT_PUBLIC_FIREBASE_API_KEY }}
NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN: ${{ secrets.NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN }}
Expand All @@ -75,18 +74,6 @@ jobs:
name: before-make-web-static
path: apps/electron/resources/web-static

- name: Upload Artifact (electron dist)
uses: actions/upload-artifact@v3
with:
name: before-make-electron-dist
path: apps/electron/dist

- name: Upload YML Build Script
uses: actions/upload-artifact@v3
with:
name: release-yml-build-script
path: apps/electron/scripts/generate-yml.js

make-distribution:
environment: ${{ github.ref_name == 'master' && 'production' || 'development' }}
strategy:
Expand Down Expand Up @@ -136,10 +123,15 @@ jobs:
with:
name: before-make-web-static
path: apps/electron/resources/web-static
- uses: actions/download-artifact@v3
with:
name: before-make-electron-dist
path: apps/electron/dist

- name: Rebuild Electron dependences
shell: bash
run: |
rm -rf apps/electron/node_modules/better-sqlite3/build
yarn workspace @affine/electron rebuild:for-electron --arch=${{ matrix.spec.arch }}
- name: Build layers
run: yarn workspace @affine/electron build-layers

- name: Signing By Apple Developer ID
if: ${{ matrix.spec.platform == 'macos' }}
Expand All @@ -149,8 +141,7 @@ jobs:
p12-password: ${{ secrets.CERTIFICATES_P12_PASSWORD }}

- name: make
run: yarn make-${{ matrix.spec.platform }}-${{ matrix.spec.arch }}
working-directory: apps/electron
run: yarn workspace @affine/electron make --platform=${{ matrix.spec.platform }} --arch=${{ matrix.spec.arch }}

- name: Save artifacts (mac)
if: ${{ matrix.spec.platform == 'macos' }}
Expand Down Expand Up @@ -213,8 +204,9 @@ jobs:
with:
node-version: 18
- name: Generate Release yml
run: |
RELEASE_VERSION=${{ github.event.inputs.version }} node generate-yml.js
run: node ./apps/electron/scripts/generate-yml.js
env:
RELEASE_VERSION: ${{ github.event.inputs.version }}
- name: Create Release Draft
uses: softprops/action-gh-release@v1
env:
Expand Down
4 changes: 0 additions & 4 deletions apps/electron/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,6 @@
"generate-main-exposed-meta": "zx scripts/generate-main-exposed-meta.mjs",
"package": "electron-forge package",
"make": "electron-forge make",
"make-macos-arm64": "electron-forge make --platform=darwin --arch=arm64",
"make-macos-x64": "electron-forge make --platform=darwin --arch=x64",
"make-windows-x64": "electron-forge make --platform=win32 --arch=x64",
"make-linux-x64": "electron-forge make --platform=linux --arch=x64",
"rebuild:for-unit-test": "yarn rebuild better-sqlite3",
"rebuild:for-electron": "yarn electron-rebuild",
"test": "playwright test"
Expand Down
3 changes: 0 additions & 3 deletions apps/electron/scripts/generate-assets.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,6 @@ if (process.platform === 'win32') {

cd(repoRootDir);

// step 1: build electron resources
await $`yarn workspace @affine/electron build-layers`;

// step 2: build web (nextjs) dist
if (!process.env.SKIP_WEB_BUILD) {
process.env.ENABLE_LEGACY_PROVIDER = 'false';
Expand Down

0 comments on commit 6a1f20d

Please # to comment.