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
93 changes: 93 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
name: Release on Package Update

on:
push:
branches:
- master
- main
- release
paths:
- 'package.json'

jobs:
release:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Extract version from package.json
id: version
run: |
VERSION=$(jq -r '.version' package.json)
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
echo "Extracted version: $VERSION"

- name: Generate release tag and metadata
id: release_info
run: |
VERSION=${{ steps.version.outputs.VERSION }}
COMMIT_HASH=$(git rev-parse --short HEAD)
BRANCH=${{ github.ref_name }}
BUILD_DATE=$(date +'%Y%m%d')

if [[ "$BRANCH" == "release" ]]; then
TAG="v$VERSION"
TITLE="v$VERSION"
NOTES="Release v$VERSION"
IS_PRERELEASE="false"
IS_LATEST="true"
else
TAG="v$VERSION-pre.$BUILD_DATE.$COMMIT_HASH"
TITLE="v$VERSION-pre ($COMMIT_HASH)"
NOTES="Pre-release v$VERSION from branch: $BRANCH"$'\n'"Commit: $COMMIT_HASH"$'\n'"Build Date: $BUILD_DATE"
IS_PRERELEASE="true"
IS_LATEST="false"
fi

echo "TAG=$TAG" >> $GITHUB_OUTPUT
echo "TITLE=$TITLE" >> $GITHUB_OUTPUT
echo "NOTES<<EOF" >> $GITHUB_OUTPUT
echo "$NOTES" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
echo "IS_PRERELEASE=$IS_PRERELEASE" >> $GITHUB_OUTPUT
echo "IS_LATEST=$IS_LATEST" >> $GITHUB_OUTPUT
echo "Generated tag: $TAG"

- name: Check if release already exists
id: check_release
run: |
TAG=${{ steps.release_info.outputs.TAG }}
if gh release view "$TAG" > /dev/null 2>&1; then
echo "EXISTS=true" >> $GITHUB_OUTPUT
else
echo "EXISTS=false" >> $GITHUB_OUTPUT
fi
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Create Release
if: steps.check_release.outputs.EXISTS == 'false'
run: |
TAG=${{ steps.release_info.outputs.TAG }}
TITLE=${{ steps.release_info.outputs.TITLE }}
IS_PRERELEASE=${{ steps.release_info.outputs.IS_PRERELEASE }}
IS_LATEST=${{ steps.release_info.outputs.IS_LATEST }}

CREATE_ARGS="--title '$TITLE'"

if [[ "$IS_PRERELEASE" == "true" ]]; then
CREATE_ARGS="$CREATE_ARGS --prerelease"
fi

if [[ "$IS_LATEST" == "true" ]]; then
CREATE_ARGS="$CREATE_ARGS --latest"
fi

gh release create "$TAG" \
$CREATE_ARGS \
--notes "${{ steps.release_info.outputs.NOTES }}"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
6 changes: 4 additions & 2 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<InsiderBanner />
</div>
<div>
<ActivityBanner :Enable="true">
<ActivityBanner :Enable="false">
OhMyGPA 论坛试运营! 访问 <a
href="https://ohmygpa.icu/"
target="_blank"
Expand All @@ -18,6 +18,7 @@
</div>

<router-view :key="$route.path" class="mt-15 sm:mt-0" />
<Footer />
<v-snackbar
v-model="snackbar.show"
:color="snackbar.color"
Expand All @@ -40,6 +41,7 @@
import Header from '@/components/global/Header';
import InsiderBanner from '@/components/global/InsiderBanner';
import ActivityBanner from '@/components/global/ActivityBanner';
import Footer from '@/components/global/Footer';
import useSnackbar from '@/composables/global/useSnackbar';
import { getPreset } from '@/composables/global/useCookie';
import { provide, reactive } from 'vue';
Expand All @@ -48,7 +50,7 @@ import MenuSideBar from '@/components/global/MenuSideBar.vue';

export default {
name: 'App',
components: { Header, InsiderBanner, ActivityBanner, MenuSideBar },
components: { Header, InsiderBanner, ActivityBanner, MenuSideBar, Footer },
setup() {
const { snackbar } = useSnackbar();
const global = reactive({
Expand Down
94 changes: 94 additions & 0 deletions src/components/global/Footer.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
<template>
<footer class="footer-container">
<v-divider></v-divider>
<div class="footer-content pt-5">
<div class="footer-text">
<span class="copyright">
&copy; {{ currentYear }} CourseBench. All rights reserved.
</span>
<span class="version-info">
v{{ version }}
<span v-if="buildHash" class="build-hash">
(Build: {{ buildHash }})
</span>
<span v-if="buildDate" class="build-date">
Last build at: {{ buildDate }}
</span>
</span>
</div>
</div>
</footer>
</template>

<script>
export default {
name: 'Footer',
setup() {
const currentYear = new Date().getFullYear();
const version = process.env.VUE_APP_VERSION || '0.1.0';
const buildHash = process.env.VUE_APP_BUILD_HASH || '';
const buildDate = process.env.VUE_APP_BUILD_DATE || '';

return {
currentYear,
version,
buildHash,
buildDate,
};
},
};
</script>

<style scoped>
.footer-container {
padding: 30px 20px;
background-color: #f8f8f9;
text-align: center;
}

.footer-content {
max-width: 1200px;
margin: 0 auto;
}

.footer-text {
display: flex;
flex-direction: column;
gap: 8px;
font-size: 0.875rem;
color: rgba(0, 0, 0, 0.6);
}

.copyright {
font-weight: 500;
}

.version-info {
font-size: 0.8125rem;
color: rgba(0, 0, 0, 0.5);
}

.build-hash {
font-family: monospace;
margin-left: 4px;
}

.build-date {
margin-left: 8px;
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
.footer-container {
background-color: #222222;
}

.footer-text {
color: rgba(255, 255, 255, 0.7);
}

.version-info {
color: rgba(255, 255, 255, 0.5);
}
}
</style>
18 changes: 18 additions & 0 deletions vue.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,24 @@ const productionGzipExtensions = /\.(js|css|json|md|html|ico)(\?.*)?$/i;
const path = require('path');
const process = require('process');
const fs = require('fs');
const { execSync } = require('child_process');
const packageJson = require('./package.json');

// Generate build hash (first 8 characters of git commit hash)
let buildHash = '';
try {
buildHash = execSync('git rev-parse --short HEAD', { encoding: 'utf-8' }).trim().substring(0, 8);
} catch (e) {
buildHash = 'unknown';
}

// Generate build date
const buildDate = new Date().toISOString().split('T')[0];

// Set environment variables
process.env.VUE_APP_VERSION = packageJson.version;
process.env.VUE_APP_BUILD_HASH = buildHash;
process.env.VUE_APP_BUILD_DATE = buildDate;

module.exports = {
productionSourceMap: false,
Expand Down
Loading