Skip to content

Commit 0804245

Browse files
committed
feat: automate frontend releases
1 parent ce4af66 commit 0804245

11 files changed

Lines changed: 132 additions & 4 deletions

File tree

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: Release Please
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
workflow_dispatch:
8+
9+
permissions:
10+
actions: write
11+
contents: write
12+
pull-requests: write
13+
14+
concurrency:
15+
group: release-${{ github.ref }}
16+
cancel-in-progress: false
17+
18+
jobs:
19+
release:
20+
runs-on: ubuntu-latest
21+
timeout-minutes: 30
22+
steps:
23+
- id: release
24+
uses: googleapis/release-please-action@v4
25+
with:
26+
config-file: release-please-config.json
27+
manifest-file: .release-please-manifest.json
28+
29+
- name: Merge release pull request
30+
if: ${{ steps.release.outputs.prs_created == 'true' }}
31+
env:
32+
GH_TOKEN: ${{ github.token }}
33+
RELEASE_PR: ${{ fromJSON(steps.release.outputs.pr).number }}
34+
run: |
35+
for attempt in {1..120}; do
36+
if gh pr merge "$RELEASE_PR" --squash --delete-branch; then
37+
break
38+
fi
39+
if [[ "$attempt" -eq 120 ]]; then
40+
echo "Timed out waiting for release PR #$RELEASE_PR to merge" >&2
41+
exit 1
42+
fi
43+
sleep 10
44+
done
45+
gh workflow run release-please.yml --ref main

.release-please-manifest.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
".": "2.4.0"
3+
}

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Changelog
2+
3+
此文件由 Release Please 根据 Conventional Commits 自动维护。

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,14 @@ pnpm install
2626
pnpm dev
2727
```
2828

29+
The frontend version comes from `package.json`. Production builds also embed the
30+
current Git commit. CI can override these values with `VITE_APP_VERSION` and
31+
`VITE_GIT_COMMIT`.
32+
33+
Releases are managed by Release Please. Use Conventional Commits such as
34+
`feat:` and `fix:`; the workflow automatically merges its release pull request,
35+
updates the version and changelog, and creates a `vX.Y.Z` tag.
36+
2937
### Type-Check, Compile and Minify for Production
3038

3139
```sh

env.d.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
11
/// <reference types="vite/client" />
2+
3+
declare const __APP_VERSION__: string
4+
declare const __GIT_COMMIT__: string

release-please-config.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"$schema": "https://raw.githubusercontent.com/googleapis/release-please/main/schemas/config.json",
3+
"packages": {
4+
".": {
5+
"release-type": "node",
6+
"package-name": "filecodebox-frontend",
7+
"include-component-in-tag": false,
8+
"changelog-path": "CHANGELOG.md"
9+
}
10+
}
11+
}

src/i18n/locales/en-US.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,8 @@ export default {
7373
lastUpdated: 'Last updated: {time}',
7474
loadFailed: 'Failed to load dashboard data',
7575
footerProduct: 'FileCodeBox Admin Console',
76-
runtimeVersion: 'Runtime Version',
76+
backendVersion: 'Server Version',
77+
frontendVersion: 'Frontend Version',
7778
versionPending: 'Pending sync',
7879
fileHealth: 'File Health',
7980
fileHealthDesc: 'Status insights for available, risky, and pending file queues.',

src/i18n/locales/zh-CN.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,8 @@ export default {
7373
lastUpdated: '最近更新:{time}',
7474
loadFailed: '仪表盘数据加载失败',
7575
footerProduct: 'FileCodeBox 管理后台',
76-
runtimeVersion: '运行版本',
76+
backendVersion: '服务端版本',
77+
frontendVersion: '前端版本',
7778
versionPending: '待同步',
7879
fileHealth: '文件健康',
7980
fileHealthDesc: '基于状态洞察统计可取件、风险与待处理队列。',

src/utils/build-info.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
const abbreviatedCommit = __GIT_COMMIT__.slice(0, 12)
2+
3+
export const buildInfo = Object.freeze({
4+
version: __APP_VERSION__,
5+
commit: abbreviatedCommit,
6+
displayVersion:
7+
abbreviatedCommit && abbreviatedCommit !== 'unknown'
8+
? `${__APP_VERSION__} (${abbreviatedCommit})`
9+
: __APP_VERSION__
10+
})

src/views/manage/DashboardView.vue

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -223,8 +223,8 @@
223223
:class="[isDarkMode ? 'border-gray-800 text-gray-500' : 'border-gray-200 text-gray-500']"
224224
>
225225
<span>{{ t('admin.dashboard.footerProduct') }}</span>
226-
<span class="inline-flex items-center gap-2">
227-
<span>{{ t('admin.dashboard.runtimeVersion') }}</span>
226+
<span class="flex flex-wrap items-center justify-end gap-2">
227+
<span>{{ t('admin.dashboard.backendVersion') }}</span>
228228
<span
229229
class="rounded-md border px-2 py-0.5 font-medium"
230230
:class="[
@@ -235,6 +235,17 @@
235235
>
236236
{{ versionText }}
237237
</span>
238+
<span>{{ t('admin.dashboard.frontendVersion') }}</span>
239+
<span
240+
class="rounded-md border px-2 py-0.5 font-medium"
241+
:class="[
242+
isDarkMode
243+
? 'border-gray-700 bg-gray-800/70 text-gray-300'
244+
: 'border-gray-200 bg-white text-gray-700'
245+
]"
246+
>
247+
{{ buildInfo.displayVersion }}
248+
</span>
238249
</span>
239250
</footer>
240251
</div>
@@ -263,6 +274,7 @@ import { useI18n } from 'vue-i18n'
263274
import { ROUTES } from '@/constants'
264275
import { useConfigStore } from '@/stores/configStore'
265276
import type { DashboardHealthAction } from '@/types'
277+
import { buildInfo } from '@/utils/build-info'
266278
267279
const isDarkMode = useInjectedDarkMode()
268280
const { t } = useI18n()

0 commit comments

Comments
 (0)