Skip to content

Release

Release #54

Workflow file for this run

name: Release
on: workflow_dispatch
permissions:
contents: write
jobs:
release:
permissions:
contents: write
id-token: write
issues: write
pull-requests: write
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Using pnpm
uses: pnpm/action-setup@v3
with:
version: 9.3.0
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 20
cache: pnpm
- name: Install dependencies
run: pnpm install
- name: Check and fix vulnerabilities
run: pnpm audit --fix
- name: Build
run: pnpm build
- name: Publish
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GIT_AUTHOR_EMAIL: [email protected]
GIT_AUTHOR_NAME: release-bot
GIT_COMMITTER_EMAIL: [email protected]
GIT_COMMITTER_NAME: release-bot
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
run: pnpm release
deploy-benchmark-report:
needs: release
runs-on: ubuntu-latest
permissions:
contents: write
pages: write
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Using pnpm
uses: pnpm/action-setup@v3
with:
version: 9.3.0
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 20
cache: pnpm
- name: Install dependencies
run: pnpm install
- name: Run benchmark tests
run: pnpm benchmark:worker
- name: Create Reports Directory
run: |
mkdir -p gh-pages-deploy/benchmark-reports
cp -r worker-benchmark/benchmark-reports/* gh-pages-deploy/benchmark-reports/
# 创建索引页面 - 使用echo命令逐行添加内容而不是heredoc
echo '<!DOCTYPE html>' > gh-pages-deploy/benchmark-reports/index.html
echo '<html lang="zh-CN">' >> gh-pages-deploy/benchmark-reports/index.html
echo '<head>' >> gh-pages-deploy/benchmark-reports/index.html
echo ' <meta charset="UTF-8">' >> gh-pages-deploy/benchmark-reports/index.html
echo ' <meta name="viewport" content="width=device-width, initial-scale=1.0">' >> gh-pages-deploy/benchmark-reports/index.html
echo ' <title>Vue Styled Components 性能基准测试报告</title>' >> gh-pages-deploy/benchmark-reports/index.html
echo ' <style>' >> gh-pages-deploy/benchmark-reports/index.html
echo ' body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; max-width: 1000px; margin: 0 auto; padding: 20px; line-height: 1.6; }' >> gh-pages-deploy/benchmark-reports/index.html
echo ' h1 { color: #2c3e50; }' >> gh-pages-deploy/benchmark-reports/index.html
echo ' .report-list { list-style: none; padding: 0; }' >> gh-pages-deploy/benchmark-reports/index.html
echo ' .report-item { margin-bottom: 10px; padding: 15px; border-radius: 8px; background-color: #f8f9fa; box-shadow: 0 2px 4px rgba(0,0,0,0.1); }' >> gh-pages-deploy/benchmark-reports/index.html
echo ' .report-link { display: block; color: #3498db; font-weight: bold; text-decoration: none; }' >> gh-pages-deploy/benchmark-reports/index.html
echo ' .report-link:hover { text-decoration: underline; }' >> gh-pages-deploy/benchmark-reports/index.html
echo ' .report-date { color: #7f8c8d; font-size: 0.9em; margin-top: 5px; }' >> gh-pages-deploy/benchmark-reports/index.html
echo ' </style>' >> gh-pages-deploy/benchmark-reports/index.html
echo '</head>' >> gh-pages-deploy/benchmark-reports/index.html
echo '<body>' >> gh-pages-deploy/benchmark-reports/index.html
echo ' <h1>Vue Styled Components 性能基准测试报告</h1>' >> gh-pages-deploy/benchmark-reports/index.html
echo ' <p>此页面列出了所有可用的性能基准测试报告。点击链接查看详细报告。</p>' >> gh-pages-deploy/benchmark-reports/index.html
echo ' <ul class="report-list" id="reportList">' >> gh-pages-deploy/benchmark-reports/index.html
echo ' <li>正在加载报告列表...</li>' >> gh-pages-deploy/benchmark-reports/index.html
echo ' </ul>' >> gh-pages-deploy/benchmark-reports/index.html
echo ' <script>' >> gh-pages-deploy/benchmark-reports/index.html
echo ' async function loadReports() {' >> gh-pages-deploy/benchmark-reports/index.html
echo ' const reportList = document.getElementById("reportList");' >> gh-pages-deploy/benchmark-reports/index.html
echo ' reportList.innerHTML = "";' >> gh-pages-deploy/benchmark-reports/index.html
echo ' try {' >> gh-pages-deploy/benchmark-reports/index.html
echo ' const response = await fetch(".");' >> gh-pages-deploy/benchmark-reports/index.html
echo ' const text = await response.text();' >> gh-pages-deploy/benchmark-reports/index.html
echo ' const parser = new DOMParser();' >> gh-pages-deploy/benchmark-reports/index.html
echo ' const doc = parser.parseFromString(text, "text/html");' >> gh-pages-deploy/benchmark-reports/index.html
echo ' const links = Array.from(doc.querySelectorAll("a")).filter(a => a.href.endsWith(".html") && a.href !== "index.html");' >> gh-pages-deploy/benchmark-reports/index.html
echo ' links.sort((a, b) => b.href.localeCompare(a.href));' >> gh-pages-deploy/benchmark-reports/index.html
echo ' if (links.length === 0) {' >> gh-pages-deploy/benchmark-reports/index.html
echo ' reportList.innerHTML = "<li>暂无可用报告</li>";' >> gh-pages-deploy/benchmark-reports/index.html
echo ' return;' >> gh-pages-deploy/benchmark-reports/index.html
echo ' }' >> gh-pages-deploy/benchmark-reports/index.html
echo ' links.forEach(link => {' >> gh-pages-deploy/benchmark-reports/index.html
echo ' const fileName = link.href.split("/").pop();' >> gh-pages-deploy/benchmark-reports/index.html
echo ' const dateMatch = fileName.match(/benchmark-report-(.*?)\.html/);' >> gh-pages-deploy/benchmark-reports/index.html
echo ' let dateStr = "";' >> gh-pages-deploy/benchmark-reports/index.html
echo ' if (dateMatch && dateMatch[1]) {' >> gh-pages-deploy/benchmark-reports/index.html
echo ' const timestamp = dateMatch[1].replace(/T/g, " ").replace(/-/g, ":");' >> gh-pages-deploy/benchmark-reports/index.html
echo ' try {' >> gh-pages-deploy/benchmark-reports/index.html
echo ' const date = new Date(timestamp);' >> gh-pages-deploy/benchmark-reports/index.html
echo ' dateStr = date.toLocaleString("zh-CN");' >> gh-pages-deploy/benchmark-reports/index.html
echo ' } catch(e) { dateStr = timestamp; }' >> gh-pages-deploy/benchmark-reports/index.html
echo ' }' >> gh-pages-deploy/benchmark-reports/index.html
echo ' const li = document.createElement("li");' >> gh-pages-deploy/benchmark-reports/index.html
echo ' li.className = "report-item";' >> gh-pages-deploy/benchmark-reports/index.html
echo ' li.innerHTML = `<a href="${fileName}" class="report-link">性能测试报告 - ${dateStr || fileName}</a><div class="report-date">生成于: ${dateStr || "未知时间"}</div>`;' >> gh-pages-deploy/benchmark-reports/index.html
echo ' reportList.appendChild(li);' >> gh-pages-deploy/benchmark-reports/index.html
echo ' });' >> gh-pages-deploy/benchmark-reports/index.html
echo ' } catch (error) {' >> gh-pages-deploy/benchmark-reports/index.html
echo ' reportList.innerHTML = "<li>加载报告列表失败</li>";' >> gh-pages-deploy/benchmark-reports/index.html
echo ' console.error("加载报告列表失败:", error);' >> gh-pages-deploy/benchmark-reports/index.html
echo ' }' >> gh-pages-deploy/benchmark-reports/index.html
echo ' }' >> gh-pages-deploy/benchmark-reports/index.html
echo ' document.addEventListener("DOMContentLoaded", loadReports);' >> gh-pages-deploy/benchmark-reports/index.html
echo ' </script>' >> gh-pages-deploy/benchmark-reports/index.html
echo '</body>' >> gh-pages-deploy/benchmark-reports/index.html
echo '</html>' >> gh-pages-deploy/benchmark-reports/index.html
- name: Deploy to GitHub Pages
uses: JamesIves/github-pages-deploy-action@v4
with:
folder: gh-pages-deploy
target-folder: benchmark-reports
clean: false
clean-exclude: |
!benchmark-reports/**/*
token: ${{ secrets.GITHUB_TOKEN }}
sync-beta:
runs-on: ubuntu-latest
needs: release
if: startsWith(github.ref, 'refs/heads/beta')
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Sync
env:
ACCESS_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git checkout main
git pull --rebase origin beta
git push -f
sync-alpha:
runs-on: ubuntu-latest
needs: release
if: startsWith(github.ref, 'refs/heads/alpha')
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Sync
env:
ACCESS_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git checkout main
git pull --rebase origin alpha
git push -f