Skip to content

Commit c337bf8

Browse files
authored
Update to v0.1.10 (#13)
* Update navbar * yeee * ok * update (thx coderabiit)
1 parent f45df48 commit c337bf8

File tree

15 files changed

+441
-272
lines changed

15 files changed

+441
-272
lines changed

.github/scripts/README.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# CI Scripts
2+
3+
This directory contains scripts used by GitHub Actions workflows to automate various tasks.
4+
5+
## increment-version.js
6+
7+
Automatically increments the version number in `apps/web/projectData.ts`.
8+
9+
### Usage
10+
11+
```bash
12+
node .github/scripts/increment-version.js
13+
```
14+
15+
### Version Increment Logic
16+
17+
The script handles different version formats intelligently:
18+
19+
1. **Suffixed versions** (e.g., `"0.1.10-canary-1"``"0.1.10-canary-2"`)
20+
- Increments the number after the final dash
21+
22+
2. **Semantic versions** (e.g., `"0.1.10"``"0.1.11"`)
23+
- Increments the patch version (third number)
24+
25+
3. **Fallback pattern** - Increments the last number found in the version string
26+
27+
### Outputs
28+
29+
When run in GitHub Actions, the script sets these outputs:
30+
- `current`: The previous version number
31+
- `new`: The new incremented version number
32+
33+
### Integration
34+
35+
This script is used by the "Auto Update Version and Build" workflow (`version-and-build.yml`) to automatically increment the version on every push to the main branch, then build and tag a Docker image with the new version.
36+
37+
### Prevention of Infinite Loops
38+
39+
The workflow is designed to skip execution when the commit message contains "🤖 Auto-increment version" to prevent infinite loops of version updates.
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
#!/usr/bin/env node
2+
3+
import fs from "fs";
4+
import path from "path";
5+
import { fileURLToPath, pathToFileURL } from "url";
6+
7+
const __filename = fileURLToPath(import.meta.url);
8+
const __dirname = path.dirname(__filename);
9+
10+
const PROJECT_DATA_PATH = path.join(__dirname, "../../apps/web/projectData.ts");
11+
12+
function incrementVersion(version) {
13+
// Handle different version formats:
14+
// "0.1.10-canery-1" -> "0.1.10-canery-2"
15+
// "0.1.10" -> "0.1.11"
16+
// "1.2.3-alpha-5" -> "1.2.3-alpha-6"
17+
18+
// Pattern 1: ends with -number (e.g., "0.1.10-canery-1")
19+
const dashNumberPattern = /^(.+-)(\d+)$/;
20+
const dashMatch = version.match(dashNumberPattern);
21+
22+
if (dashMatch) {
23+
const prefix = dashMatch[1];
24+
const number = parseInt(dashMatch[2], 10);
25+
return `${prefix}${number + 1}`;
26+
}
27+
28+
// Pattern 2: semantic version (e.g., "0.1.10" or "1.2.3")
29+
const semverPattern = /^(\d+)\.(\d+)\.(\d+)(.*)$/;
30+
const semverMatch = version.match(semverPattern);
31+
32+
if (semverMatch) {
33+
const major = parseInt(semverMatch[1], 10);
34+
const minor = parseInt(semverMatch[2], 10);
35+
const patch = parseInt(semverMatch[3], 10);
36+
const suffix = semverMatch[4] || "";
37+
return `${major}.${minor}.${patch + 1}${suffix}`;
38+
}
39+
40+
// Fallback: find the last number in the string and increment it
41+
const lastNumberPattern = /^(.*?)(\d+)([^\d]*)$/;
42+
const lastNumberMatch = version.match(lastNumberPattern);
43+
44+
if (lastNumberMatch) {
45+
const prefix = lastNumberMatch[1];
46+
const number = parseInt(lastNumberMatch[2], 10);
47+
const suffix = lastNumberMatch[3];
48+
return `${prefix}${number + 1}${suffix}`;
49+
}
50+
51+
// If no number found, append .1
52+
return `${version}.1`;
53+
}
54+
55+
function updateProjectData() {
56+
try {
57+
// Read the current file
58+
const content = fs.readFileSync(PROJECT_DATA_PATH, "utf8");
59+
60+
// Extract current version using regex
61+
const versionPattern = /version:\s*["']([^"']+)["']/;
62+
const match = content.match(versionPattern);
63+
64+
if (!match) {
65+
throw new Error("Could not find version property in projectData.ts");
66+
}
67+
68+
const currentVersion = match[1];
69+
const newVersion = incrementVersion(currentVersion);
70+
71+
// Replace the version in the content
72+
const newContent = content.replace(
73+
versionPattern,
74+
`version: "${newVersion}"`,
75+
);
76+
77+
// Write back to file
78+
fs.writeFileSync(PROJECT_DATA_PATH, newContent, "utf8");
79+
80+
console.log(`Version updated from ${currentVersion} to ${newVersion}`);
81+
82+
// Output for GitHub Actions (using modern format)
83+
if (process.env.GITHUB_OUTPUT) {
84+
fs.appendFileSync(
85+
process.env.GITHUB_OUTPUT,
86+
`current=${currentVersion}\n`,
87+
);
88+
fs.appendFileSync(process.env.GITHUB_OUTPUT, `new=${newVersion}\n`);
89+
} else {
90+
// Fallback for local testing
91+
console.log(`current=${currentVersion}`);
92+
console.log(`new=${newVersion}`);
93+
}
94+
} catch (error) {
95+
console.error("Error updating version:", error.message);
96+
process.exit(1);
97+
}
98+
}
99+
100+
// Run if this script is executed directly
101+
if (import.meta.url === pathToFileURL(process.argv[1]).href) {
102+
updateProjectData();
103+
}
104+
105+
export { incrementVersion, updateProjectData };
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
name: Auto Update Version
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
- main
8+
workflow_dispatch:
9+
10+
jobs:
11+
update-version:
12+
runs-on: ubuntu-latest
13+
permissions:
14+
contents: write
15+
# Skip if the commit message contains the auto-increment marker to prevent infinite loops
16+
if: "!contains(github.event.head_commit.message, '🤖 Auto-increment version')"
17+
18+
steps:
19+
- name: Checkout repository
20+
uses: actions/checkout@v4
21+
with:
22+
token: ${{ secrets.GITHUB_TOKEN }}
23+
fetch-depth: 0
24+
25+
- name: Setup Node.js
26+
uses: actions/setup-node@v4
27+
with:
28+
node-version: "20"
29+
30+
- name: Update version using Node.js script
31+
id: version_update
32+
run: |
33+
# Make script executable
34+
chmod +x .github/scripts/increment-version.js
35+
36+
# Run the version increment script
37+
node .github/scripts/increment-version.js
38+
39+
# Display updated file
40+
echo "Updated projectData.ts:"
41+
cat apps/web/projectData.ts
42+
43+
- name: Check for changes
44+
id: git_status
45+
run: |
46+
if [ -n "$(git status --porcelain)" ]; then
47+
echo "changes=true" >> $GITHUB_OUTPUT
48+
else
49+
echo "changes=false" >> $GITHUB_OUTPUT
50+
fi
51+
52+
- name: Commit and push changes
53+
if: steps.git_status.outputs.changes == 'true'
54+
run: |
55+
git config --local user.email "action@github.com"
56+
git config --local user.name "GitHub Action"
57+
git add apps/web/projectData.ts
58+
git commit -m "🤖 Auto-increment version to ${{ steps.version_update.outputs.new }} [skip ci]"
59+
git push
60+
61+
- name: Output version info
62+
run: |
63+
echo "Previous version: ${{ steps.version_update.outputs.current }}"
64+
echo "New version: ${{ steps.version_update.outputs.new }}"

.github/workflows/build_docker_image.yml renamed to .github/workflows/build_docker_image.yml.disabled

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ jobs:
1717
permissions:
1818
contents: read
1919
packages: write
20+
# Only run if not triggered by the auto-increment commit
21+
if: "!contains(github.event.head_commit.message, '🤖 Auto-increment version')"
2022

2123
steps:
2224
- name: Checkout repository
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
name: Auto Update Version and Build
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
- main
8+
workflow_dispatch:
9+
10+
env:
11+
REGISTRY: ghcr.io
12+
IMAGE_NAME: ${{ github.repository }}
13+
14+
jobs:
15+
update-version-and-build:
16+
runs-on: ubuntu-latest
17+
permissions:
18+
contents: write
19+
packages: write
20+
# Skip if the commit message contains the auto-increment marker to prevent infinite loops
21+
if: "!contains(github.event.head_commit.message, '🤖 Auto-increment version')"
22+
23+
steps:
24+
- name: Checkout repository
25+
uses: actions/checkout@v4
26+
with:
27+
token: ${{ secrets.GITHUB_TOKEN }}
28+
fetch-depth: 0
29+
30+
- name: Setup Node.js
31+
uses: actions/setup-node@v4
32+
with:
33+
node-version: "20"
34+
35+
- name: Update version using Node.js script
36+
id: version_update
37+
run: |
38+
# Make script executable
39+
chmod +x .github/scripts/increment-version.js
40+
41+
# Run the version increment script
42+
node .github/scripts/increment-version.js
43+
44+
# Display updated file
45+
echo "Updated projectData.ts:"
46+
cat apps/web/projectData.ts
47+
48+
- name: Check for changes
49+
id: git_status
50+
run: |
51+
if [ -n "$(git status --porcelain)" ]; then
52+
echo "changes=true" >> $GITHUB_OUTPUT
53+
else
54+
echo "changes=false" >> $GITHUB_OUTPUT
55+
fi
56+
57+
- name: Commit version changes
58+
if: steps.git_status.outputs.changes == 'true'
59+
run: |
60+
git config --local user.email "action@github.com"
61+
git config --local user.name "GitHub Action"
62+
git add apps/web/projectData.ts
63+
git commit -m "🤖 Auto-increment version to ${{ steps.version_update.outputs.new }}"
64+
git push
65+
66+
- name: Log in to the Container registry
67+
uses: docker/login-action@v3
68+
with:
69+
registry: ${{ env.REGISTRY }}
70+
username: ${{ github.actor }}
71+
password: ${{ secrets.GITHUB_TOKEN }}
72+
73+
- name: Extract metadata (tags, labels) for Docker
74+
id: meta
75+
uses: docker/metadata-action@v5
76+
with:
77+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
78+
tags: |
79+
type=raw,value=latest
80+
type=raw,value=${{ steps.version_update.outputs.new }}
81+
type=ref,event=branch
82+
type=ref,event=pr
83+
type=semver,pattern={{version}}
84+
type=sha,prefix=
85+
86+
- name: Set up Docker Buildx
87+
uses: docker/setup-buildx-action@v3
88+
89+
- name: Build and push Docker image
90+
uses: docker/build-push-action@v5
91+
with:
92+
context: .
93+
push: true
94+
tags: ${{ steps.meta.outputs.tags }}
95+
labels: ${{ steps.meta.outputs.labels }}
96+
cache-from: type=gha
97+
cache-to: type=gha,mode=max
98+
99+
- name: Output summary
100+
run: |
101+
echo "## Version Update Summary" >> $GITHUB_STEP_SUMMARY
102+
echo "- Previous version: ${{ steps.version_update.outputs.current }}" >> $GITHUB_STEP_SUMMARY
103+
echo "- New version: ${{ steps.version_update.outputs.new }}" >> $GITHUB_STEP_SUMMARY
104+
echo "- Docker image built with tags:" >> $GITHUB_STEP_SUMMARY
105+
echo " - ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest" >> $GITHUB_STEP_SUMMARY
106+
echo " - ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.version_update.outputs.new }}" >> $GITHUB_STEP_SUMMARY

apps/web/projectData.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
const data = {
2-
version: "0.1.9",
2+
version: "0.1.10-canery-1",
33
};
44

55
export default data;

apps/web/src/app/dashboard/sidebar.tsx

Lines changed: 1 addition & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,14 @@ import {
55
PanelTopIcon,
66
PlusCircleIcon,
77
UsersIcon,
8-
Sun,
9-
Moon,
108
SettingsIcon,
119
InfoIcon,
1210
CircleArrowLeftIcon,
1311
LibraryIcon,
1412
} from "lucide-react";
1513
import { Button } from "@/components/ui/button";
1614
import Image from "next/image";
17-
import {
18-
DropdownMenu,
19-
DropdownMenuContent,
20-
DropdownMenuItem,
21-
DropdownMenuLabel,
22-
DropdownMenuSeparator,
23-
DropdownMenuTrigger,
24-
} from "@/components/ui/dropdown-menu";
15+
import { ModeToggle } from "@/components/mode-toggle";
2516
import Link from "next/link";
2617
import {
2718
Sidebar,
@@ -39,8 +30,6 @@ import {
3930
import { authClient } from "@/lib/auth-client";
4031
import { useRouter } from "next/navigation";
4132
import type { Route } from "next";
42-
import { useTheme } from "next-themes";
43-
import { useEffect } from "react";
4433

4534
const items = [
4635
{
@@ -211,30 +200,3 @@ export default function DashboardSidebar({
211200
</Sidebar>
212201
);
213202
}
214-
215-
function ModeToggle() {
216-
const { setTheme } = useTheme();
217-
218-
return (
219-
<DropdownMenu>
220-
<DropdownMenuTrigger asChild>
221-
<Button variant="outline" size="icon">
222-
<Sun className="h-[1.2rem] w-[1.2rem] rotate-0 scale-100 transition-all dark:-rotate-90 dark:scale-0" />
223-
<Moon className="absolute h-[1.2rem] w-[1.2rem] rotate-90 scale-0 transition-all dark:rotate-0 dark:scale-100" />
224-
<span className="sr-only">Toggle theme</span>
225-
</Button>
226-
</DropdownMenuTrigger>
227-
<DropdownMenuContent align="end">
228-
<DropdownMenuItem onClick={() => setTheme("light")}>
229-
Light
230-
</DropdownMenuItem>
231-
<DropdownMenuItem onClick={() => setTheme("dark")}>
232-
Dark
233-
</DropdownMenuItem>
234-
<DropdownMenuItem onClick={() => setTheme("system")}>
235-
System
236-
</DropdownMenuItem>
237-
</DropdownMenuContent>
238-
</DropdownMenu>
239-
);
240-
}

0 commit comments

Comments
 (0)