From 40c29e494c882027474ad5c374b3790f7af0800e Mon Sep 17 00:00:00 2001 From: cc <98377878+hicccc77@users.noreply.github.com> Date: Fri, 3 Apr 2026 19:49:43 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E9=85=8D=E7=BD=AE=E6=96=87?= =?UTF-8?q?=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/preview-nightly-main.yml | 103 ++++++++++++++++++--- 1 file changed, 88 insertions(+), 15 deletions(-) diff --git a/.github/workflows/preview-nightly-main.yml b/.github/workflows/preview-nightly-main.yml index 9ff6a19..5ccb22d 100644 --- a/.github/workflows/preview-nightly-main.yml +++ b/.github/workflows/preview-nightly-main.yml @@ -11,6 +11,7 @@ permissions: env: FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: "true" + FIXED_PREVIEW_TAG: nightly-preview ELECTRON_BUILDER_BINARIES_MIRROR: https://github.com/electron-userland/electron-builder-binaries/releases/download/ jobs: @@ -33,8 +34,6 @@ jobs: - name: Decide whether to build and generate preview version id: meta - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} shell: bash run: | set -euo pipefail @@ -52,14 +51,24 @@ jobs: BASE_VERSION="$(node -p "require('./package.json').version.split('-')[0]")" YEAR_2="$(TZ=Asia/Shanghai date +%y)" - EXISTING_COUNT="$(gh api --paginate "repos/${GITHUB_REPOSITORY}/releases" --jq "[.[].tag_name | select(test(\"^v${BASE_VERSION}-preview[.]${YEAR_2}[.][0-9]+$\"))] | length")" - NEXT_COUNT=$((EXISTING_COUNT + 1)) - PREVIEW_VERSION="${BASE_VERSION}-preview.${YEAR_2}.${NEXT_COUNT}" + PREVIEW_VERSION="${BASE_VERSION}-preview.${YEAR_2}.${GITHUB_RUN_NUMBER}" echo "should_build=$SHOULD_BUILD" >> "$GITHUB_OUTPUT" echo "preview_version=$PREVIEW_VERSION" >> "$GITHUB_OUTPUT" echo "Preview version: $PREVIEW_VERSION (commits in last 24h on main: $COMMITS_24H)" + - name: Ensure fixed preview prerelease exists + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + shell: bash + run: | + set -euo pipefail + if gh release view "$FIXED_PREVIEW_TAG" --repo "$GITHUB_REPOSITORY" >/dev/null 2>&1; then + gh release edit "$FIXED_PREVIEW_TAG" --repo "$GITHUB_REPOSITORY" --title "Preview Nightly Build" --prerelease + else + gh release create "$FIXED_PREVIEW_TAG" --repo "$GITHUB_REPOSITORY" --title "Preview Nightly Build" --notes "预览版发布页" --prerelease + fi + preview-mac-arm64: needs: prepare if: needs.prepare.outputs.should_build == 'true' @@ -88,15 +97,29 @@ jobs: npx tsc npx vite build - - name: Package and Publish macOS arm64 preview + - name: Package macOS arm64 preview artifacts env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} CSC_IDENTITY_AUTO_DISCOVERY: "false" shell: bash run: | export ELECTRON_BUILDER_BINARIES_MIRROR="https://github.com/electron-userland/electron-builder-binaries/releases/download/" echo "Using ELECTRON_BUILDER_BINARIES_MIRROR=$ELECTRON_BUILDER_BINARIES_MIRROR" - npx electron-builder --mac dmg --arm64 --publish always '--config.publish.releaseType=prerelease' '--config.publish.channel=preview' + npx electron-builder --mac dmg --arm64 --publish never '--config.publish.channel=preview' '--config.artifactName=${productName}-preview-arm64.${ext}' + + - name: Upload macOS arm64 assets to fixed preview release + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + shell: bash + run: | + assets=() + while IFS= read -r file; do + assets+=("$file") + done < <(find release -maxdepth 1 -type f | sort) + if [ "${#assets[@]}" -eq 0 ]; then + echo "No release files found in ./release" + exit 1 + fi + gh release upload "$FIXED_PREVIEW_TAG" "${assets[@]}" --repo "$GITHUB_REPOSITORY" --clobber preview-linux: needs: prepare @@ -126,11 +149,27 @@ jobs: npx tsc npx vite build - - name: Package and Publish Linux preview + - name: Package Linux preview artifacts env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + shell: bash run: | - npx electron-builder --linux --publish always '--config.publish.releaseType=prerelease' '--config.publish.channel=preview' + npx electron-builder --linux --publish never '--config.publish.channel=preview' '--config.artifactName=${productName}-preview-linux.${ext}' + + - name: Upload Linux assets to fixed preview release + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + shell: bash + run: | + assets=() + while IFS= read -r file; do + assets+=("$file") + done < <(find release -maxdepth 1 -type f | sort) + if [ "${#assets[@]}" -eq 0 ]; then + echo "No release files found in ./release" + exit 1 + fi + gh release upload "$FIXED_PREVIEW_TAG" "${assets[@]}" --repo "$GITHUB_REPOSITORY" --clobber preview-win-x64: needs: prepare @@ -160,11 +199,27 @@ jobs: npx tsc npx vite build - - name: Package and Publish Windows x64 preview + - name: Package Windows x64 preview artifacts env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + shell: bash run: | - npx electron-builder --win nsis --x64 --publish always '--config.publish.releaseType=prerelease' '--config.publish.channel=preview' '--config.artifactName=${productName}-${version}-x64-Setup.${ext}' + npx electron-builder --win nsis --x64 --publish never '--config.publish.channel=preview' '--config.artifactName=${productName}-preview-x64-Setup.${ext}' + + - name: Upload Windows x64 assets to fixed preview release + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + shell: bash + run: | + assets=() + while IFS= read -r file; do + assets+=("$file") + done < <(find release -maxdepth 1 -type f | sort) + if [ "${#assets[@]}" -eq 0 ]; then + echo "No release files found in ./release" + exit 1 + fi + gh release upload "$FIXED_PREVIEW_TAG" "${assets[@]}" --repo "$GITHUB_REPOSITORY" --clobber preview-win-arm64: needs: prepare @@ -194,11 +249,27 @@ jobs: npx tsc npx vite build - - name: Package and Publish Windows arm64 preview + - name: Package Windows arm64 preview artifacts env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + shell: bash run: | - npx electron-builder --win nsis --arm64 --publish always '--config.publish.releaseType=prerelease' '--config.publish.channel=preview-arm64' '--config.artifactName=${productName}-${version}-arm64-Setup.${ext}' + npx electron-builder --win nsis --arm64 --publish never '--config.publish.channel=preview-arm64' '--config.artifactName=${productName}-preview-arm64-Setup.${ext}' + + - name: Upload Windows arm64 assets to fixed preview release + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + shell: bash + run: | + assets=() + while IFS= read -r file; do + assets+=("$file") + done < <(find release -maxdepth 1 -type f | sort) + if [ "${#assets[@]}" -eq 0 ]; then + echo "No release files found in ./release" + exit 1 + fi + gh release upload "$FIXED_PREVIEW_TAG" "${assets[@]}" --repo "$GITHUB_REPOSITORY" --clobber update-preview-release-notes: needs: @@ -217,7 +288,8 @@ jobs: run: | set -euo pipefail - TAG="v${{ needs.prepare.outputs.preview_version }}" + TAG="$FIXED_PREVIEW_TAG" + CURRENT_PREVIEW_VERSION="${{ needs.prepare.outputs.preview_version }}" REPO="$GITHUB_REPOSITORY" RELEASE_PAGE="https://github.com/$REPO/releases/tag/$TAG" @@ -259,6 +331,7 @@ jobs: ## Preview Nightly 说明 - 该版本为 **预览版**,用于提前体验即将发布的功能与修复。 - 可能包含尚未完全稳定的改动,不建议长期使用 + - 当前版本号:\`$CURRENT_PREVIEW_VERSION\` ## 下载 - Windows x64: ${WINDOWS_URL:-$RELEASE_PAGE}