From 2783fb4c0ec93796809d2bb918351bdb75db83b5 Mon Sep 17 00:00:00 2001 From: LOG1997 <2694233102@qq.com> Date: Wed, 31 Dec 2025 09:56:32 +0800 Subject: [PATCH] Release (#157) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * build: πŸ—οΈ ζž„ε»ΊδΈŽζ ‘ιͺŒ * build: πŸ—οΈ release.yml github action --- .github/workflows/release.yml | 55 ++++-------------------------- .husky/scripts/verifyTagVersion.js | 24 ++++++------- 2 files changed, 19 insertions(+), 60 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 940a0a0..8fee00e 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -51,26 +51,14 @@ jobs: with: name: web-build path: dist.zip - - - name: Prepare GitHub Pages artifact - run: | - cp -r dist-prod dist-gh-pages - - name: Upload GitHub Pages artifact - uses: actions/upload-artifact@v4 + - name: Deploy to gh-pages branch + uses: peaceiris/actions-gh-pages@v3 with: - name: github-pages - path: dist-gh-pages - - - name: Prepare GitHub Pages artifact - run: | - cp -r dist-prod dist-gh-pages - - - name: Upload GitHub Pages artifact - uses: actions/upload-artifact@v4 - with: - name: github-pages - path: dist-gh-pages + github_token: ${{ secrets.GITHUB_TOKEN }} + publish_dir: ./dist-prod + publish_branch: gh-pages + force_orphan: true publish-tauri: permissions: @@ -118,37 +106,8 @@ jobs: prerelease: false run: pnpm tauri build - deploy-gh-pages: - needs: build-web - runs-on: ubuntu-latest - permissions: - contents: read - pages: write - id-token: write - - environment: - name: github-pages - url: ${{ steps.deployment.outputs.page_url }} - - steps: - - name: Download GitHub Pages artifact - uses: actions/download-artifact@v4 - with: - name: github-pages - path: dist-gh-pages - - - name: Setup Pages - uses: actions/configure-pages@v3 - - - name: Upload to GitHub Pages - uses: actions/deploy-pages@v2 - id: deployment - with: - github_token: ${{ secrets.GITHUB_TOKEN }} - publish_dir: ./dist-gh-pages - release: - needs: [build-web, publish-tauri, deploy-gh-pages] + needs: [build-web, publish-tauri] runs-on: ubuntu-latest steps: - name: Checkout code diff --git a/.husky/scripts/verifyTagVersion.js b/.husky/scripts/verifyTagVersion.js index 6fa2fe0..736b78a 100644 --- a/.husky/scripts/verifyTagVersion.js +++ b/.husky/scripts/verifyTagVersion.js @@ -25,10 +25,10 @@ try { } else { console.log('βœ… Git tag η‰ˆζœ¬ζ ‘ιͺŒι€šθΏ‡'); } - + // θŽ·ε– tag ζŒ‡ε‘ηš„ζδΊ€ε“ˆεΈŒ const tagCommit = execSync(`git rev-list -1 ${tag}`, { encoding: 'utf-8' }).trim(); - + // θŽ·ε–ε½“ε‰εˆ†ζ”―εη§° let currentBranch; try { @@ -37,12 +37,12 @@ try { console.error('ζ— ζ³•θŽ·ε–ε½“ε‰εˆ†ζ”―εη§°'); process.exit(1); } - + console.log(`ε½“ε‰εˆ†ζ”―δΈΊ: ${currentBranch}`); // ζ£€ζŸ₯ε½“ε‰εˆ†ζ”―ζ˜―ε¦δΈΊ release εˆ†ζ”― - if (currentBranch.startsWith('release/')) { + if (currentBranch.startsWith('release')) { // ε¦‚ζžœε½“ε‰εœ¨ release εˆ†ζ”―δΈŠοΌŒζ£€ζŸ₯ε½“ε‰εˆ†ζ”―ηš„ HEAD 提亀是否与 tag ζŒ‡ε‘ηš„ζδΊ€δΈ€θ‡΄ const currentBranchCommit = execSync(`git rev-parse ${currentBranch}`, { encoding: 'utf-8' }).trim(); - + if (tagCommit !== currentBranchCommit) { console.log('🏷️ Git tag ζŒ‡ε‘ηš„ζδΊ€δΈŽε½“ε‰ release εˆ†ζ”―ηš„ζœ€ζ–°ζδΊ€δΈδΈ€θ‡΄'); console.error(`当前 release εˆ†ζ”― "${currentBranch}" ηš„ζœ€ζ–°ζδΊ€δΈΊ: ${currentBranchCommit}`); @@ -54,27 +54,27 @@ try { } else { // ε¦‚ζžœε½“ε‰δΈεœ¨ release εˆ†ζ”―δΈŠοΌŒζŸ₯ζ‰Ύζ‰€ζœ‰ release εˆ†ζ”―εΉΆζ£€ζŸ₯ζ˜―ε¦ζœ‰εˆ†ζ”―ηš„ HEAD 与 tag ζŒ‡ε‘ηš„ζδΊ€δΈ€θ‡΄ console.log(`πŸ” ε½“ε‰εœ¨ "${currentBranch}" εˆ†ζ”―οΌŒζ£€ζŸ₯ tag ζŒ‡ε‘ηš„ζδΊ€ζ˜―ε¦δΈŽδ»»δ½• release εˆ†ζ”―ηš„ζœ€ζ–°ζδΊ€δΈ€θ‡΄`); - + // θŽ·ε–ζ‰€ζœ‰ζœ¬εœ°εˆ†ζ”― const localBranchesOutput = execSync('git branch --format="%(refname:short)"', { encoding: 'utf-8' }); const localBranches = localBranchesOutput.split('\n').map(b => b.trim()).filter(b => b); - + // 过滀出 release εˆ†ζ”― const releaseBranches = localBranches.filter(branch => branch.startsWith('release/')); - + if (releaseBranches.length === 0) { console.log('⚠️ ζœͺζ‰Ύεˆ° release εˆ†ζ”―'); process.exit(1); } - + let foundMatchingBranch = false; let matchingBranchName = ''; - + for (const branch of releaseBranches) { try { // θŽ·ε– release εˆ†ζ”―ηš„ζœ€ζ–°ζδΊ€ const releaseBranchCommit = execSync(`git rev-parse ${branch}`, { encoding: 'utf-8' }).trim(); - + // ζ£€ζŸ₯是否与 tag ζŒ‡ε‘ηš„ζδΊ€δΈ€θ‡΄ if (tagCommit === releaseBranchCommit) { foundMatchingBranch = true; @@ -86,7 +86,7 @@ try { continue; } } - + if (!foundMatchingBranch) { console.log('🏷️ Git tag ζŒ‡ε‘ηš„ζδΊ€δΈŽδ»»δ½• release εˆ†ζ”―ηš„ζœ€ζ–°ζδΊ€ιƒ½δΈδΈ€θ‡΄'); console.error(`ζδΎ›ηš„ tag δΈΊ: ${tag}`);