name: Publish Release on: push: branches: - main # 在同一个工作流中处理发布任务 concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true permissions: contents: write issues: write pull-requests: write jobs: publish: runs-on: windows-latest steps: - name: Checkout code uses: actions/checkout@v4 with: fetch-depth: 0 token: ${{ secrets.GITHUB_TOKEN }} - name: Setup Node.js uses: actions/setup-node@v4 with: node-version: '20' - name: Configure Git to use HTTPS instead of SSH run: | git config --global url."https://github.com/".insteadOf git@github.com: git config --global url."https://".insteadOf git:// - name: Setup pnpm uses: pnpm/action-setup@v4 with: version: 9 run_install: | - recursive: true args: [--frozen-lockfile=false] cache: 'pnpm' - name: Install dependencies run: pnpm install --no-frozen-lockfile env: NPM_CONFIG_LEGACY_PEER_DEPS: true - name: Setup Git user run: | git config --global user.name 'github-actions[bot]' git config --global user.email 'github-actions[bot]@users.noreply.github.com' - name: Bump version and generate changelog shell: bash run: | # 根据 commit 信息自动更新版本和生成 changelog pnpm release # 获取新版本号 version=$(node -p "require('./package.json').version") echo "VERSION=$version" >> $GITHUB_ENV echo "Version set to: $version" - name: Push changes run: | git push origin main git tag "v${{ env.VERSION }}" git push origin "v${{ env.VERSION }}" - name: Build for Windows run: | pnpm build:win env: # 禁用 Windows 代码签名 WIN_CSC_KEY_PASSWORD: '' # GitHub token 用于发布 GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Create GitHub Release uses: softprops/action-gh-release@v2 with: tag_name: v${{ env.VERSION }} name: Release v${{ env.VERSION }} # body_path: CHANGELOG.md draft: false prerelease: false files: | release/**/*.exe release/**/*.exe.blockmap release/**/latest.yml release/**/app-update.yml env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # - name: Create GitHub Release # uses: softprops/action-gh-release@v2 # with: # tag_name: v${{ env.VERSION }} # name: Release v${{ env.VERSION }} # body_path: CHANGELOG.md # draft: false # prerelease: false # files: | # release/${{ env.VERSION }}/* # env: # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}