ci: 自动发布 release(draft: false) #35
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: Build & Release | |
| on: | |
| push: | |
| branches: [main] | |
| tags: ['v*'] | |
| workflow_dispatch: | |
| jobs: | |
| build: | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - os: macos-latest | |
| platform: mac | |
| artifact: dmg | |
| - os: windows-latest | |
| platform: win | |
| artifact: exe | |
| - os: ubuntu-latest | |
| platform: linux | |
| artifact: appimage | |
| runs-on: ${{ matrix.os }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 22 | |
| cache: npm | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Build (electron-vite) | |
| run: npm run build | |
| - name: Prepare vendor/opencli | |
| run: | | |
| mkdir -p vendor/opencli | |
| npm run vendor:opencli | |
| - name: Package (electron-builder) | |
| run: npx electron-builder --publish never | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Upload artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: ${{ matrix.platform }}-${{ matrix.artifact }} | |
| path: | | |
| release/*.dmg | |
| release/*.exe | |
| release/*.AppImage | |
| release/*.yml | |
| if-no-files-found: warn | |
| retention-days: 30 | |
| release: | |
| if: startsWith(github.ref, 'refs/tags/') | |
| needs: build | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: Download all artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| path: artifacts | |
| # 自动发布:CI 构建完成后直接公开 release,electron-updater 立即可见。 | |
| - name: Create GitHub Release | |
| uses: ncipollo/release-action@v1 | |
| with: | |
| draft: false | |
| generateReleaseNotes: true | |
| artifacts: | | |
| artifacts/**/*.dmg | |
| artifacts/**/*.exe | |
| artifacts/**/*.AppImage | |
| artifacts/**/*.yml | |
| allowUpdates: true | |
| updateOnlyUnreleased: true |