Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
176 changes: 0 additions & 176 deletions .github/workflows/prod-build.yaml

This file was deleted.

152 changes: 152 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
name: Release

on:
push:
branches:
- main

permissions:
contents: write
issues: write
pull-requests: write

jobs:
release:
name: Semantic Release
runs-on: ubuntu-latest
outputs:
new_release_published: ${{ steps.semantic.outputs.new_release_published }}
new_release_version: ${{ steps.semantic.outputs.new_release_version }}
new_release_git_tag: ${{ steps.semantic.outputs.new_release_git_tag }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
persist-credentials: false

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 'lts/*'

- name: Install dependencies
run: |
corepack enable
yarn install --immutable

- name: Semantic Release
id: semantic
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: yarn release

build-and-deploy:
name: Build & Deploy
needs: release
if: needs.release.outputs.new_release_published == 'true'
runs-on: ubuntu-latest
env:
VERSION: ${{ needs.release.outputs.new_release_version }}
GIT_TAG: ${{ needs.release.outputs.new_release_git_tag }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ needs.release.outputs.new_release_git_tag }}

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Login to registry.sciol.ac.cn
uses: docker/login-action@v3
with:
registry: registry.sciol.ac.cn
username: ${{ secrets.SCIENCEOL_REGISTRY_USERNAME }}
password: ${{ secrets.SCIENCEOL_REGISTRY_PASSWORD }}

- name: Build and push Service image
uses: docker/build-push-action@v6
with:
context: ./service
push: true
build-args: |
XYZEN_VERSION=${{ env.VERSION }}
XYZEN_COMMIT_SHA=${{ github.sha }}
XYZEN_BUILD_TIME=${{ github.event.head_commit.timestamp }}
tags: |
registry.sciol.ac.cn/sciol/xyzen-service:latest
registry.sciol.ac.cn/sciol/xyzen-service:${{ env.VERSION }}
registry.sciol.ac.cn/sciol/xyzen-service:${{ env.GIT_TAG }}

- name: Build and push Web image
uses: docker/build-push-action@v6
with:
context: ./web
push: true
tags: |
registry.sciol.ac.cn/sciol/xyzen-web:latest
registry.sciol.ac.cn/sciol/xyzen-web:${{ env.VERSION }}
registry.sciol.ac.cn/sciol/xyzen-web:${{ env.GIT_TAG }}

- name: Set up kubeconfig
env:
KUBE_CONFIG: ${{ secrets.SCIENCEOL_ACR_KUBE_CONFIG }}
run: |
mkdir -p ~/.kube
echo "$KUBE_CONFIG" > ~/.kube/config
chmod 600 ~/.kube/config

- name: Deploy to Kubernetes
run: |
kubectl -n bohrium set image deployment/xyzen *=registry.sciol.ac.cn/sciol/xyzen-service:${{ env.VERSION }}
kubectl -n bohrium set image deployment/xyzen-celery *=registry.sciol.ac.cn/sciol/xyzen-service:${{ env.VERSION }}
kubectl -n sciol set image deployment/xyzen *=registry.sciol.ac.cn/sciol/xyzen-service:${{ env.VERSION }}
kubectl -n sciol set image deployment/xyzen-web *=registry.sciol.ac.cn/sciol/xyzen-web:${{ env.VERSION }}

- name: Deployment Summary
run: |
echo "## 🚀 Deployment Complete" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "| Component | Image |" >> $GITHUB_STEP_SUMMARY
echo "|-----------|-------|" >> $GITHUB_STEP_SUMMARY
echo "| Service | \`registry.sciol.ac.cn/sciol/xyzen-service:${{ env.VERSION }}\` |" >> $GITHUB_STEP_SUMMARY
echo "| Web | \`registry.sciol.ac.cn/sciol/xyzen-web:${{ env.VERSION }}\` |" >> $GITHUB_STEP_SUMMARY

notify:
name: Notify
needs: [release, build-and-deploy]
if: always() && needs.release.outputs.new_release_published == 'true'
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Send notification
uses: ./.github/actions/email-notification
with:
status: ${{ needs.build-and-deploy.result }}
smtp_server: smtp.feishu.cn
smtp_port: 465
smtp_user: ${{ secrets.SMTP_USER }}
smtp_pass: ${{ secrets.SMTP_PASS }}
recipient: ${{ secrets.SMTP_RECEIVER }}
architecture: 'amd64'
pr_number: 'N/A'
pr_title: 'Release ${{ needs.release.outputs.new_release_git_tag }}'
pr_url: '${{ github.server_url }}/${{ github.repository }}/releases/tag/${{ needs.release.outputs.new_release_git_tag }}'
head_ref: ${{ github.ref_name }}
base_ref: 'main'
repo: ${{ github.repository }}
run_id: ${{ github.run_id }}
build_start: ${{ github.event.head_commit.timestamp }}
build_end: ${{ github.event.head_commit.timestamp }}
build_duration: 'N/A'
commit_author: ${{ github.event.head_commit.author.name }}
commit_email: ${{ github.event.head_commit.author.email }}
commit_message: 'Release ${{ needs.release.outputs.new_release_version }}'
commit_sha: ${{ github.sha }}
commit_sha_short: ${{ github.sha }}
commit_date: ${{ github.event.head_commit.timestamp }}
service_image: 'registry.sciol.ac.cn/sciol/xyzen-service:${{ needs.release.outputs.new_release_version }}'
web_image: 'registry.sciol.ac.cn/sciol/xyzen-web:${{ needs.release.outputs.new_release_version }}'
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ dist/
.next-server/
.nuxt/
.cache/
.yarn/

# ===== Next.js 项目 =====
next-env.d.ts
Expand Down
12 changes: 11 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,20 +1,30 @@
# Pre-commit hooks for both backend and frontend
# Run locally: uv run pre-commit run --all-files
# Install locally: uv run pre-commit install
# Install commit-msg hook: uv run pre-commit install --hook-type commit-msg
#
# REPO CHOICE GUIDE:
# - External repos (preferred): For tools that work in isolation (ruff, prettier)
# - Local repos (when needed): For tools requiring project dependencies/config (pyright, eslint, typescript)

repos:
# Commitlint - validate commit message format
- repo: https://github.com/alessandrojcm/commitlint-pre-commit-hook
rev: v9.21.0
hooks:
- id: commitlint
stages: [commit-msg]
additional_dependencies: ['@commitlint/config-conventional']
name: Commitlint (Conventional Commits)

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v6.0.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: check-added-large-files
args: ["--maxkb=1000"]
args: ['--maxkb=1000']
- id: check-merge-conflict
- id: mixed-line-ending

Expand Down
Loading
Loading