Skip to content

Commit 81e3c90

Browse files
HeZeBangGregTaooCNDY1390
authored
feat: revision date and hash (#45)
* feat: make search case-insensitive * fix: add autocomplete attributes to enable password autofill support (#42) * feat: revision date and footer (#44) * feat: revision date and hash * feat: workflow to create release * feat: different release * chore: v1.5.0 * fix: release quote --------- Co-authored-by: GregTao <gregtaoo@outlook.com> Co-authored-by: CNDY <60209538+CNDY1390@users.noreply.github.com>
1 parent cf8fce0 commit 81e3c90

File tree

5 files changed

+220
-3
lines changed

5 files changed

+220
-3
lines changed

.github/workflows/release.yml

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
name: Release on Package Update
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
- main
8+
- release
9+
paths:
10+
- 'package.json'
11+
12+
jobs:
13+
release:
14+
runs-on: ubuntu-latest
15+
permissions:
16+
contents: write
17+
steps:
18+
- name: Checkout repository
19+
uses: actions/checkout@v4
20+
21+
- name: Extract version from package.json
22+
id: version
23+
run: |
24+
VERSION=$(jq -r '.version' package.json)
25+
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
26+
echo "Extracted version: $VERSION"
27+
28+
- name: Generate release tag and metadata
29+
id: release_info
30+
run: |
31+
VERSION=${{ steps.version.outputs.VERSION }}
32+
COMMIT_HASH=$(git rev-parse --short HEAD)
33+
BRANCH=${{ github.ref_name }}
34+
BUILD_DATE=$(date +'%Y%m%d')
35+
36+
if [[ "$BRANCH" == "release" ]]; then
37+
TAG="v$VERSION"
38+
TITLE="v$VERSION"
39+
NOTES="Release v$VERSION"
40+
IS_PRERELEASE="false"
41+
IS_LATEST="true"
42+
else
43+
TAG="v$VERSION-pre.$BUILD_DATE.$COMMIT_HASH"
44+
TITLE="v$VERSION-pre ($COMMIT_HASH)"
45+
NOTES="Pre-release v$VERSION from branch: $BRANCH"$'\n'"Commit: $COMMIT_HASH"$'\n'"Build Date: $BUILD_DATE"
46+
IS_PRERELEASE="true"
47+
IS_LATEST="false"
48+
fi
49+
50+
echo "TAG=$TAG" >> $GITHUB_OUTPUT
51+
echo "TITLE=$TITLE" >> $GITHUB_OUTPUT
52+
echo "NOTES<<EOF" >> $GITHUB_OUTPUT
53+
echo "$NOTES" >> $GITHUB_OUTPUT
54+
echo "EOF" >> $GITHUB_OUTPUT
55+
echo "IS_PRERELEASE=$IS_PRERELEASE" >> $GITHUB_OUTPUT
56+
echo "IS_LATEST=$IS_LATEST" >> $GITHUB_OUTPUT
57+
echo "Generated tag: $TAG"
58+
59+
- name: Check if release already exists
60+
id: check_release
61+
run: |
62+
TAG=${{ steps.release_info.outputs.TAG }}
63+
if gh release view "$TAG" > /dev/null 2>&1; then
64+
echo "EXISTS=true" >> $GITHUB_OUTPUT
65+
else
66+
echo "EXISTS=false" >> $GITHUB_OUTPUT
67+
fi
68+
env:
69+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
70+
71+
- name: Create Release
72+
if: steps.check_release.outputs.EXISTS == 'false'
73+
run: |
74+
TAG="${{ steps.release_info.outputs.TAG }}"
75+
TITLE="${{ steps.release_info.outputs.TITLE }}"
76+
IS_PRERELEASE="${{ steps.release_info.outputs.IS_PRERELEASE }}"
77+
IS_LATEST="${{ steps.release_info.outputs.IS_LATEST }}"
78+
NOTES="${{ steps.release_info.outputs.NOTES }}"
79+
80+
# Build the gh release create command
81+
GH_CMD="gh release create '$TAG' --title '$TITLE'"
82+
83+
if [[ "$IS_PRERELEASE" == "true" ]]; then
84+
GH_CMD="$GH_CMD --prerelease"
85+
fi
86+
87+
if [[ "$IS_LATEST" == "true" ]]; then
88+
GH_CMD="$GH_CMD --latest"
89+
fi
90+
91+
GH_CMD="$GH_CMD --notes '$NOTES'"
92+
93+
eval "$GH_CMD"
94+
env:
95+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "coursebench-frontend",
3-
"version": "0.1.0",
3+
"version": "1.5.1",
44
"private": true,
55
"scripts": {
66
"serve": "vue-cli-service serve",

src/App.vue

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<InsiderBanner />
88
</div>
99
<div>
10-
<ActivityBanner :Enable="true">
10+
<ActivityBanner :Enable="false">
1111
OhMyGPA 论坛试运营! 访问 <a
1212
href="https://ohmygpa.icu/"
1313
target="_blank"
@@ -18,6 +18,7 @@
1818
</div>
1919

2020
<router-view :key="$route.path" class="mt-15 sm:mt-0" />
21+
<Footer />
2122
<v-snackbar
2223
v-model="snackbar.show"
2324
:color="snackbar.color"
@@ -40,6 +41,7 @@
4041
import Header from '@/components/global/Header';
4142
import InsiderBanner from '@/components/global/InsiderBanner';
4243
import ActivityBanner from '@/components/global/ActivityBanner';
44+
import Footer from '@/components/global/Footer';
4345
import useSnackbar from '@/composables/global/useSnackbar';
4446
import { getPreset } from '@/composables/global/useCookie';
4547
import { provide, reactive } from 'vue';
@@ -48,7 +50,7 @@ import MenuSideBar from '@/components/global/MenuSideBar.vue';
4850
4951
export default {
5052
name: 'App',
51-
components: { Header, InsiderBanner, ActivityBanner, MenuSideBar },
53+
components: { Header, InsiderBanner, ActivityBanner, MenuSideBar, Footer },
5254
setup() {
5355
const { snackbar } = useSnackbar();
5456
const global = reactive({

src/components/global/Footer.vue

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
<template>
2+
<footer class="footer-container">
3+
<div class="footer-content">
4+
<div class="footer-text">
5+
<span class="copyright">
6+
&copy; {{ currentYear }} CourseBench. All rights reserved.
7+
</span>
8+
<span class="version-info">
9+
v{{ version }}
10+
<span v-if="buildHash" class="build-hash">
11+
(Build: {{ buildHash }})
12+
</span>
13+
<a
14+
href="https://github.com/ShanghaitechGeekPie/coursebench-frontend/releases/latest"
15+
target="_blank"
16+
rel="noopener noreferrer"
17+
classname="inline-link"
18+
>更新日志</a>
19+
<span v-if="buildDate" class="build-date">
20+
构建日期: {{ buildDate }}
21+
</span>
22+
</span>
23+
</div>
24+
</div>
25+
</footer>
26+
</template>
27+
28+
<script>
29+
export default {
30+
name: 'Footer',
31+
setup() {
32+
const currentYear = new Date().getFullYear();
33+
const version = process.env.VUE_APP_VERSION || '0.1.0';
34+
const buildHash = process.env.VUE_APP_BUILD_HASH || '';
35+
const buildDate = process.env.VUE_APP_BUILD_DATE || '';
36+
37+
return {
38+
currentYear,
39+
version,
40+
buildHash,
41+
buildDate,
42+
};
43+
},
44+
};
45+
</script>
46+
47+
<style scoped>
48+
.footer-container {
49+
padding: 30px 20px;
50+
background-color: #f8f8f9;
51+
text-align: center;
52+
}
53+
54+
.footer-content {
55+
max-width: 1200px;
56+
margin: 0 auto;
57+
}
58+
59+
.footer-text {
60+
display: flex;
61+
flex-direction: column;
62+
gap: 8px;
63+
font-size: 0.875rem;
64+
color: rgba(0, 0, 0, 0.6);
65+
}
66+
67+
.copyright {
68+
font-weight: 500;
69+
}
70+
71+
.version-info {
72+
font-size: 0.8125rem;
73+
color: rgba(0, 0, 0, 0.5);
74+
a {
75+
color: inherit;
76+
}
77+
}
78+
79+
.build-hash {
80+
font-family: monospace;
81+
margin-left: 4px;
82+
}
83+
84+
.build-date {
85+
margin-left: 8px;
86+
}
87+
88+
/* Dark mode support */
89+
@media (prefers-color-scheme: dark) {
90+
.footer-container {
91+
background-color: #222222;
92+
}
93+
94+
.footer-text {
95+
color: rgba(255, 255, 255, 0.7);
96+
}
97+
98+
.version-info {
99+
color: rgba(255, 255, 255, 0.5);
100+
}
101+
}
102+
</style>

vue.config.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,24 @@ const productionGzipExtensions = /\.(js|css|json|md|html|ico)(\?.*)?$/i;
33
const path = require('path');
44
const process = require('process');
55
const fs = require('fs');
6+
const { execSync } = require('child_process');
7+
const packageJson = require('./package.json');
8+
9+
// Generate build hash (first 8 characters of git commit hash)
10+
let buildHash = '';
11+
try {
12+
buildHash = execSync('git rev-parse --short HEAD', { encoding: 'utf-8' }).trim().substring(0, 8);
13+
} catch (e) {
14+
buildHash = 'unknown';
15+
}
16+
17+
// Generate build date
18+
const buildDate = new Date().toISOString().split('T')[0];
19+
20+
// Set environment variables
21+
process.env.VUE_APP_VERSION = packageJson.version;
22+
process.env.VUE_APP_BUILD_HASH = buildHash;
23+
process.env.VUE_APP_BUILD_DATE = buildDate;
624

725
module.exports = {
826
productionSourceMap: false,

0 commit comments

Comments
 (0)