Skip to content

Commit

Permalink
auto updater (#2)
Browse files Browse the repository at this point in the history
  • Loading branch information
nirtamir2 authored Oct 13, 2023
1 parent cc17a85 commit 1f49778
Show file tree
Hide file tree
Showing 7 changed files with 264 additions and 33 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/release-tauri.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ jobs:
- uses: tauri-apps/tauri-action@v0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TAURI_PRIVATE_KEY: ${{ secrets.TAURI_PRIVATE_KEY }}
TAURI_KEY_PASSWORD: ${{ secrets.TAURI_KEY_PASSWORD }}
with:
tagName: app-v__VERSION__ # the action automatically replaces \_\_VERSION\_\_ with the app version
projectPath: "./apps/tauri"
Expand Down
2 changes: 1 addition & 1 deletion apps/tauri/src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ edition = "2021"
tauri-build = { version = "1.5", features = [] }

[dependencies]
tauri = { version = "1.5", features = [ "http-all", "window-start-dragging", "macos-private-api", "shell-open"] }
tauri = { version = "1.5", features = [ "updater", "http-all", "window-start-dragging", "macos-private-api", "shell-open"] }
serde = { version = "1.0", features = ["derive"] }
tauri-plugin-positioner = { version = "1.0.4", features = ["system-tray"] }
serde_json = "1.0"
Expand Down
18 changes: 15 additions & 3 deletions apps/tauri/src-tauri/tauri.conf.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"$schema": "../node_modules/@tauri-apps/cli/schema.json",
"build": {
"beforeDevCommand": "pnpm dev",
"beforeBuildCommand": "cross-env VITE_USE_PRODUCTION_API=true NODE_ENV=production pnpm build",
Expand All @@ -8,7 +9,7 @@
},
"package": {
"productName": "tzeva-adom",
"version": "0.3.0"
"version": "0.4.0"
},
"tauri": {
"macOSPrivateApi": true,
Expand All @@ -18,7 +19,9 @@
},
"http": {
"all": true,
"scope": ["https://www.oref.org.il/WarningMessages/alert/alerts.json"]
"scope": [
"https://www.oref.org.il/WarningMessages/alert/alerts.json"
]
},
"all": false,
"shell": {
Expand Down Expand Up @@ -73,6 +76,15 @@
"title": "Tzeva Adom",
"width": 230
}
]
],
"updater": {
"active": true,
"endpoints": [
"https://gist.github.com/nirtamir2/f9fd2e3e5d683bad411a5cf4d94dcf7c",
"https://gist.github.com/nirtamir2/f9fd2e3e5d683bad411a5cf4d94dcf7c/raw/tzeva-adom.releases.json"
],
"dialog": true,
"pubkey": "dW50cnVzdGVkIGNvbW1lbnQ6IG1pbmlzaWduIHB1YmxpYyBrZXk6IDkwMzJCQzVDQjMzRDEzQ0QKUldUTkV6MnpYTHd5a0xOUGpURGFmN2NBQ0VVOHFkWnFRcnc2L0RoSStKVEZPRFV5ejdEeHcxYnUK"
}
}
}
3 changes: 2 additions & 1 deletion apps/website/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
},
"dependencies": {
"@astrojs/partytown": "^2.0.1",
"astro": "^3.2.3"
"astro": "^3.2.3",
"astro-icon": "^0.8.1"
}
}
33 changes: 22 additions & 11 deletions apps/website/src/components/Card.astro
Original file line number Diff line number Diff line change
@@ -1,22 +1,33 @@
---
import { Icon } from 'astro-icon'
interface Props {
title: string;
body: string;
href: string;
iconName: string
title: string
download?: boolean
href: string
}
const { href, title, body } = Astro.props;
const { iconName, title, download, href } = Astro.props;
---
<script>
const links = document.querySelectorAll('a [data-download-link]');
links.forEach((link) => {
link.addEventListener('click', () => {
window.gtag('event', 'file_download', {
'event_category' : 'send-to',
'event_label' : href,

})
});
});
</script>
<li class="link-card">
<a href={href}>
<a href={href} download={download} data-download-link>
<h2>
{title}
<span>&larr;</span>
<Icon height={24} name={iconName}/>
</h2>
<p>
{body}
</p>
<p>{title}</p>
</a>
</li>
<style>
Expand Down
85 changes: 68 additions & 17 deletions apps/website/src/pages/index.astro
Original file line number Diff line number Diff line change
@@ -1,6 +1,45 @@
---
import Layout from "../layouts/Layout.astro";
import Card from "../components/Card.astro";
interface ReleasesResponse {
"version": string,
"notes": string,
"pub_date": string,
"platforms": {
"darwin-x86_64": {
"signature": string,
"url": string
},
"darwin-aarch64": {
"signature": string,
"url": string
},
"linux-x86_64": {
"signature": "string",
"url": string
},
"windows-x86_64": {
"signature": "string",
"url": string
},
"win64": {
"signature": "string",
"url": string
},
"linux": {
"signature": "string",
"url": string
},
"darwin": {
"signature": string,
"url": string
}
}
}
const releasesResponse = await fetch("https://gist.github.com/nirtamir2/f9fd2e3e5d683bad411a5cf4d94dcf7c/raw/tzeva-adom.releases.json");
const releases: ReleasesResponse = await releasesResponse.json();
---


Expand Down Expand Up @@ -40,30 +79,36 @@ import Card from "../components/Card.astro";
</p>
<p>
לא חייב להיות כל היום מול מסך הטלוויזיה...
הצגת התרעות צבע אדום כמו בטלוויזיה - גם על מסך המחשב שלך!
</p>
<p>זאת <strong>אינה</strong> אפליקציה רשמית. היא עובדת על ידי כך שהיא פונה לאתר של פיקוד העורף כל שנייה כדי לדעת האם
יש התרעות של צבע אדום
ומציגה אותם בהתאם
<p> הצגת התרעות צבע אדום כמו בטלוויזיה - גם על מסך המחשב שלך!
</p>
<p>כרגע האפליקציה רק מציגה את ההתראות בזמן אמת, בלי להשמיע צליל</p>
<h3>דמו</h3>
<div class="demo-image">
<img src="/assets/demo-mock-data.gif" height="188" width="222" alt="דמו של האפליקציה"/>
<img src="/assets/demo-mock-data.gif" height="188" width="222" alt="דמו של האפליקציה" />
</div>
<h3>הורדות</h3>
<ul role="list" class="link-card-grid">
<Card
href="https://github.com/nirtamir2/tzeva-adom/releases/latest"
title="הורדה"
body="הורדה דרך GitHub"
/>
<Card
href="https://github.com/nirtamir2/tzeva-adom"
title="GitHub"
body="קישור לקוד המקור"
/>

{releases.platforms != null ?
<>
<Card download iconName="simple-icons:windows" title="Windows" href={releases.platforms.win64.url} />
<Card download iconName="simple-icons:macos" title="macOS" href={releases.platforms.darwin.url} />
<Card download iconName="simple-icons:linux" title="Linux" href={releases.platforms.linux.url} />
</> : null}
<Card iconName="ic:sharp-cloud-download" title="פלטפורמות נוספות"
href="https://github.com/nirtamir2/tzeva-adom/releases/latest" />
<Card iconName="simple-icons:github" title="קוד המקור בGitHub" href="https://github.com/nirtamir2/tzeva-adom" />
</ul>

<h3>פרטים נוספים</h3>

<p>זאת <strong>אינה</strong> אפליקציה רשמית.
</p>
<p>
היא עובדת על ידי כך שהיא פונה לאתר של פיקוד העורף כל שנייה כדי לדעת האם
יש התרעות של צבע אדום
ומציגה אותם בהתאם
</p>
<p>כרגע האפליקציה רק מציגה את ההתראות בזמן אמת, בלי להשמיע צליל</p>

</main>
</Layout>
Expand All @@ -80,6 +125,7 @@ import Card from "../components/Card.astro";
}

.demo-image {
padding: 2rem 0;
display: flex;
align-items: center;
justify-content: center;
Expand Down Expand Up @@ -138,4 +184,9 @@ import Card from "../components/Card.astro";
gap: 2rem;
padding: 0;
}

p {
margin: 0;
text-wrap: balance;
}
</style>
Loading

0 comments on commit 1f49778

Please sign in to comment.