fix: v1.12.2 — 修复自动更新检查 Object has been destroyed #49
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Release | |
| on: | |
| push: | |
| tags: | |
| - 'v*.*.*' | |
| workflow_dispatch: | |
| permissions: | |
| contents: write | |
| jobs: | |
| version-check: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Verify tag matches package.json | |
| if: startsWith(github.ref, 'refs/tags/') | |
| run: | | |
| PKG_VERSION=$(node -p "require('./package.json').version") | |
| TAG_VERSION="${GITHUB_REF_NAME#v}" | |
| echo "package.json: $PKG_VERSION" | |
| echo "tag : $TAG_VERSION" | |
| if [ "$PKG_VERSION" != "$TAG_VERSION" ]; then | |
| echo "::error::package.json version ($PKG_VERSION) does not match tag ($TAG_VERSION)" | |
| exit 1 | |
| fi | |
| build: | |
| needs: version-check | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - { os: macos-latest, target: mac, name: mac } | |
| - { os: windows-latest, target: win, name: win } | |
| runs-on: ${{ matrix.os }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Setup pnpm | |
| uses: pnpm/action-setup@v4 | |
| with: | |
| version: 9.4.0 | |
| - name: Setup Node | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 20 | |
| cache: pnpm | |
| - name: Install | |
| run: pnpm install --frozen-lockfile=false | |
| - name: Typecheck | |
| run: pnpm typecheck | |
| - name: Test | |
| run: pnpm test | |
| - name: Build (macOS) | |
| if: matrix.target == 'mac' | |
| env: | |
| CSC_IDENTITY_AUTO_DISCOVERY: 'false' | |
| run: | | |
| pnpm build | |
| # Build each arch in a SEPARATE electron-builder invocation. | |
| # When --x64 --arm64 are passed together, electron-builder builds both | |
| # DMGs concurrently; on macOS arm64 runners both try to mount a volume | |
| # named "Codex Switch <version>" at the same time, causing hdiutil | |
| # detach failures and background.tiff FileNotFoundError (APFS mode). | |
| # Sequential invocations avoid the volume-name collision entirely. | |
| build_arch() { | |
| local arch=$1 | |
| for i in 1 2 3; do | |
| echo "::group::electron-builder $arch attempt $i" | |
| if npx electron-builder --mac --${arch} --publish never; then | |
| echo "::endgroup::" | |
| return 0 | |
| fi | |
| echo "::endgroup::" | |
| if [ "$i" = "3" ]; then return 1; fi | |
| echo "Build $arch attempt $i failed; cleaning and retrying..." | |
| rm -rf release/mac* /tmp/t-* 2>/dev/null || true | |
| sleep 10 | |
| done | |
| } | |
| build_arch arm64 | |
| sleep 5 | |
| build_arch x64 | |
| - name: Build (Windows) | |
| if: matrix.target == 'win' | |
| shell: bash | |
| run: | | |
| pnpm build | |
| # GitHub artifact mirror occasionally returns 502 on nsis-resources; | |
| # retry up to 3 times before giving up. | |
| for i in 1 2 3; do | |
| echo "::group::electron-builder attempt $i" | |
| if npx electron-builder --win --x64 --arm64 --publish never; then | |
| echo "::endgroup::" | |
| break | |
| fi | |
| echo "::endgroup::" | |
| if [ "$i" = "3" ]; then exit 1; fi | |
| echo "Build attempt $i failed; cleaning and retrying..." | |
| rm -rf release/ 2>/dev/null || true | |
| sleep 15 | |
| done | |
| - name: List release artifacts | |
| shell: bash | |
| run: ls -lh release/ || true | |
| - name: Upload artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: release-${{ matrix.name }} | |
| path: | | |
| release/*.dmg | |
| release/*.exe | |
| release/*.zip | |
| release/*.yml | |
| release/*.blockmap | |
| if-no-files-found: error | |
| retention-days: 7 | |
| publish: | |
| needs: build | |
| runs-on: ubuntu-latest | |
| if: startsWith(github.ref, 'refs/tags/') | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Download all artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| path: artifacts | |
| - name: Flatten artifacts | |
| run: | | |
| mkdir -p release | |
| find artifacts -type f \( -name '*.dmg' -o -name '*.exe' -o -name '*.zip' -o -name '*.yml' -o -name '*.blockmap' \) -exec cp -v {} release/ \; | |
| ls -lh release/ | |
| - name: Create / update GitHub Release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: ${{ github.ref_name }} | |
| name: ${{ github.ref_name }} | |
| draft: false | |
| prerelease: false | |
| generate_release_notes: true | |
| fail_on_unmatched_files: true | |
| files: | | |
| release/*.dmg | |
| release/*.exe | |
| release/*.zip | |
| release/*.yml | |
| release/*.blockmap | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |