๐จ ๅ่ฝไผๅๅๆฐๆฎๅบ็ปๆๆน่ฟ #126
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: "๐ DeeChat Build & Release" | |
| on: | |
| push: | |
| branches: [main, develop] | |
| tags: ["v*"] | |
| pull_request: | |
| branches: [main] | |
| jobs: | |
| # ---------- macOS (x64 / Intel) ---------- | |
| build-macos-x64: | |
| name: Build macOS x64 | |
| runs-on: macos-13 | |
| if: startsWith(github.ref, 'refs/tags/v') || github.event_name == 'pull_request' || github.ref == 'refs/heads/develop' | |
| steps: | |
| - name: ๐ฅ Checkout code | |
| uses: actions/checkout@v4 | |
| - name: ๐ข Setup Node.js 22 | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: "22" | |
| cache: "npm" | |
| cache-dependency-path: | | |
| package-lock.json | |
| app/package-lock.json | |
| app/renderer/package-lock.json | |
| - name: ๐ฆ Install dependencies (workspace) | |
| run: | | |
| npm ci --prefer-offline | |
| cd app && npm ci --prefer-offline | |
| cd renderer && npm ci --prefer-offline | |
| - name: ๐ฆ Install node-abi for ABI checking | |
| run: npm install -g node-abi | |
| - name: ๐ Print Electron ABI | |
| run: node -e "console.log('Electron 30 | abi=' + require('node-abi').getAbi('30.0.0','electron'))" | |
| - name: ๐ง Rebuild native modules for Electron x64 | |
| working-directory: app | |
| env: | |
| npm_config_runtime: electron | |
| npm_config_target: 30.0.0 | |
| npm_config_disturl: https://electronjs.org/headers | |
| npm_config_arch: x64 | |
| run: npx electron-rebuild -f -w lmdb --arch=x64 | |
| - name: ๐๏ธ Build application | |
| run: npm run build | |
| - name: ๐ Import Code-Signing Certificates | |
| if: startsWith(github.ref, 'refs/tags/v') | |
| env: | |
| APPLE_CERTIFICATE: ${{ secrets.APPLE_CERTIFICATE }} | |
| APPLE_CERTIFICATE_PASSWORD: ${{ secrets.APPLE_CERTIFICATE_PASSWORD }} | |
| run: | | |
| if [ -n "$APPLE_CERTIFICATE" ]; then | |
| echo "$APPLE_CERTIFICATE" | base64 --decode > certificate.p12 | |
| security create-keychain -p "" build.keychain | |
| security import certificate.p12 -k ~/Library/Keychains/build.keychain -P "$APPLE_CERTIFICATE_PASSWORD" -T /usr/bin/codesign | |
| security list-keychains -s ~/Library/Keychains/build.keychain | |
| security default-keychain -s ~/Library/Keychains/build.keychain | |
| security unlock-keychain -p "" ~/Library/Keychains/build.keychain | |
| security set-key-partition-list -S apple-tool:,apple: -s -k "" ~/Library/Keychains/build.keychain | |
| fi | |
| - name: ๐ฑ Build macOS x64 app | |
| working-directory: app | |
| env: | |
| CSC_IDENTITY_AUTO_DISCOVERY: ${{ startsWith(github.ref, 'refs/tags/v') && 'true' || 'false' }} | |
| APPLE_ID: ${{ secrets.APPLE_ID }} | |
| APPLE_ID_PASSWORD: ${{ secrets.APPLE_ID_PASSWORD }} | |
| APPLE_TEAM_ID: ${{ secrets.APPLE_TEAM_ID }} | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: npx electron-builder --mac --x64 --publish=never | |
| - name: ๐ค Upload macOS x64 artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: macos-x64-build | |
| path: | | |
| app/release/*.dmg | |
| app/release/*.zip | |
| app/release/latest-mac.yml | |
| retention-days: 30 | |
| # ---------- macOS (arm64 / Apple Silicon) ---------- | |
| build-macos-arm64: | |
| name: Build macOS arm64 | |
| runs-on: macos-14 | |
| if: startsWith(github.ref, 'refs/tags/v') || github.event_name == 'pull_request' || github.ref == 'refs/heads/develop' | |
| steps: | |
| - name: ๐ฅ Checkout code | |
| uses: actions/checkout@v4 | |
| - name: ๐ข Setup Node.js 22 | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: "22" | |
| cache: "npm" | |
| cache-dependency-path: | | |
| package-lock.json | |
| app/package-lock.json | |
| app/renderer/package-lock.json | |
| - name: ๐ฆ Install dependencies (workspace) | |
| run: | | |
| npm ci --prefer-offline | |
| cd app && npm ci --prefer-offline | |
| cd renderer && npm ci --prefer-offline | |
| - name: ๐ฆ Install node-abi for ABI checking | |
| run: npm install -g node-abi | |
| - name: ๐ Print Electron ABI | |
| run: node -e "console.log('Electron 30 | abi=' + require('node-abi').getAbi('30.0.0','electron'))" | |
| - name: ๐ง Rebuild native modules for Electron arm64 | |
| working-directory: app | |
| env: | |
| npm_config_runtime: electron | |
| npm_config_target: 30.0.0 | |
| npm_config_disturl: https://electronjs.org/headers | |
| npm_config_arch: arm64 | |
| run: npx electron-rebuild -f -w lmdb --arch=arm64 | |
| - name: ๐๏ธ Build application | |
| run: npm run build | |
| - name: ๐ Import Code-Signing Certificates | |
| if: startsWith(github.ref, 'refs/tags/v') | |
| env: | |
| APPLE_CERTIFICATE: ${{ secrets.APPLE_CERTIFICATE }} | |
| APPLE_CERTIFICATE_PASSWORD: ${{ secrets.APPLE_CERTIFICATE_PASSWORD }} | |
| run: | | |
| if [ -n "$APPLE_CERTIFICATE" ]; then | |
| echo "$APPLE_CERTIFICATE" | base64 --decode > certificate.p12 | |
| security create-keychain -p "" build.keychain | |
| security import certificate.p12 -k ~/Library/Keychains/build.keychain -P "$APPLE_CERTIFICATE_PASSWORD" -T /usr/bin/codesign | |
| security list-keychains -s ~/Library/Keychains/build.keychain | |
| security default-keychain -s ~/Library/Keychains/build.keychain | |
| security unlock-keychain -p "" ~/Library/Keychains/build.keychain | |
| security set-key-partition-list -S apple-tool:,apple: -s -k "" ~/Library/Keychains/build.keychain | |
| fi | |
| - name: ๐ฑ Build macOS arm64 app | |
| working-directory: app | |
| env: | |
| CSC_IDENTITY_AUTO_DISCOVERY: ${{ startsWith(github.ref, 'refs/tags/v') && 'true' || 'false' }} | |
| APPLE_ID: ${{ secrets.APPLE_ID }} | |
| APPLE_ID_PASSWORD: ${{ secrets.APPLE_ID_PASSWORD }} | |
| APPLE_TEAM_ID: ${{ secrets.APPLE_TEAM_ID }} | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: npx electron-builder --mac --arm64 --publish=never | |
| - name: ๐ค Upload macOS arm64 artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: macos-arm64-build | |
| path: | | |
| app/release/*.dmg | |
| app/release/*.zip | |
| app/release/latest-mac.yml | |
| retention-days: 30 | |
| # ---------- Windows (x64 only) ---------- | |
| build-windows: | |
| name: Build Windows x64 | |
| runs-on: windows-latest | |
| if: startsWith(github.ref, 'refs/tags/v') || github.event_name == 'pull_request' || github.ref == 'refs/heads/develop' | |
| steps: | |
| - name: ๐ฅ Checkout code | |
| uses: actions/checkout@v4 | |
| - name: ๐ข Setup Node.js 22 | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: "22" | |
| cache: "npm" | |
| cache-dependency-path: | | |
| package-lock.json | |
| app/package-lock.json | |
| app/renderer/package-lock.json | |
| - name: ๐ Setup Python 3.12 | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.12" | |
| - name: ๐ง Force x64 + Electron headers for node-gyp | |
| shell: bash | |
| run: | | |
| echo "GYP_MSVS_VERSION=2022" >> $GITHUB_ENV | |
| echo "npm_config_arch=x64" >> $GITHUB_ENV | |
| echo "npm_config_target_arch=x64" >> $GITHUB_ENV | |
| echo "npm_config_runtime=electron" >> $GITHUB_ENV | |
| echo "npm_config_target=30.0.0" >> $GITHUB_ENV | |
| echo "npm_config_disturl=https://electronjs.org/headers" >> $GITHUB_ENV | |
| echo "npm_config_build_from_source=false" >> $GITHUB_ENV | |
| - name: ๐ฆ Install dependencies (workspace) | |
| run: | | |
| npm ci --prefer-offline | |
| cd app && npm ci --prefer-offline | |
| cd renderer && npm ci --prefer-offline | |
| - name: ๐ฆ Install node-abi for ABI checking | |
| run: npm install -g node-abi | |
| - name: ๐ Print Electron ABI | |
| run: node -e "console.log('Electron 30 | abi=' + require('node-abi').getAbi('30.0.0','electron'))" | |
| - name: ๐ฉน Patch lmdb to disable V8 API (root & app) | |
| shell: pwsh | |
| run: | | |
| function Patch-Lmdb { | |
| param([string]$basePath) | |
| $gypFile = Join-Path $basePath "node_modules/lmdb/binding.gyp" | |
| $gypiFile = Join-Path $basePath "node_modules/lmdb/binding.gypi" | |
| if (Test-Path $gypFile) { | |
| Write-Host "๐ Patching $gypFile ..." | |
| $content = Get-Content $gypFile -Raw | |
| $content = $content -replace '"ENABLE_V8_API=1"', '"ENABLE_V8_API=0"' | |
| $content = $content -replace "'ENABLE_V8_API=1'", "'ENABLE_V8_API=0'" | |
| Set-Content $gypFile -Value $content | |
| Write-Host "โ V8 API disabled in $gypFile" | |
| } | |
| if (Test-Path $gypiFile) { | |
| Write-Host "๐ Patching $gypiFile ..." | |
| $content = Get-Content $gypiFile -Raw | |
| $content = $content -replace '"ENABLE_V8_API=1"', '"ENABLE_V8_API=0"' | |
| $content = $content -replace "'ENABLE_V8_API=1'", "'ENABLE_V8_API=0'" | |
| Set-Content $gypiFile -Value $content | |
| Write-Host "โ V8 API disabled in $gypiFile" | |
| } | |
| } | |
| Write-Host "๐ Patching LMDB in root directory..." | |
| Patch-Lmdb -basePath $PWD | |
| Write-Host "๐ Patching LMDB in app directory..." | |
| Patch-Lmdb -basePath (Join-Path $PWD "app") | |
| - name: ๐ง Rebuild native modules for Electron (Windows x64) | |
| working-directory: app | |
| env: | |
| GYP_DEFINES: ENABLE_V8_API=0 | |
| run: npx electron-rebuild -f -a x64 -w lmdb | |
| - name: ๐๏ธ Build application | |
| run: npm run build | |
| - name: ๐ฑ Build Windows x64 app | |
| working-directory: app | |
| env: | |
| CSC_LINK: ${{ secrets.WIN_CSC_LINK }} | |
| CSC_KEY_PASSWORD: ${{ secrets.WIN_CSC_KEY_PASSWORD }} | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: npx electron-builder --win --x64 --publish=never | |
| - name: ๐ค Upload Windows x64 artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: windows-build | |
| path: | | |
| app/release/*.exe | |
| app/release/latest.yml | |
| retention-days: 30 | |
| # ---------- Linux (x64) ---------- | |
| build-linux: | |
| name: Build Linux | |
| runs-on: ubuntu-latest | |
| if: startsWith(github.ref, 'refs/tags/v') || github.event_name == 'pull_request' || github.ref == 'refs/heads/develop' | |
| steps: | |
| - name: ๐ฅ Checkout code | |
| uses: actions/checkout@v4 | |
| - name: ๐ข Setup Node.js 22 | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: "22" | |
| cache: "npm" | |
| cache-dependency-path: | | |
| package-lock.json | |
| app/package-lock.json | |
| app/renderer/package-lock.json | |
| - name: ๐ง Install Linux build deps | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y \ | |
| libnss3-dev libatk-bridge2.0-dev libdrm-dev libxkbcommon-dev \ | |
| libxss1 libasound2-dev libgtk-3-dev | |
| - name: ๐ฆ Install dependencies (workspace) | |
| run: | | |
| npm ci --prefer-offline | |
| cd app && npm ci --prefer-offline | |
| cd renderer && npm ci --prefer-offline | |
| - name: ๐ฆ Install node-abi for ABI checking | |
| run: npm install -g node-abi | |
| - name: ๐ Print Electron ABI | |
| run: node -e "console.log('Electron 30 | abi=' + require('node-abi').getAbi('30.0.0','electron'))" | |
| - name: ๐ง Rebuild native modules for Electron Linux (x64) | |
| working-directory: app | |
| env: | |
| npm_config_runtime: electron | |
| npm_config_target: 30.0.0 | |
| npm_config_disturl: https://electronjs.org/headers | |
| npm_config_arch: x64 | |
| run: npx electron-rebuild -f -w lmdb --arch=x64 | |
| - name: ๐๏ธ Build application | |
| run: npm run build | |
| - name: ๐ฑ Build Linux app | |
| working-directory: app | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: npx electron-builder --linux --x64 --publish=never | |
| - name: ๐ค Upload Linux artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: linux-build | |
| path: | | |
| app/release/*.AppImage | |
| app/release/*.deb | |
| app/release/*.rpm | |
| app/release/latest-linux.yml | |
| retention-days: 30 | |
| # ---------- Release (only on tag) ---------- | |
| release: | |
| name: "๐ Create Release" | |
| needs: | |
| - build-macos-x64 | |
| - build-macos-arm64 | |
| - build-windows | |
| - build-linux | |
| runs-on: ubuntu-latest | |
| if: startsWith(github.ref, 'refs/tags/v') | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: ๐ฅ Download all artifacts | |
| uses: actions/download-artifact@v4 | |
| - name: ๐ Create Release | |
| uses: softprops/action-gh-release@v1 | |
| with: | |
| name: Release ${{ github.ref_name }} | |
| files: | | |
| macos-x64-build/DeeChat-mac-x64.dmg | |
| macos-x64-build/DeeChat-mac-x64.zip | |
| macos-arm64-build/DeeChat-mac-arm64.dmg | |
| macos-arm64-build/DeeChat-mac-arm64.zip | |
| macos-x64-build/latest-mac.yml | |
| windows-build/DeeChat-win-x64.exe | |
| windows-build/latest.yml | |
| linux-build/DeeChat-linux-x64.AppImage | |
| linux-build/DeeChat-linux-x64.deb | |
| linux-build/DeeChat-linux-x64.rpm | |
| linux-build/latest-linux.yml | |
| generate_release_notes: true | |
| draft: false | |
| prerelease: false | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |