Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix auto updater #840

Merged
merged 17 commits into from
Jul 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,8 @@ jobs:
path: |
out/make/**/*.dmg
out/make/**/*.AppImage
out/make/**/*.zip
out/make/**/*.nupkg
windows_signing/**/*.exe

- name: Show build items
Expand Down Expand Up @@ -231,8 +233,10 @@ jobs:
run: |
mkdir dist
find ${{ github.workspace }}/artifacts -name '*.exe' -exec cp -v {} ${{ github.workspace }}/dist \;
find ${{ github.workspace }}/artifacts -name '*.nupkg' -exec cp -v {} ${{ github.workspace }}/dist \;
find ${{ github.workspace }}/artifacts -name '*.AppImage' -exec cp -v {} ${{ github.workspace }}/dist \;
find ${{ github.workspace }}/artifacts -name '*.dmg' -exec cp -v {} ${{ github.workspace }}/dist \;
find ${{ github.workspace }}/artifacts -name '*.zip' -exec cp -v {} ${{ github.workspace }}/dist \;

- name: Log dist folder
run: |
Expand Down
58 changes: 35 additions & 23 deletions .github/workflows/staging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@ jobs:
fail-fast: false
matrix:
include:
- os: macos-12
- os: macos-13
- os: windows-2019
- os: ubuntu-20.04
steps:
- uses: actions/setup-python@v4
- uses: actions/setup-python@v5
with:
python-version: "3.10"
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20.13.1
Expand All @@ -41,7 +41,7 @@ jobs:
run: sudo apt update && sudo apt install libudev-dev
- name: Cache node_modules
id: cache-node-modules
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: node_modules
key: ${{ runner.os }}-${{ hashFiles('package.json', 'yarn.lock') }}
Expand All @@ -51,26 +51,35 @@ jobs:
- run: yarn run test

build:
runs-on: ${{ matrix.os }}
needs: [testing]
permissions:
contents: write # to be able to publish a GitHub release
issues: write # to be able to comment on released issues
pull-requests: write # to be able to comment on released pull requests

name: Bazecor ${{ matrix.target_os }}_${{ matrix.target_arch }} binaries
strategy:
fail-fast: false
matrix:
os: [ubuntu-20.04, windows-2019, macos-13]
target_arch: [arm, amd64]
include:
- os: macos-12
- os: ubuntu-20.04
target_os: linux
- os: windows-2019
target_os: windows
- os: macOS-13
target_os: darwin
exclude:
- os: windows-2019
target_arch: arm
- os: ubuntu-20.04

target_arch: arm
runs-on: ${{ matrix.os }}
needs: [testing]
permissions:
contents: write # to be able to publish a GitHub release
issues: write # to be able to comment on released issues
pull-requests: write # to be able to comment on released pull requests
steps:
- uses: actions/setup-python@v4
- uses: actions/setup-python@v5
with:
python-version: "3.10"
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20.13.1
Expand All @@ -79,7 +88,7 @@ jobs:
run: sudo apt update && sudo apt install libudev-dev
- if: runner.os == 'Windows'
name: Set up Java
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
distribution: "temurin"
java-version: "17"
Expand All @@ -93,19 +102,19 @@ jobs:
cp jsign.jar windows_signing/jsign.jar
- if: runner.os == 'Windows'
name: Setup GCloud Auth
uses: "google-github-actions/auth@v1"
uses: "google-github-actions/auth@v2"
with:
credentials_json: "${{ secrets.GCP_SIGNER_SERVICE_ACCOUNT }}"
- if: runner.os == 'Windows'
name: "Set up GCloud SDK"
uses: "google-github-actions/setup-gcloud@v1"
uses: "google-github-actions/setup-gcloud@v2"
env:
CLOUDSDK_PYTHON: ${{ env.pythonLocation }}${{ '\python' }}
with:
version: ">= 416.0.0"
- name: Cache node_modules
id: cache-node-modules
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: node_modules
key: ${{ runner.os }}-${{ hashFiles('package.json', 'yarn.lock') }}
Expand Down Expand Up @@ -137,14 +146,14 @@ jobs:
security import $APPLE_APPLICATION_CERT_PATH -P "$APPLE_CERT_PASSWORD" -A -t cert -f pkcs12 -k $KEYCHAIN_PATH
security list-keychain -d user -s $KEYCHAIN_PATH
# - run: yarn run lint
- if: runner.os == 'macOS'
- if: runner.os == 'macOS' && matrix.target_arch == 'amd64'
name: Build for MacOS Intel
env:
APPLE_ID: ${{ secrets.APPLEID }}
APPLE_ID_PASSWORD: ${{ secrets.APPLEIDPASS }}
APPLE_TEAM_ID: ${{ secrets.APPLE_TEAM_ID }}
run: yarn run make-mac-intel
- if: runner.os == 'macOS'
- if: runner.os == 'macOS' && matrix.target_arch == 'arm'
name: Build for MacOS Arm
env:
APPLE_ID: ${{ secrets.APPLEID }}
Expand Down Expand Up @@ -176,12 +185,15 @@ jobs:
--certfile "dygma_cert.pem" --tsmode RFC3161 --tsaurl http://timestamp.digicert.com $EXE_FILE
cd ..
- name: Upload build
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: artifacts
name: Bazecor-${{ matrix.os }}-${{ matrix.target_arch }}
path: |
out/make/**/*.dmg
out/make/**/*.AppImage
out/make/**/*.zip
out/make/**/*.nupkg
out/make/**/RELEASES*
windows_signing/**/*.exe

- name: Show build items
Expand Down
16 changes: 10 additions & 6 deletions forge.config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type { ForgeConfig, ForgePackagerOptions } from "@electron-forge/shared-types";
import { MakerSquirrel } from "@electron-forge/maker-squirrel";
import { MakerZIP } from "@electron-forge/maker-zip";
import { WebpackPlugin } from "@electron-forge/plugin-webpack";
import fs from "fs";
import path from "path";
Expand All @@ -22,26 +23,29 @@ const packagerConfig: ForgePackagerOptions = {
};

if (process.env["NODE_ENV"] !== "development") {
packagerConfig.osxNotarize = {
appleId: process.env["APPLE_ID"] || "",
appleIdPassword: process.env["APPLE_ID_PASSWORD"] || "",
teamId: process.env["APPLE_TEAM_ID"] || "",
};
packagerConfig.osxSign = {
optionsForFile: () => ({
entitlements: "./build/entitlements.plist",
identity: process.env["APPLE_IDENTITY"],
// entitlements: "./build/entitlements.plist",
hardenedRuntime: true,
}),
};
packagerConfig.osxNotarize = {
appleId: process.env["APPLE_ID"] || "",
appleIdPassword: process.env["APPLE_ID_PASSWORD"] || "",
teamId: process.env["APPLE_TEAM_ID"] || "",
};
}

const config: ForgeConfig = {
packagerConfig,
rebuildConfig: {},
makers: [
new MakerSquirrel({
name: "bazecor",
setupIcon: "./build/logo.ico",
}),
new MakerZIP({}, ["darwin"]),
{
name: "@electron-forge/maker-dmg",
config: {
Expand Down
8 changes: 3 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "Bazecor",
"productName": "Bazecor",
"version": "1.4.1",
"version": "1.4.2",
"description": "Bazecor desktop app",
"private": true,
"repository": {
Expand Down Expand Up @@ -61,6 +61,7 @@
"@electron-forge/maker-dmg": "^7.4.0",
"@electron-forge/maker-rpm": "^7.4.0",
"@electron-forge/maker-squirrel": "^7.4.0",
"@electron-forge/maker-zip": "^7.4.0",
"@electron-forge/plugin-webpack": "^7.4.0",
"@electron/universal": "^1.4.1",
"@playwright/test": "^1.36.0",
Expand Down Expand Up @@ -194,12 +195,9 @@
"category": "Utility"
},
"mac": {
"entitlements": "./build/entitlements.plist",
"category": "public.app-category.utilities",
"target": [
{
"target": "dmg"
}
"default"
]
}
}
Expand Down
7 changes: 4 additions & 3 deletions src/main/setup/configureAutoUpdate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,16 @@ const store = Store.getStore();
const configureAutoUpdate = () => {
const autoUpdate = store.get("settings.autoUpdate") as boolean;

if (autoUpdate === true) {
if (autoUpdate === true && process.platform !== "linux") {
updateElectronApp({
updateSource: {
type: UpdateSourceType.ElectronPublicUpdateService,
repo: "Dygmalab/Bazecor",
host: "https://github.com/Dygmalab/Bazecor",
host: "https://update.electronjs.org",
repo: "dygmalab/bazecor",
},
updateInterval: "24 hour",
logger: log,
notifyUser: true,
});
}
};
Expand Down
3 changes: 1 addition & 2 deletions src/main/utils/autoUpdateOptIn.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import { BrowserWindow, dialog, MessageBoxOptions } from "electron";
import log from "electron-log/main";
import Store from "../managers/Store";

const store = Store.getStore();

const autoUpdateOptIn = (mainWindow: BrowserWindow) => {
const autoUpdate = store.get("settings.autoUpdate") as boolean;

if (autoUpdate === undefined) {
if (autoUpdate === undefined && process.platform !== "linux") {
let dialogOpts: MessageBoxOptions;
if (process.platform !== "darwin") {
dialogOpts = {
Expand Down
30 changes: 17 additions & 13 deletions src/renderer/modules/Settings/GeneralSettings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -248,19 +248,23 @@ const GeneralSettings = ({
size="sm"
/>
</div>
<div className="flex items-center w-full justify-between py-2 border-b-[1px] border-gray-50 dark:border-gray-700">
<label htmlFor="autoUpdateSwitch" className="m-0 text-sm font-semibold tracking-tight">
{i18n.preferences.autoUpdate}
</label>
<Switch
id="autoUpdateSwitch"
defaultChecked={false}
checked={autoUpdate}
onCheckedChange={onChangeAutoUpdate}
variant="default"
size="sm"
/>
</div>
{process.platform !== "linux" ? (
<div className="flex items-center w-full justify-between py-2 border-b-[1px] border-gray-50 dark:border-gray-700">
<label htmlFor="autoUpdateSwitch" className="m-0 text-sm font-semibold tracking-tight">
{i18n.preferences.autoUpdate}
</label>
<Switch
id="autoUpdateSwitch"
defaultChecked={false}
checked={autoUpdate}
onCheckedChange={onChangeAutoUpdate}
variant="default"
size="sm"
/>
</div>
) : (
""
)}
</form>
</CardContent>
</Card>
Expand Down
47 changes: 44 additions & 3 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1203,6 +1203,17 @@
optionalDependencies:
electron-winstaller "^5.3.0"

"@electron-forge/maker-zip@^7.4.0":
version "7.4.0"
resolved "https://registry.yarnpkg.com/@electron-forge/maker-zip/-/maker-zip-7.4.0.tgz#e82ab6174344c43eb9a30b2fb5e2c2e32de2113d"
integrity sha512-UGbMdpuK/P29x1FFRWNOs3bNz+7QNFWVWyTM5hcWqib66cNuUmoaPifQyuwW2POIrIohrxlzLK87/i9Zc8g4dA==
dependencies:
"@electron-forge/maker-base" "7.4.0"
"@electron-forge/shared-types" "7.4.0"
cross-zip "^4.0.0"
fs-extra "^10.0.0"
got "^11.8.5"

"@electron-forge/[email protected]":
version "7.4.0"
resolved "https://registry.npmjs.org/@electron-forge/plugin-base/-/plugin-base-7.4.0.tgz"
Expand Down Expand Up @@ -5635,6 +5646,11 @@ cross-spawn@^7.0.0, cross-spawn@^7.0.1, cross-spawn@^7.0.2, cross-spawn@^7.0.3:
shebang-command "^2.0.0"
which "^2.0.1"

cross-zip@^4.0.0:
version "4.0.1"
resolved "https://registry.yarnpkg.com/cross-zip/-/cross-zip-4.0.1.tgz#1bbf5d3b0e5a77b5f5ca130a6d38f770786e1270"
integrity sha512-n63i0lZ0rvQ6FXiGQ+/JFCKAUyPFhLQYJIqKaa+tSJtfKeULF/IDNDAbdnSIxgS4NTuw2b0+lj8LzfITuq+ZxQ==

crypto-random-string@^4.0.0:
version "4.0.0"
resolved "https://registry.npmjs.org/crypto-random-string/-/crypto-random-string-4.0.0.tgz"
Expand Down Expand Up @@ -12651,7 +12667,16 @@ stream-combiner2@~1.1.1:
duplexer2 "~0.1.0"
readable-stream "^2.0.2"

"string-width-cjs@npm:string-width@^4.2.0", "string-width@^1.0.2 || 2 || 3 || 4", string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.3:
"string-width-cjs@npm:string-width@^4.2.0":
version "4.2.3"
resolved "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz"
integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==
dependencies:
emoji-regex "^8.0.0"
is-fullwidth-code-point "^3.0.0"
strip-ansi "^6.0.1"

"string-width@^1.0.2 || 2 || 3 || 4", string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.3:
version "4.2.3"
resolved "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz"
integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==
Expand Down Expand Up @@ -12722,7 +12747,14 @@ string_decoder@^1.1.1, string_decoder@~1.1.1:
dependencies:
safe-buffer "~5.1.0"

"strip-ansi-cjs@npm:strip-ansi@^6.0.1", strip-ansi@^6.0.0, strip-ansi@^6.0.1:
"strip-ansi-cjs@npm:strip-ansi@^6.0.1":
version "6.0.1"
resolved "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz"
integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==
dependencies:
ansi-regex "^5.0.1"

strip-ansi@^6.0.0, strip-ansi@^6.0.1:
version "6.0.1"
resolved "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz"
integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==
Expand Down Expand Up @@ -14114,7 +14146,16 @@ wordwrap@^1.0.0:
resolved "https://registry.npmjs.org/wordwrap/-/wordwrap-1.0.0.tgz"
integrity sha512-gvVzJFlPycKc5dZN4yPkP8w7Dc37BtP1yczEneOb4uq34pXZcvrtRTmWV8W+Ume+XCxKgbjM+nevkyFPMybd4Q==

"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0", wrap-ansi@^7.0.0:
"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0":
version "7.0.0"
resolved "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz"
integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==
dependencies:
ansi-styles "^4.0.0"
string-width "^4.1.0"
strip-ansi "^6.0.0"

wrap-ansi@^7.0.0:
version "7.0.0"
resolved "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz"
integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==
Expand Down
Loading