|
| 1 | +name: Build & Package |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [ main ] |
| 6 | + tags: [ 'v*' ] |
| 7 | + pull_request: |
| 8 | + |
| 9 | +permissions: |
| 10 | + contents: read |
| 11 | + |
| 12 | +jobs: |
| 13 | + package: |
| 14 | + name: ${{ matrix.display-name }} |
| 15 | + runs-on: ${{ matrix.os }} |
| 16 | + strategy: |
| 17 | + fail-fast: false |
| 18 | + matrix: |
| 19 | + include: |
| 20 | + - display-name: macOS x64 |
| 21 | + os: macos-latest |
| 22 | + script: package:mac:x64 |
| 23 | + arch: x64 |
| 24 | + npm-platform: darwin |
| 25 | + cache-paths: | |
| 26 | + ~/Library/Caches/electron |
| 27 | + ~/Library/Caches/electron-builder |
| 28 | + artifact-name: docforge-macos-x64 |
| 29 | + - display-name: Windows x64 |
| 30 | + os: windows-latest |
| 31 | + script: package:win:x64 |
| 32 | + arch: x64 |
| 33 | + npm-platform: win32 |
| 34 | + cache-paths: | |
| 35 | + ~/AppData/Local/electron/Cache |
| 36 | + ~/AppData/Local/electron-builder/Cache |
| 37 | + artifact-name: docforge-windows-x64 |
| 38 | + - display-name: Windows ia32 |
| 39 | + os: windows-latest |
| 40 | + script: package:win:ia32 |
| 41 | + arch: ia32 |
| 42 | + npm-platform: win32 |
| 43 | + cache-paths: | |
| 44 | + ~/AppData/Local/electron/Cache |
| 45 | + ~/AppData/Local/electron-builder/Cache |
| 46 | + artifact-name: docforge-windows-ia32 |
| 47 | + - display-name: Linux x64 |
| 48 | + os: ubuntu-latest |
| 49 | + script: package:linux:x64 |
| 50 | + arch: x64 |
| 51 | + npm-platform: linux |
| 52 | + cache-paths: | |
| 53 | + ~/.cache/electron |
| 54 | + ~/.cache/electron-builder |
| 55 | + artifact-name: docforge-linux-x64 |
| 56 | + - display-name: Linux armv7l |
| 57 | + os: ubuntu-latest |
| 58 | + script: package:linux:armv7l |
| 59 | + arch: armv7l |
| 60 | + npm-platform: linux |
| 61 | + cache-paths: | |
| 62 | + ~/.cache/electron |
| 63 | + ~/.cache/electron-builder |
| 64 | + artifact-name: docforge-linux-armv7l |
| 65 | + - display-name: Linux arm64 |
| 66 | + os: ubuntu-latest |
| 67 | + script: package:linux:arm64 |
| 68 | + arch: arm64 |
| 69 | + npm-platform: linux |
| 70 | + cache-paths: | |
| 71 | + ~/.cache/electron |
| 72 | + ~/.cache/electron-builder |
| 73 | + artifact-name: docforge-linux-arm64 |
| 74 | + |
| 75 | + defaults: |
| 76 | + run: |
| 77 | + shell: bash |
| 78 | + |
| 79 | + env: |
| 80 | + NODE_OPTIONS: --max_old_space_size=4096 |
| 81 | + |
| 82 | + steps: |
| 83 | + - name: Checkout repository |
| 84 | + uses: actions/checkout@v4 |
| 85 | + with: |
| 86 | + fetch-depth: 0 |
| 87 | + |
| 88 | + - name: Setup Node.js |
| 89 | + uses: actions/setup-node@v4 |
| 90 | + with: |
| 91 | + node-version: 20 |
| 92 | + cache: npm |
| 93 | + cache-dependency-path: package-lock.json |
| 94 | + |
| 95 | + - name: Cache Electron downloads |
| 96 | + uses: actions/cache@v4 |
| 97 | + with: |
| 98 | + path: ${{ matrix.cache-paths }} |
| 99 | + key: ${{ runner.os }}-electron-${{ matrix.arch }}-${{ hashFiles('package-lock.json') }} |
| 100 | + restore-keys: | |
| 101 | + ${{ runner.os }}-electron-${{ matrix.arch }}- |
| 102 | + ${{ runner.os }}-electron- |
| 103 | +
|
| 104 | + - name: Install system dependencies (Linux) |
| 105 | + if: runner.os == 'Linux' |
| 106 | + run: | |
| 107 | + sudo apt-get update |
| 108 | + sudo apt-get install --no-install-recommends -y rpm libarchive-tools libfuse2 |
| 109 | +
|
| 110 | + - name: Install dependencies |
| 111 | + run: npm ci |
| 112 | + env: |
| 113 | + npm_config_arch: ${{ matrix.arch }} |
| 114 | + npm_config_target_arch: ${{ matrix.arch }} |
| 115 | + npm_config_platform: ${{ matrix.npm-platform }} |
| 116 | + |
| 117 | + - name: Prepare native modules |
| 118 | + run: npm run postinstall --if-present |
| 119 | + env: |
| 120 | + npm_config_arch: ${{ matrix.arch }} |
| 121 | + npm_config_target_arch: ${{ matrix.arch }} |
| 122 | + npm_config_platform: ${{ matrix.npm-platform }} |
| 123 | + |
| 124 | + - name: Package application |
| 125 | + run: npm run ${{ matrix.script }} |
| 126 | + env: |
| 127 | + npm_config_arch: ${{ matrix.arch }} |
| 128 | + npm_config_target_arch: ${{ matrix.arch }} |
| 129 | + npm_config_platform: ${{ matrix.npm-platform }} |
| 130 | + |
| 131 | + - name: Upload build artifacts |
| 132 | + if: always() |
| 133 | + uses: actions/upload-artifact@v4 |
| 134 | + with: |
| 135 | + name: ${{ matrix.artifact-name }} |
| 136 | + path: | |
| 137 | + release/** |
| 138 | + !**/*.blockmap |
| 139 | + if-no-files-found: error |
| 140 | + retention-days: 14 |
| 141 | + |
| 142 | + - name: Upload build logs on failure |
| 143 | + if: failure() |
| 144 | + uses: actions/upload-artifact@v4 |
| 145 | + with: |
| 146 | + name: ${{ matrix.artifact-name }}-logs |
| 147 | + path: | |
| 148 | + npm-debug.log |
| 149 | + *.log |
| 150 | + release/**/*.log |
| 151 | + if-no-files-found: ignore |
| 152 | + retention-days: 7 |
0 commit comments