name: Build and Release on: push: tags: - "v*" permissions: contents: write env: FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: "true" jobs: release-mac-arm64: runs-on: macos-14 steps: - name: Check out git repository uses: actions/checkout@v5 with: fetch-depth: 0 - name: Install Node.js uses: actions/setup-node@v5 with: node-version: 24 cache: "npm" - name: Install Dependencies run: npm install - name: Sync version with tag shell: bash run: | VERSION=${GITHUB_REF_NAME#v} echo "Syncing package.json version to $VERSION" npm version $VERSION --no-git-tag-version --allow-same-version - name: Build Frontend & Type Check run: | npx tsc npx vite build - name: Package and Publish macOS arm64 (unsigned DMG) env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} CSC_IDENTITY_AUTO_DISCOVERY: "false" run: | npx electron-builder --mac dmg --arm64 --publish always release-linux: runs-on: ubuntu-latest steps: - name: Check out git repository uses: actions/checkout@v5 with: fetch-depth: 0 - name: Install Node.js uses: actions/setup-node@v5 with: node-version: 24 cache: "npm" - name: Install Dependencies run: npm install - name: Sync version with tag shell: bash run: | VERSION=${GITHUB_REF_NAME#v} echo "Syncing package.json version to $VERSION" npm version $VERSION --no-git-tag-version --allow-same-version - name: Build Frontend & Type Check run: | npx tsc npx vite build - name: Package and Publish Linux env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | npx electron-builder --linux --publish always release: runs-on: windows-latest steps: - name: Check out git repository uses: actions/checkout@v5 with: fetch-depth: 0 - name: Install Node.js uses: actions/setup-node@v5 with: node-version: 24 cache: 'npm' - name: Install Dependencies run: npm install - name: Sync version with tag shell: bash run: | VERSION=${GITHUB_REF_NAME#v} echo "Syncing package.json version to $VERSION" npm version $VERSION --no-git-tag-version --allow-same-version - name: Build Frontend & Type Check run: | npx tsc npx vite build - name: Package and Publish env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | npx electron-builder --publish always update-release-notes: runs-on: ubuntu-latest needs: - release-mac-arm64 - release-linux - release steps: - name: Generate release notes with platform download links env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} shell: bash run: | set -euo pipefail TAG="$GITHUB_REF_NAME" REPO="$GITHUB_REPOSITORY" RELEASE_PAGE="https://github.com/$REPO/releases/tag/$TAG" ASSETS_JSON="$(gh release view "$TAG" --repo "$REPO" --json assets)" pick_asset() { local pattern="$1" echo "$ASSETS_JSON" | jq -r --arg p "$pattern" '[.assets[].name | select(test($p))][0] // ""' } WINDOWS_ASSET="$(pick_asset "\\.exe$")" MAC_ASSET="$(pick_asset "\\.dmg$")" LINUX_DEB_ASSET="$(pick_asset "\\.deb$")" LINUX_TAR_ASSET="$(pick_asset "\\.tar\\.gz$")" LINUX_APPIMAGE_ASSET="$(pick_asset "\\.AppImage$")" build_link() { local name="$1" if [ -n "$name" ]; then echo "https://github.com/$REPO/releases/download/$TAG/$name" fi } WINDOWS_URL="$(build_link "$WINDOWS_ASSET")" MAC_URL="$(build_link "$MAC_ASSET")" LINUX_DEB_URL="$(build_link "$LINUX_DEB_ASSET")" LINUX_TAR_URL="$(build_link "$LINUX_TAR_ASSET")" LINUX_APPIMAGE_URL="$(build_link "$LINUX_APPIMAGE_ASSET")" cat > release_notes.md < 如果某个平台链接暂时未生成,可进入完整发布页查看全部资源:$RELEASE_PAGE EOF gh release edit "$TAG" --repo "$REPO" --notes-file release_notes.md