mirror of
https://github.com/open-webui/computer-desktop.git
synced 2026-11-27 17:59:18 -05:00
refac
This commit is contained in:
1 parent
aa071d173e
commit
e11a140768
39 files changed
+11539
No files matched your search
@@ -0,0 +1,385 @@
|
||||
name: Build and Release Electron App (electron-builder)
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- release
|
||||
|
||||
jobs:
|
||||
compile:
|
||||
name: Compile (Typecheck + Vite Build)
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout Repository
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Setup Node.js
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 22
|
||||
cache: 'npm'
|
||||
|
||||
- name: Install Dependencies
|
||||
run: npm ci
|
||||
|
||||
- name: Typecheck and Build
|
||||
run: npm run build
|
||||
|
||||
- name: Upload Compiled Output
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: compiled-output
|
||||
path: out/
|
||||
retention-days: 1
|
||||
|
||||
package:
|
||||
name: Package (${{ matrix.os }}-${{ matrix.arch }})
|
||||
needs: compile
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- os: ubuntu-latest
|
||||
arch: x64
|
||||
- os: ubuntu-24.04-arm
|
||||
arch: arm64
|
||||
- os: windows-latest
|
||||
arch: x64
|
||||
- os: windows-11-arm
|
||||
arch: arm64
|
||||
- os: macos-latest
|
||||
arch: x64
|
||||
- os: macos-latest
|
||||
arch: arm64
|
||||
steps:
|
||||
- name: Checkout Repository
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Setup Node.js
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 22
|
||||
cache: 'npm'
|
||||
|
||||
- name: Install Dependencies
|
||||
run: npm ci
|
||||
|
||||
- name: Download Compiled Output
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: compiled-output
|
||||
path: out/
|
||||
|
||||
# ── Apple codesigning (macOS only) ──
|
||||
- name: Install Apple codesigning certificate
|
||||
id: apple_cert
|
||||
if: matrix.os == 'macos-latest'
|
||||
continue-on-error: true
|
||||
env:
|
||||
BUILD_CERTIFICATE_BASE64: ${{ secrets.BUILD_CERTIFICATE_BASE64 }}
|
||||
P12_PASSWORD: ${{ secrets.P12_PASSWORD }}
|
||||
KEYCHAIN_PASSWORD: ${{ secrets.KEYCHAIN_PASSWORD }}
|
||||
run: |
|
||||
if [ -z "$BUILD_CERTIFICATE_BASE64" ]; then
|
||||
echo "No certificate provided, will build unsigned"
|
||||
exit 1
|
||||
fi
|
||||
CERTIFICATE_PATH=$RUNNER_TEMP/build_certificate.p12
|
||||
KEYCHAIN_PATH=$RUNNER_TEMP/app-signing.keychain-db
|
||||
echo -n "$BUILD_CERTIFICATE_BASE64" | base64 --decode > $CERTIFICATE_PATH
|
||||
security create-keychain -p "$KEYCHAIN_PASSWORD" $KEYCHAIN_PATH
|
||||
security set-keychain-settings -lut 21600 $KEYCHAIN_PATH
|
||||
security unlock-keychain -p "$KEYCHAIN_PASSWORD" $KEYCHAIN_PATH
|
||||
security import $CERTIFICATE_PATH -P "$P12_PASSWORD" -A -t cert -f pkcs12 -k $KEYCHAIN_PATH
|
||||
security set-key-partition-list -S apple-tool:,apple:,codesign: -s -k "$KEYCHAIN_PASSWORD" $KEYCHAIN_PATH
|
||||
security list-keychain -d user -s $KEYCHAIN_PATH
|
||||
|
||||
# ── Platform packaging ──
|
||||
- name: Package for Windows
|
||||
id: win_build
|
||||
if: runner.os == 'Windows'
|
||||
continue-on-error: true
|
||||
run: npx electron-builder --win --${{ matrix.arch }} --publish never
|
||||
|
||||
- name: Package for Windows (unsigned fallback)
|
||||
if: runner.os == 'Windows' && steps.win_build.outcome == 'failure'
|
||||
env:
|
||||
WIN_CSC_LINK: ''
|
||||
CSC_IDENTITY_AUTO_DISCOVERY: 'false'
|
||||
run: |
|
||||
rm -rf dist/
|
||||
npx electron-builder --win --${{ matrix.arch }} --publish never
|
||||
|
||||
- name: Package for macOS (signed + notarized)
|
||||
id: mac_build
|
||||
if: matrix.os == 'macos-latest' && steps.apple_cert.outcome == 'success'
|
||||
continue-on-error: true
|
||||
env:
|
||||
CSC_LINK: ${{ secrets.BUILD_CERTIFICATE_BASE64 }}
|
||||
CSC_KEY_PASSWORD: ${{ secrets.P12_PASSWORD }}
|
||||
APPLE_ID: ${{ secrets.APPLE_ID }}
|
||||
APPLE_APP_SPECIFIC_PASSWORD: ${{ secrets.APPLE_PASSWORD }}
|
||||
APPLE_TEAM_ID: ${{ secrets.APPLE_TEAM_ID }}
|
||||
run: npx electron-builder --mac --${{ matrix.arch }} -c.mac.notarize=true --publish never
|
||||
|
||||
- name: Package for macOS (unsigned fallback)
|
||||
if: matrix.os == 'macos-latest' && (steps.apple_cert.outcome != 'success' || steps.mac_build.outcome == 'failure')
|
||||
env:
|
||||
CSC_IDENTITY_AUTO_DISCOVERY: 'false'
|
||||
run: |
|
||||
rm -rf dist/
|
||||
npx electron-builder --mac --${{ matrix.arch }} --publish never
|
||||
|
||||
- name: Package for Linux
|
||||
if: runner.os == 'Linux'
|
||||
run: |
|
||||
npx electron-builder --linux AppImage deb snap --${{ matrix.arch }} --publish never
|
||||
|
||||
# ── Windows code signing ──
|
||||
- name: Azure Trusted Signing (Windows Only)
|
||||
if: runner.os == 'Windows'
|
||||
continue-on-error: true
|
||||
uses: azure/trusted-signing-action@v0.5.1
|
||||
with:
|
||||
azure-tenant-id: ${{ secrets.AZURE_TENANT_ID }}
|
||||
azure-client-id: ${{ secrets.AZURE_CLIENT_ID }}
|
||||
azure-client-secret: ${{ secrets.AZURE_CLIENT_SECRET }}
|
||||
endpoint: https://eus.codesigning.azure.net/
|
||||
trusted-signing-account-name: open-webui
|
||||
certificate-profile-name: open-webui
|
||||
files-folder: dist
|
||||
files-folder-filter: exe
|
||||
|
||||
# ── Upload release artifacts ──
|
||||
- name: Upload Artifacts
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: ${{ matrix.os }}-${{ matrix.arch }}
|
||||
path: |
|
||||
dist/*.exe
|
||||
dist/*.dmg
|
||||
dist/*.zip
|
||||
dist/*.pkg
|
||||
dist/*.deb
|
||||
dist/*.AppImage
|
||||
dist/*.snap
|
||||
dist/*.tar.gz
|
||||
dist/*.blockmap
|
||||
dist/latest*.yml
|
||||
if-no-files-found: warn
|
||||
|
||||
release:
|
||||
name: Create GitHub Release
|
||||
needs: package
|
||||
if: >-
|
||||
github.event_name == 'push' &&
|
||||
github.ref == 'refs/heads/release' &&
|
||||
!cancelled() &&
|
||||
needs.package.result != 'failure'
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: write
|
||||
steps:
|
||||
- name: Checkout Repository
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
sparse-checkout: |
|
||||
package.json
|
||||
CHANGELOG.md
|
||||
sparse-checkout-cone-mode: false
|
||||
|
||||
- name: Get version from package.json
|
||||
id: version
|
||||
run: |
|
||||
VERSION=$(node -p "require('./package.json').version")
|
||||
echo "version=$VERSION" >> $GITHUB_OUTPUT
|
||||
echo "Release version: $VERSION"
|
||||
|
||||
- name: Extract changelog for this version
|
||||
id: changelog
|
||||
run: |
|
||||
VERSION="${{ steps.version.outputs.version }}"
|
||||
NOTES=$(awk "/^## \[$VERSION\]/{found=1; next} /^## \[/{if(found) exit} found{print}" CHANGELOG.md)
|
||||
if [ -z "$NOTES" ]; then
|
||||
NOTES="Release v$VERSION"
|
||||
fi
|
||||
echo "$NOTES" > /tmp/release_notes.md
|
||||
echo "Changelog notes:"
|
||||
cat /tmp/release_notes.md
|
||||
|
||||
- name: Download Artifacts
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
pattern: '*-*'
|
||||
merge-multiple: false
|
||||
|
||||
- name: Install js-yaml for manifest merging
|
||||
run: npm install --no-save js-yaml
|
||||
|
||||
- name: Merge macOS latest-mac.yml (x64 + arm64)
|
||||
run: |
|
||||
X64_YML="macos-latest-x64/latest-mac.yml"
|
||||
ARM_YML="macos-latest-arm64/latest-mac.yml"
|
||||
|
||||
if [ -f "$X64_YML" ] && [ -f "$ARM_YML" ]; then
|
||||
echo "Merging latest-mac.yml from both architectures"
|
||||
node -e "
|
||||
const fs = require('fs');
|
||||
const yaml = require('js-yaml');
|
||||
const x64 = yaml.load(fs.readFileSync('$X64_YML', 'utf8'));
|
||||
const arm = yaml.load(fs.readFileSync('$ARM_YML', 'utf8'));
|
||||
const all = [...(x64.files || []), ...(arm.files || [])];
|
||||
const map = new Map();
|
||||
for (const f of all) map.set(f.url, f);
|
||||
x64.files = [...map.values()];
|
||||
const out = yaml.dump(x64, { lineWidth: -1 });
|
||||
fs.writeFileSync('$X64_YML', out);
|
||||
console.log(out);
|
||||
"
|
||||
rm -f "$ARM_YML"
|
||||
else
|
||||
echo "Skipping merge — need both $X64_YML and $ARM_YML"
|
||||
ls -la macos-latest-*/latest-mac.yml 2>/dev/null || true
|
||||
fi
|
||||
|
||||
- name: Merge Linux latest-linux.yml (x64 + arm64)
|
||||
run: |
|
||||
X64_YML="ubuntu-latest-x64/latest-linux.yml"
|
||||
ARM_YML="ubuntu-24.04-arm-arm64/latest-linux-arm64.yml"
|
||||
|
||||
if [ -f "$X64_YML" ] && [ -f "$ARM_YML" ]; then
|
||||
echo "Merging latest-linux.yml from both architectures"
|
||||
node -e "
|
||||
const fs = require('fs');
|
||||
const yaml = require('js-yaml');
|
||||
const x64 = yaml.load(fs.readFileSync('$X64_YML', 'utf8'));
|
||||
const arm = yaml.load(fs.readFileSync('$ARM_YML', 'utf8'));
|
||||
const all = [...(x64.files || []), ...(arm.files || [])];
|
||||
const map = new Map();
|
||||
for (const f of all) map.set(f.url, f);
|
||||
x64.files = [...map.values()];
|
||||
const out = yaml.dump(x64, { lineWidth: -1 });
|
||||
fs.writeFileSync('$X64_YML', out);
|
||||
console.log(out);
|
||||
"
|
||||
rm -f "$ARM_YML"
|
||||
else
|
||||
echo "Skipping merge — need both $X64_YML and $ARM_YML"
|
||||
ls -la ubuntu-*-*/latest-linux*.yml 2>/dev/null || true
|
||||
fi
|
||||
|
||||
- name: Merge Windows latest.yml (x64 + arm64)
|
||||
run: |
|
||||
X64_YML="windows-latest-x64/latest.yml"
|
||||
ARM_YML="windows-11-arm-arm64/latest.yml"
|
||||
|
||||
if [ -f "$X64_YML" ] && [ -f "$ARM_YML" ]; then
|
||||
echo "Merging latest.yml from both architectures"
|
||||
node -e "
|
||||
const fs = require('fs');
|
||||
const yaml = require('js-yaml');
|
||||
const x64 = yaml.load(fs.readFileSync('$X64_YML', 'utf8'));
|
||||
const arm = yaml.load(fs.readFileSync('$ARM_YML', 'utf8'));
|
||||
const all = [...(x64.files || []), ...(arm.files || [])];
|
||||
const map = new Map();
|
||||
for (const f of all) map.set(f.url, f);
|
||||
x64.files = [...map.values()];
|
||||
const out = yaml.dump(x64, { lineWidth: -1 });
|
||||
fs.writeFileSync('$X64_YML', out);
|
||||
console.log(out);
|
||||
"
|
||||
rm -f "$ARM_YML"
|
||||
else
|
||||
echo "Skipping merge — need both $X64_YML and $ARM_YML"
|
||||
ls -la windows-*-*/latest.yml 2>/dev/null || true
|
||||
fi
|
||||
|
||||
- name: Reconcile update manifest hashes
|
||||
run: |
|
||||
node -e "
|
||||
const fs = require('fs');
|
||||
const crypto = require('crypto');
|
||||
const yaml = require('js-yaml');
|
||||
const path = require('path');
|
||||
|
||||
const manifests = [
|
||||
{ prefix: 'macos-latest-', file: 'latest-mac.yml' },
|
||||
{ prefix: 'ubuntu-', file: 'latest-linux.yml' },
|
||||
{ prefix: 'windows-', file: 'latest.yml' },
|
||||
];
|
||||
|
||||
const allDirs = fs.readdirSync('.').filter(d => {
|
||||
try { return fs.statSync(d).isDirectory(); } catch { return false; }
|
||||
});
|
||||
|
||||
for (const { prefix, file } of manifests) {
|
||||
const dirs = allDirs.filter(d => d.startsWith(prefix));
|
||||
let ymlPath = null;
|
||||
for (const dir of dirs) {
|
||||
const p = path.join(dir, file);
|
||||
if (fs.existsSync(p)) { ymlPath = p; break; }
|
||||
}
|
||||
if (!ymlPath) { console.log('No ' + file + ' found, skipping'); continue; }
|
||||
|
||||
const manifest = yaml.load(fs.readFileSync(ymlPath, 'utf8'));
|
||||
let fixed = 0;
|
||||
|
||||
for (const entry of manifest.files) {
|
||||
for (const dir of dirs) {
|
||||
const filePath = path.join(dir, entry.url);
|
||||
if (fs.existsSync(filePath)) {
|
||||
const buf = fs.readFileSync(filePath);
|
||||
const hash = crypto.createHash('sha512').update(buf).digest('base64');
|
||||
if (hash !== entry.sha512) {
|
||||
console.log('[' + file + '] Fix: ' + entry.url);
|
||||
entry.sha512 = hash;
|
||||
entry.size = buf.length;
|
||||
fixed++;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (manifest.path) {
|
||||
for (const dir of dirs) {
|
||||
const filePath = path.join(dir, manifest.path);
|
||||
if (fs.existsSync(filePath)) {
|
||||
const buf = fs.readFileSync(filePath);
|
||||
manifest.sha512 = crypto.createHash('sha512').update(buf).digest('base64');
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const out = yaml.dump(manifest, { lineWidth: -1 });
|
||||
fs.writeFileSync(ymlPath, out);
|
||||
console.log('[' + file + '] ' + (fixed ? 'Fixed ' + fixed + ' entries' : 'All hashes OK'));
|
||||
}
|
||||
"
|
||||
|
||||
- name: Create Release
|
||||
uses: softprops/action-gh-release@v2
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
tag_name: v${{ steps.version.outputs.version }}
|
||||
name: v${{ steps.version.outputs.version }}
|
||||
body_path: /tmp/release_notes.md
|
||||
draft: false
|
||||
prerelease: false
|
||||
files: |
|
||||
windows-*-*/*.exe
|
||||
windows-*-*/*.blockmap
|
||||
windows-*-*/latest*.yml
|
||||
macos-latest-*/*.dmg
|
||||
macos-latest-*/*.zip
|
||||
macos-latest-*/*.pkg
|
||||
macos-latest-*/*.blockmap
|
||||
macos-latest-*/latest*.yml
|
||||
ubuntu-*-*/*.deb
|
||||
ubuntu-*-*/*.AppImage
|
||||
ubuntu-*-*/*.snap
|
||||
ubuntu-*-*/*.tar.gz
|
||||
ubuntu-*-*/latest*.yml
|
||||
Reference in new issue
Block a user