Skip to content
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
87 changes: 87 additions & 0 deletions .github/workflows/version-bump.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
name: Version Bump

on:
workflow_dispatch:
inputs:
bump:
description: "Version bump type"
required: true
type: choice
options:
- patch
- minor
- major
custom_version:
description: "Custom version (overrides bump type, e.g. 1.2.3)"
required: false
type: string

jobs:
bump-version:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: lts/*

- name: Calculate new version
id: version
run: |
CURRENT=$(node -p "require('./package.json').version")
echo "current=$CURRENT" >> "$GITHUB_OUTPUT"

if [ -n "${{ inputs.custom_version }}" ]; then
NEW="${{ inputs.custom_version }}"
else
IFS='.' read -r major minor patch <<< "$CURRENT"
case "${{ inputs.bump }}" in
major) NEW="$((major + 1)).0.0" ;;
minor) NEW="$major.$((minor + 1)).0" ;;
patch) NEW="$major.$minor.$((patch + 1))" ;;
esac
fi

echo "new=$NEW" >> "$GITHUB_OUTPUT"
echo "Bumping version: $CURRENT -> $NEW"

- name: Update package.json
run: |
node -e "
const fs = require('fs');
const pkg = JSON.parse(fs.readFileSync('package.json', 'utf8'));
pkg.version = '${{ steps.version.outputs.new }}';
fs.writeFileSync('package.json', JSON.stringify(pkg, null, 2) + '\n');
"

- name: Update tauri.conf.json
run: |
node -e "
const fs = require('fs');
const conf = JSON.parse(fs.readFileSync('src-tauri/tauri.conf.json', 'utf8'));
conf.version = '${{ steps.version.outputs.new }}';
fs.writeFileSync('src-tauri/tauri.conf.json', JSON.stringify(conf, null, 2) + '\n');
"

- name: Update Cargo.toml
run: |
sed -i 's/^version = "${{ steps.version.outputs.current }}"/version = "${{ steps.version.outputs.new }}"/' src-tauri/Cargo.toml

- name: Update Cargo.lock
run: |
sed -i '/^name = "timlyzer"/{n;s/^version = "${{ steps.version.outputs.current }}"/version = "${{ steps.version.outputs.new }}"/}' src-tauri/Cargo.lock

- name: Commit and tag
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add package.json src-tauri/tauri.conf.json src-tauri/Cargo.toml src-tauri/Cargo.lock
git commit -m "chore: bump version to v${{ steps.version.outputs.new }}"
git tag "v${{ steps.version.outputs.new }}"
git push origin main --tags
13 changes: 13 additions & 0 deletions src-tauri/src/tray.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ pub struct TrayTranslations {
pub tracking_enabled: String,
pub open: String,
pub summary: String,
pub settings: String,
pub quit: String,
}

Expand All @@ -23,6 +24,7 @@ impl Default for TrayTranslations {
tracking_enabled: "Tracking Enabled".to_string(),
open: "Open Timlyzer".to_string(),
summary: "Today's Summary".to_string(),
settings: "Settings".to_string(),
quit: "Quit".to_string(),
}
}
Expand All @@ -39,6 +41,8 @@ fn create_menu<R: Runtime>(app: &AppHandle<R>, trans: &TrayTranslations) -> taur
)?;
let open_item = MenuItem::with_id(app, "open", &trans.open, true, None::<&str>)?;
let summary_item = MenuItem::with_id(app, "summary", &trans.summary, true, None::<&str>)?;
let settings_item =
MenuItem::with_id(app, "settings", &trans.settings, true, None::<&str>)?;
let separator = MenuItem::with_id(app, "sep1", "───────────", false, None::<&str>)?;
let quit_item = MenuItem::with_id(app, "quit", &trans.quit, true, None::<&str>)?;

Expand All @@ -49,6 +53,7 @@ fn create_menu<R: Runtime>(app: &AppHandle<R>, trans: &TrayTranslations) -> taur
&separator,
&open_item,
&summary_item,
&settings_item,
&separator,
&quit_item,
],
Expand Down Expand Up @@ -77,6 +82,7 @@ pub fn setup_tray(app: &tauri::App) -> Result<TrayIcon, tauri::Error> {
if let Some(window) = app.get_webview_window("main") {
let _ = window.show();
let _ = window.set_focus();
let _ = window.eval("window.location.assign('/')");
}
}
"summary" => {
Expand All @@ -87,6 +93,13 @@ pub fn setup_tray(app: &tauri::App) -> Result<TrayIcon, tauri::Error> {
let _ = window.eval("window.location.assign('/summary')");
}
}
"settings" => {
if let Some(window) = app.get_webview_window("main") {
let _ = window.show();
let _ = window.set_focus();
let _ = window.eval("window.location.assign('/settings')");
}
}
"quit" => {
app.exit(0);
}
Expand Down
1 change: 1 addition & 0 deletions src/i18n/locales/en-US/tray.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
"tracking_enabled": "Tracking Enabled",
"open": "Open Timlyzer",
"summary": "Today's Summary",
"settings": "Settings",
"quit": "Quit"
}
1 change: 1 addition & 0 deletions src/i18n/locales/zh-CN/tray.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
"tracking_enabled": "启用追踪",
"open": "打开 Timlyzer",
"summary": "今日概览",
"settings": "设置",
"quit": "退出"
}