Prepare Release #8
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: | |
| workflow_dispatch: | |
| inputs: | |
| release_type: | |
| description: "Release type" | |
| required: true | |
| default: "patch" | |
| type: choice | |
| options: | |
| - patch | |
| - minor | |
| - major | |
| permissions: | |
| contents: write | |
| jobs: | |
| prepare-release: | |
| runs-on: ubuntu-latest | |
| if: github.event_name == 'workflow_dispatch' | |
| outputs: | |
| new_tag: ${{ steps.get_tag.outputs.tag }} | |
| changelog: ${{ steps.extract_changelog.outputs.notes }} | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Setup pnpm | |
| uses: pnpm/action-setup@v4 | |
| with: | |
| version: "10" | |
| run_install: false | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: "20" | |
| cache: "pnpm" | |
| cache-dependency-path: "pnpm-lock.yaml" | |
| - name: Install dependencies | |
| run: pnpm install --frozen-lockfile | |
| - name: Configure Git | |
| run: | | |
| git config --global user.name "github-actions[bot]" | |
| git config --global user.email "github-actions[bot]@users.noreply.github.com" | |
| - name: Bump version (no commit/tag) | |
| run: pnpm dlx standard-version --release-as ${{ inputs.release_type }} --skip.tag --skip.commit | |
| - name: Sync Tauri version | |
| run: | | |
| node -e "const fs=require('fs');const pkg=require('./package.json');const path='src-tauri/tauri.conf.json';const conf=JSON.parse(fs.readFileSync(path,'utf8'));conf.version=pkg.version;fs.writeFileSync(path, JSON.stringify(conf,null,2)+'\\n');" | |
| - name: Commit and tag | |
| run: | | |
| VERSION=$(node -p "require('./package.json').version") | |
| git add package.json pnpm-lock.yaml CHANGELOG.md src-tauri/tauri.conf.json | |
| git commit -m "chore(release): v${VERSION}" | |
| git tag -a "v${VERSION}" -m "v${VERSION}" | |
| git push --follow-tags origin HEAD:main | |
| - name: Get new tag | |
| id: get_tag | |
| run: | | |
| TAG=$(git describe --tags --abbrev=0) | |
| echo "tag=$TAG" >> $GITHUB_OUTPUT | |
| echo "Generated new tag: $TAG" | |
| - name: Extract Changelog | |
| id: extract_changelog | |
| run: | | |
| CHANGELOG_CONTENT=$(node .github/scripts/extract-changelog.js) | |
| echo "notes<<EOF" >> $GITHUB_OUTPUT | |
| echo "$CHANGELOG_CONTENT" >> $GITHUB_OUTPUT | |
| echo "EOF" >> $GITHUB_OUTPUT | |
| build-mac: | |
| needs: [prepare-release] | |
| strategy: | |
| matrix: | |
| include: | |
| - os: macos-15-intel | |
| arch: x64 | |
| - os: macos-latest | |
| arch: arm64 | |
| runs-on: ${{ matrix.os }} | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: ${{ needs.prepare-release.outputs.new_tag }} | |
| - name: Setup pnpm | |
| uses: pnpm/action-setup@v4 | |
| with: | |
| version: "10" | |
| run_install: false | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: "20" | |
| cache: "pnpm" | |
| cache-dependency-path: "pnpm-lock.yaml" | |
| - name: Setup Rust | |
| uses: dtolnay/rust-toolchain@stable | |
| - name: Install dependencies | |
| run: pnpm install --frozen-lockfile | |
| - name: Build macOS app | |
| run: pnpm tauri build | |
| - name: Rename macOS artifacts | |
| run: | | |
| VERSION=${{ needs.prepare-release.outputs.new_tag }} | |
| VERSION=${VERSION#v} | |
| DMG=$(ls src-tauri/target/release/bundle/dmg/*.dmg | head -n 1) | |
| mv "$DMG" "src-tauri/target/release/bundle/dmg/skills-manager-gui_${VERSION}_macos-${{ matrix.arch }}.dmg" | |
| - name: Upload macOS artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: mac-artifacts-${{ matrix.arch }} | |
| path: | | |
| src-tauri/target/release/bundle/dmg/skills-manager-gui_*.dmg | |
| if-no-files-found: error | |
| build-win: | |
| needs: [prepare-release] | |
| runs-on: windows-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: ${{ needs.prepare-release.outputs.new_tag }} | |
| - name: Setup pnpm | |
| uses: pnpm/action-setup@v4 | |
| with: | |
| version: "10" | |
| run_install: false | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: "20" | |
| cache: "pnpm" | |
| cache-dependency-path: "pnpm-lock.yaml" | |
| - name: Setup Rust | |
| uses: dtolnay/rust-toolchain@stable | |
| - name: Install dependencies | |
| run: pnpm install --frozen-lockfile | |
| - name: Build Windows app | |
| run: pnpm tauri build | |
| - name: Rename Windows artifacts | |
| shell: pwsh | |
| run: | | |
| $version = "${{ needs.prepare-release.outputs.new_tag }}".TrimStart("v") | |
| $msi = Get-ChildItem "src-tauri/target/release/bundle/msi" -Filter "*.msi" | Select-Object -First 1 | |
| if ($msi) { | |
| Rename-Item $msi.FullName (Join-Path $msi.DirectoryName "skills-manager-gui_${version}_windows-x64.msi") | |
| } | |
| $exe = Get-ChildItem "src-tauri/target/release/bundle/nsis" -Filter "*.exe" | Select-Object -First 1 | |
| if ($exe) { | |
| Rename-Item $exe.FullName (Join-Path $exe.DirectoryName "skills-manager-gui_${version}_windows-x64-setup.exe") | |
| } | |
| - name: Upload Windows artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: win-artifacts | |
| path: | | |
| src-tauri/target/release/bundle/msi/skills-manager-gui_*.msi | |
| src-tauri/target/release/bundle/nsis/skills-manager-gui_*.exe | |
| if-no-files-found: error | |
| release: | |
| needs: [prepare-release, build-mac, build-win] | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Download macOS artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| pattern: mac-artifacts-* | |
| merge-multiple: true | |
| path: artifacts | |
| - name: Download Windows artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: win-artifacts | |
| path: artifacts | |
| - name: Create GitHub Release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: ${{ needs.prepare-release.outputs.new_tag }} | |
| draft: false | |
| prerelease: false | |
| files: | | |
| artifacts/**/skills-manager-gui_*.dmg | |
| artifacts/**/skills-manager-gui_*.msi | |
| artifacts/**/skills-manager-gui_*.exe | |
| body: | | |
| ## 🎉 新版本发布! | |
| **注意:本项目暂无商业签名证书,安装时可能会提示安全警告。** | |
| ### 🍎 macOS 用户 | |
| 初次安装可能出现 “应用已损坏,无法打开” 或 “来自身份不明的开发者”。 | |
| 请打开「终端」执行: | |
| ```bash | |
| xattr -cr /Applications/skills-manager-gui.app | |
| ``` | |
| ### 🪟 Windows 用户 | |
| 1. 点击 “更多信息” | |
| 2. 点击 “仍要运行” | |
| --- | |
| ### 更新日志 | |
| ${{ needs.prepare-release.outputs.changelog }} | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |