Skip to content

Commit

Permalink
chore: add update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
billyjacoby committed May 9, 2023
1 parent 8a0452e commit 7e0f98f
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 13 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ jobs:
APPLE_CERTIFICATE_PASSWORD: ${{ secrets.APPLE_CERTIFICATE_PASSWORD }}
APPLE_SIGNING_IDENTITY: ${{ secrets.APPLE_SIGNING_IDENTITY }}
APPLE_ID: ${{ secrets.APPLE_ID }}
APPLE_PASSWORD: ${{ secrets.APPLE_ID_PASSWORD }}
APPLE_PASSWORD: ${{ secrets.APPLE_PASSWORD }}
APPLE_PROVIDER_SHORT_NAME: ${{ secrets.APPLE_PROVIDER_SHORT_NAME}}
with:
tagName: app-v__VERSION__ # the action automatically replaces \_\_VERSION\_\_ with the app version
releaseName: 'App v__VERSION__'
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"scripts": {
"dev": "vite",
"build": "tsc && vite build",
"build:debug": "CI=true yarn tauri build --debug --target x86_64-apple-darwin",
"build:debug": "dotenv yarn tauri build -d --target x86_64-apple-darwin",
"build:release": "dotenv yarn tauri build --target x86_64-apple-darwin",
"sign": "dotenv ./bin/apple.sh",
"preview": "vite preview",
Expand Down
2 changes: 1 addition & 1 deletion src-tauri/tauri.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@
"active": true,
"dialog": true,
"endpoints": [
"https://github.com/billyjacoby/browsernaut/releases/tag/{{current_version}}"
"https://raw.githubusercontent.com/billyjacoby/browsernaut/dev/updates.json"
],
"pubkey": "dW50cnVzdGVkIGNvbW1lbnQ6IG1pbmlzaWduIHB1YmxpYyBrZXk6IDg1ODJGMzM3MDNERUNFRDAKUldUUXp0NEROL09DaGVLdUo1WHErVzkyeEV6K0NzQTUzd1pYMGwxOVl2OXIxT1JIQlo2ZWdkUjAK"
},
Expand Down
58 changes: 48 additions & 10 deletions src/views/Preferences/components/PaneAbout.tsx
Original file line number Diff line number Diff line change
@@ -1,30 +1,60 @@
// import { useDispatch } from 'react-redux'

// import icon from '../../../../shared/static/icon/icon.png';
import Button from '@components/Button';
import { getVersion } from '@tauri-apps/api/app';
// import { useSelector } from '../../../shared/state/hooks'
// import {
// clickedHomepageButton,
// clickedOpenIssueButton,
// } from '../../state/actions';
import { checkUpdate, installUpdate } from '@tauri-apps/api/updater';
import { Pane } from '@components/Pane';
import React from 'react';
import { confirm } from '@tauri-apps/api/dialog';

const useDispatch = () => (any: any) => console.log('dispatch: ', any);

export const AboutPane = (): JSX.Element => {
const dispatch = useDispatch();
// const version = useSelector((state) => state.data.version);
const [version, setVersion] = React.useState<null | string>(null);

const [isCheckingForUpdate, setIsCheckingForUpdate] = React.useState(false);

React.useEffect(() => {
(async () => {
const _version = await getVersion();
setVersion(_version);
})();
}, []);

const checkForUpdate = async () => {
setIsCheckingForUpdate(true);

try {
const _updateAvailable = await checkUpdate();
const { manifest, shouldUpdate } = _updateAvailable;

console.log(
'🪵 | file: PaneAbout.tsx:23 | checkForUpdate | shouldUpdate:',
shouldUpdate
);
console.log(
'🪵 | file: PaneAbout.tsx:23 | checkForUpdate | manifest:',
manifest
);

if (shouldUpdate) {
const result = await confirm(
'There is an update available. Would you like to update now?'
);

if (result) {
await installUpdate();
return;
} else {
return;
}
} else {
return;
}
} finally {
setIsCheckingForUpdate(false);
}
};

return (
<Pane className="space-y-8" pane="about">
<div className="text-center">
Expand All @@ -33,7 +63,15 @@ export const AboutPane = (): JSX.Element => {
Browsernaut
</h1>
<p className="mb-8 text-xl">Another browser prompter for macOS</p>
<p className="mb-4 opacity-70">Version {version || 'loading.'}</p>
<p className="mb-2 opacity-70">Version {version || 'loading.'}</p>
<Button
onClick={checkForUpdate}
disabled={isCheckingForUpdate}
className="mb-8"
>
Check{isCheckingForUpdate ? 'ing' : ''} for update
</Button>

<p className="mb-8">Copyright © Billy Jacoby</p>
<div className="space-x-4">
<Button onClick={() => dispatch('clickedHomepageButton()')}>
Expand Down

0 comments on commit 7e0f98f

Please sign in to comment.