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
61 changes: 44 additions & 17 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,21 +39,13 @@ jobs:
run: |
set -euo pipefail

latest_tag="$(git tag --list 'v*' --sort=-v:refname | head -n 1 || true)"
if [[ -z "$latest_tag" ]]; then
version="1.0.0"
else
current_version="${latest_tag#v}"
IFS='.' read -r major minor patch <<< "$current_version"

if [[ -z "${major:-}" || -z "${minor:-}" || -z "${patch:-}" ]]; then
echo "Latest tag '$latest_tag' is not in vX.Y.Z format." >&2
exit 1
fi

version="${major}.${minor}.$((patch + 1))"
current_version="$(node -p "require('./package.json').version")"
IFS='.' read -r major minor patch <<< "$current_version"
if [[ -z "${major:-}" || -z "${minor:-}" || -z "${patch:-}" ]]; then
echo "package.json version '$current_version' is not in X.Y.Z format." >&2
exit 1
fi

version="${major}.${minor}.$((patch + 1))"
echo "version=$version" >> "$GITHUB_OUTPUT"
echo "release_tag=v${version}" >> "$GITHUB_OUTPUT"

Expand All @@ -67,6 +59,7 @@ jobs:
echo "owner=$lower_owner" >> "$GITHUB_OUTPUT"

verify:
needs: prepare
name: Verify Bun / TypeScript / Coverage
runs-on: ubuntu-latest
timeout-minutes: 20
Expand Down Expand Up @@ -107,9 +100,38 @@ jobs:
- name: Build Next.js app
run: bun run build

commit_version:
needs:
- prepare
- verify
runs-on: ubuntu-latest
outputs:
commit_sha: ${{ steps.commit.outputs.commit_sha }}
steps:
- name: Checkout repository
uses: actions/checkout@v7
with:
fetch-depth: 0

- name: Commit package version
id: commit
shell: bash
env:
VERSION: ${{ needs.prepare.outputs.version }}
run: |
set -euo pipefail
node -e "const fs=require('fs'); const path='package.json'; const pkg=JSON.parse(fs.readFileSync(path,'utf8')); pkg.version=process.argv[1]; fs.writeFileSync(path, JSON.stringify(pkg,null,2)+'\\n');" "$VERSION"
git config user.name 'github-actions[bot]'
git config user.email '41898282+github-actions[bot]@users.noreply.github.com'
git add package.json
git commit -m "chore: bump version to v${VERSION}"
git push origin "HEAD:${GITHUB_REF_NAME}"
echo "commit_sha=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT"

publish-image:
needs:
- prepare
- commit_version
- verify
name: Publish ${{ matrix.arch }} image
runs-on: ${{ matrix.runs_on }}
Expand All @@ -128,6 +150,8 @@ jobs:
steps:
- name: Checkout repository
uses: actions/checkout@v7
with:
ref: ${{ needs.commit_version.outputs.commit_sha }}

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4
Expand Down Expand Up @@ -204,6 +228,7 @@ jobs:
merge-image-manifests:
needs:
- prepare
- commit_version
- publish-image
name: Merge multi-arch manifests
runs-on: ubuntu-latest
Expand Down Expand Up @@ -269,6 +294,7 @@ jobs:
release:
needs:
- prepare
- commit_version
- merge-image-manifests
runs-on: ubuntu-latest
timeout-minutes: 15
Expand All @@ -278,6 +304,7 @@ jobs:
uses: actions/checkout@v7
with:
fetch-depth: 0
ref: ${{ needs.commit_version.outputs.commit_sha }}

- name: Create GitHub release
env:
Expand All @@ -291,10 +318,10 @@ jobs:
set -euo pipefail

latest_tag="$(git tag --list 'v*' --sort=-v:refname | grep -Fxv "${RELEASE_TAG}" | head -n 1 || true)"
commit_range="${GITHUB_SHA}"
commit_range="${{ needs.commit_version.outputs.commit_sha }}"

if [[ -n "${latest_tag}" ]]; then
commit_range="${latest_tag}..${GITHUB_SHA}"
commit_range="${latest_tag}..${{ needs.commit_version.outputs.commit_sha }}"
fi

commit_notes="$(git log "${commit_range}" --pretty=format:'- %s (%h)' || true)"
Expand All @@ -312,7 +339,7 @@ jobs:
release_notes="${release_notes}"$'\n\n'"## Commits"$'\n'"${commit_notes}"

gh release create "$RELEASE_TAG" \
--target "$GITHUB_SHA" \
--target "${{ needs.commit_version.outputs.commit_sha }}" \
--title "$RELEASE_TITLE" \
--latest \
--notes "$release_notes"
5 changes: 0 additions & 5 deletions .husky/pre-push
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,3 @@ set -eu
bun run lint
bun run format:check
bun run typecheck
bun run test:ci

base_sha="$(git merge-base HEAD origin/main)"
bun run test:patch-branches --base "$base_sha"
bun run build
1 change: 1 addition & 0 deletions app/credentials/credential-card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ export const CredentialCard = ({
return (
<Block
className="credential-card"
data-credential-filename={credential.filename}
direction="vertical"
gap={16}
padding={24}
Expand Down
25 changes: 25 additions & 0 deletions app/dashboard/dashboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { createContext, useContext } from 'react';

import type { AdminConsoleInitialData } from '@/app/page-data';
import type { AppMessages } from '@/lib/i18n/messages';
import packageJson from '@/package.json';

export interface DashboardSummary {
cacheHitTokens: number;
Expand Down Expand Up @@ -160,6 +161,30 @@ const Dashboard = () => {
</Block>
))}
</div>
<div className="dashboard-github-link">
<a
aria-label="orangeboyChen/codebuddy2api on GitHub"
className="dashboard-github-repository"
href="https://github.com/orangeboyChen/codebuddy2api"
rel="noreferrer"
target="_blank"
>
<svg
aria-hidden="true"
className="dashboard-github-icon"
height="18"
viewBox="0 0 24 24"
width="18"
>
<path
d="M12 2C6.477 2 2 6.477 2 12c0 4.418 2.865 8.166 6.839 9.49.5.092.682-.217.682-.482 0-.237-.009-1.024-.014-1.856-2.782.604-3.369-1.18-3.369-1.18-.455-1.156-1.11-1.464-1.11-1.464-.908-.62.069-.607.069-.607 1.004.07 1.532 1.031 1.532 1.031.892 1.529 2.341 1.087 2.91.832.091-.647.349-1.087.636-1.338-2.22-.253-4.555-1.11-4.555-4.943 0-1.091.39-1.984 1.029-2.683-.103-.253-.446-1.27.098-2.647 0 0 .84-.269 2.75 1.025A9.564 9.564 0 0 1 12 7.844a9.56 9.56 0 0 1 2.504.337c1.909-1.294 2.748-1.025 2.748-1.025.546 1.377.202 2.394.1 2.647.64.699 1.028 1.592 1.028 2.683 0 3.842-2.339 4.687-4.566 4.935.359.309.678.919.678 1.852 0 1.337-.012 2.415-.012 2.744 0 .267.18.578.688.48A10.003 10.003 0 0 0 22 12C22 6.477 17.523 2 12 2Z"
fill="currentColor"
/>
</svg>
<span>orangeboyChen/codebuddy2api</span>
</a>
<span className="dashboard-version">v{packageJson.version}</span>
</div>
</Flexbox>
);
};
Expand Down
35 changes: 35 additions & 0 deletions app/globals.scss
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,12 @@ textarea {
margin-left: 24px;
max-width: none;
min-width: 0;
overflow-x: auto;
scrollbar-width: none;
}

.admin-header-navigation::-webkit-scrollbar {
display: none;
}

.admin-header-navigation-compact {
Expand All @@ -205,6 +211,8 @@ textarea {
background: transparent !important;
border-color: transparent !important;
box-shadow: none !important;
flex: 0 0 auto;
white-space: nowrap;
}

.admin-header-tab[data-active] {
Expand All @@ -219,7 +227,9 @@ textarea {
}

.admin-header-controls {
flex: 0 0 auto;
margin-left: auto;
min-width: 0;
}

.admin-header-select > *:last-child {
Expand Down Expand Up @@ -312,6 +322,31 @@ textarea {
background: var(--lobe-color-fill);
}

.dashboard-github-link {
align-items: center;
align-self: center;
display: inline-flex;
gap: 8px;
justify-content: center;
}

.dashboard-github-repository {
align-items: center;
color: var(--lobe-color-text-secondary);
display: inline-flex;
gap: 8px;
transition: color 160ms ease;
}

.dashboard-github-repository:hover {
color: var(--lobe-color-text);
}

.dashboard-version {
color: var(--lobe-color-text);
font-variant-numeric: tabular-nums;
}

.account-status-card-busy {
opacity: 0.72;
}
Expand Down
2 changes: 1 addition & 1 deletion e2e/account-status.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ test.describe('Account Status tab', () => {
await context.grantPermissions(['clipboard-read', 'clipboard-write'], {
origin: 'http://127.0.0.1:8001',
});
const filename = 'account-status-copy.json';
const filename = `account-status-copy-${process.pid}.json`;
const createResponse = await page.request.post('/admin-api/credentials', {
data: {
bearer_token: 'e2e-token',
Expand Down
11 changes: 4 additions & 7 deletions e2e/admin-console.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { expect, test } from '@playwright/test';

const filename = 'admin-console-e2e.json';
const filename = `admin-console-e2e-${process.pid}.json`;
const json = (body: unknown) => ({
data: body,
headers: { 'Content-Type': 'application/json' },
Expand Down Expand Up @@ -165,12 +165,9 @@ test.describe('Admin console essentials', () => {
});
expect(createResponse.ok()).toBe(true);
await page.goto('/credentials');
const credentialCard = page
.locator('.credential-card')
.filter({
hasText: filename,
})
.last();
const credentialCard = page.locator(
`[data-credential-filename="${filename}"]`,
);
await expect(credentialCard).toBeVisible();
await credentialCard.getByRole('button', { name: 'Edit' }).click();
const saveButton = credentialCard.getByRole('button', {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "codebuddy2api",
"version": "2.0.0",
"version": "1.0.31",
"private": true,
"scripts": {
"dev": "next dev",
Expand Down
Loading