diff --git a/.github/workflows/release-simple.yml b/.github/workflows/release-simple.yml new file mode 100644 index 00000000..62d2c5e5 --- /dev/null +++ b/.github/workflows/release-simple.yml @@ -0,0 +1,135 @@ +name: 生成 Changelog 并发布版本 + +on: + workflow_dispatch: + push: + tags: + - 'v*' + +permissions: + contents: write + +jobs: + build-and-release: + name: 构建并发布版本 + runs-on: windows-latest + steps: + - name: Check out repository + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: 设置 git-cliff + uses: kenji-miyake/setup-git-cliff@v1 + + - name: 生成 changelog + id: generate-changelog + run: | + git cliff + + - name: Setup MSbuild + uses: microsoft/setup-msbuild@v2 + + - name: Setup NuGet + uses: NuGet/setup-nuget@v2.0.1 + + - name: Restore NuGet Packages + run: nuget restore "Ink Canvas.sln" + + - name: Build the Solution + run: | + msbuild -t:restore /p:GitFlow="Github Action" + msbuild /p:platform="Any CPU" /p:configuration="Release" /p:GitFlow="Github Action" "Ink Canvas/InkCanvasForClass.csproj" + + - name: 准备发布文件 + run: | + echo "准备发布目录..." + mkdir -p release + + # 复制构建产物到发布目录 + xcopy "Ink Canvas\bin\Any CPU\Release\net472\*" "release\" /E /I /Y + + echo "构建产物整理完成" + dir release + + - name: 计算 SHA256 值 + run: | + echo "开始计算SHA256校验值..." + cd release + echo "" > SHA256SUMS.txt + for /r %%f in (*) do ( + if not "%%~nxf"=="SHA256SUMS.txt" ( + echo "计算 %%~nxf 的SHA256值..." + certutil -hashfile "%%f" SHA256 | findstr /v "CertUtil" | findstr /v "SHA256" >> SHA256SUMS.txt + ) + ) + echo "SHA256校验值计算完成:" + type SHA256SUMS.txt + + - name: 验证 SHA256SUMS.txt 文件 + run: | + echo "验证SHA256SUMS.txt文件..." + cd release + if not exist "SHA256SUMS.txt" ( + echo "错误:在release目录中未找到SHA256SUMS.txt文件" + exit /b 1 + ) + for %%f in (SHA256SUMS.txt) do if %%~zf==0 ( + echo "错误:SHA256SUMS.txt文件为空" + exit /b 1 + ) + echo "SHA256SUMS.txt文件验证通过" + cd .. + + - name: 生成 需发布 的表格信息 + run: | + cd release + echo. >> ..\CHANGELOG.md + echo Full Changelog: [1.7.9.0...%GITHUB_REF_NAME%](https://github.com/InkCanvasForClass/community/compare/1.7.9.0...%GITHUB_REF_NAME%) >> ..\CHANGELOG.md + echo. >> ..\CHANGELOG.md + echo **国内 下载链接** >> ..\CHANGELOG.md + echo ^| 平台/打包方式 ^| 支持架构 ^| 完整版 ^| >> ..\CHANGELOG.md + echo ^| --- ^| --- ^| --- ^| >> ..\CHANGELOG.md + echo ^| Windows ^| Any CPU ^| [下载](https://icc.bliemhax.com) ^| >> ..\CHANGELOG.md + echo. >> ..\CHANGELOG.md + echo **Github 镜像 下载链接** >> ..\CHANGELOG.md + echo ^| 镜像源 ^| 平台/打包方式 ^| 支持架构 ^| 完整版 ^| >> ..\CHANGELOG.md + echo ^| --- ^| --- ^| --- ^| --- ^| >> ..\CHANGELOG.md + echo ^| ghfast.top ^| Windows 目录模式 ^| Any CPU ^| [下载 %GITHUB_REF_NAME%](https://ghfast.top/https://github.com/InkCanvasForClass/community/releases/download/%GITHUB_REF_NAME%/InkCanvasForClass.CE.%GITHUB_REF_NAME%.zip) ^| >> ..\CHANGELOG.md + echo ^| gh-proxy.com ^| Windows 目录模式 ^| Any CPU ^| [下载 %GITHUB_REF_NAME%](https://gh-proxy.com/https://github.com/InkCanvasForClass/community/releases/download/%GITHUB_REF_NAME%/InkCanvasForClass.CE.%GITHUB_REF_NAME%.zip) ^| >> ..\CHANGELOG.md + echo ^| bgithub.xyz ^| Windows 目录模式 ^| Any CPU ^| [下载 %GITHUB_REF_NAME%](https://bgithub.xyz/InkCanvasForClass/community/releases/download/%GITHUB_REF_NAME%/InkCanvasForClass.CE.%GITHUB_REF_NAME%.zip) ^| >> ..\CHANGELOG.md + echo ^| kkgithub.com ^| Windows 目录模式 ^| Any CPU ^| [下载 %GITHUB_REF_NAME%](https://kkgithub.com/InkCanvasForClass/community/releases/download/%GITHUB_REF_NAME%/InkCanvasForClass.CE.%GITHUB_REF_NAME%.zip) ^| >> ..\CHANGELOG.md + echo. >> ..\CHANGELOG.md + echo **SHA256 校验值-请核对下载的文件的SHA256值是否正确** >> ..\CHANGELOG.md + echo ^| 文件名 ^| SHA256 值 ^| >> ..\CHANGELOG.md + echo ^| --- ^| --- ^| >> ..\CHANGELOG.md + for /f "tokens=1,2" %%a in (SHA256SUMS.txt) do ( + echo ^| %%b ^| %%a ^| >> ..\CHANGELOG.md + ) + del SHA256SUMS.txt + cd .. + + - name: 确定发布类型 + id: release-type + run: | + if "%GITHUB_REF%" == *"beta"* ( + echo is_beta=true >> %GITHUB_ENV% + ) else if "%GITHUB_REF%" == *"alpha"* ( + echo is_beta=true >> %GITHUB_ENV% + ) else ( + echo is_beta=false >> %GITHUB_ENV% + ) + + - name: 发布 + uses: softprops/action-gh-release@v2 + with: + token: ${{ secrets.GITHUB_TOKEN }} + files: release/* + body_path: CHANGELOG.md + draft: false + prerelease: ${{ env.is_beta == 'true' }} + tag_name: ${{ github.ref_name }} + name: Ink Canvas CE 新版本 - ${{ github.ref_name }} + fail_on_unmatched_files: true + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/cliff.toml b/cliff.toml new file mode 100644 index 00000000..f84a9ee9 --- /dev/null +++ b/cliff.toml @@ -0,0 +1,57 @@ +# git-cliff configuration file +# https://git-cliff.org/docs/configuration + +[changelog] +# changelog header +header = "# Changelog\n\n" +# template for the changelog body +# https://keats.github.io/tera/docs/#introduction +body = """ +{% if version %}\ +## [{{ version }}] - {{ timestamp | date(format="%Y-%m-%d") }} +{% else %}\ +## [Unreleased] +{% endif %}\ +{% for group, commits in commits | group_by(attribute="group") %} +### {{ group | upper_first }} +{% for commit in commits %} +- {{ commit.message | upper_first }}{% if commit.scope %} *({{ commit.scope }})*{% endif %}{% if commit.breaking %} **BREAKING:** {{ commit.breaking_description }}{% endif %} +{% endfor %} +{% endfor %} +""" + +# template for the changelog footer +footer = "" + +# git-cliff internal behavior +[git] +# parse the commits using this regex +commit_parsers = [ + { message = "^feat", group = "Features" }, + { message = "^fix", group = "Bug Fixes" }, + { message = "^docs", group = "Documentation" }, + { message = "^style", group = "Styling" }, + { message = "^refactor", group = "Code Refactoring" }, + { message = "^perf", group = "Performance" }, + { message = "^test", group = "Tests" }, + { message = "^build", group = "Build System" }, + { message = "^ci", group = "Continuous Integration" }, + { message = "^chore", group = "Chores" }, + { message = "^revert", group = "Reverts" }, + { message = "^merge", group = "Merges" }, + { message = "^.*", group = "Other" }, +] +# protect breaking changes from being skipped due to matching a previous commit +protect_breaking_commits = false +# filter out the commits that are not matched by commit parsers +filter_commits = false +# glob pattern for matching tags +tag_pattern = "v[0-9]*" +# regex for skipping tags +skip_tags = "^v0\\.1\\.0$" +# regex for ignoring tags +ignore_tags = "" +# sort the tags topologically +topo_order = false +# sort the commits inside sections by date +sort_commits = "newest" \ No newline at end of file