build: actiooo #4
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: Build & Release OpenGit | |
| on: | |
| push: | |
| tags: | |
| - 'v*' # 打 tag 自动触发 | |
| workflow_dispatch: # 手动触发 | |
| jobs: | |
| build: | |
| name: Build ${{ matrix.os }} | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| # - os: windows-latest | |
| # platform: windows-x64 | |
| # artifact_name: opengit-${{ github.ref_name }}-windows-x64.zip | |
| # binary: target/release/opengit.exe | |
| - os: ubuntu-latest | |
| platform: linux-x64 | |
| artifact_name: opengit-${{ github.ref_name }}-linux-x64.zip | |
| binary: target/release/opengit | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: 安装 Rust | |
| uses: dtolnay/rust-toolchain@stable | |
| with: | |
| components: rustfmt, clippy | |
| - name: 编译 Release | |
| run: cargo build --release | |
| # - name: 打包 Windows | |
| # if: matrix.os == 'windows-latest' | |
| # run: Compress-Archive -Path ${{ matrix.binary }} -DestinationPath ${{ matrix.artifact_name }} | |
| - name: 打包 Linux | |
| if: matrix.os == 'ubuntu-latest' | |
| run: zip -j ${{ matrix.artifact_name }} ${{ matrix.binary }} | |
| - name: 上传构建产物 | |
| uses: actions/upload-artifact@v4 | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }} | |
| with: | |
| name: ${{ matrix.artifact_name }} | |
| path: ${{ matrix.artifact_name }} | |
| # 自动创建 Release Draft 并上传所有文件 | |
| release: | |
| name: Create GitHub Release | |
| needs: build | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/download-artifact@v4 | |
| with: | |
| path: artifacts/ | |
| - name: 生成发布说明 | |
| run: | | |
| cat << EOF > RELEASE_NOTES.md | |
| ## 🎉 OpenGit ${{ github.ref_name }} | |
| 自动构建版本,支持一键打开 Git 仓库网页。 | |
| ### 下载 | |
| - Linux: opengit-${{ github.ref_name }}-linux-x64.zip | |
| EOF | |
| - name: 创建 Draft Release | |
| uses: softprops/action-gh-release@v1 | |
| with: | |
| body_path: RELEASE_NOTES.md | |
| draft: true | |
| prerelease: false | |
| files: artifacts/**/*.zip |