chore: Update Cake and GitHub release automation.

This commit is contained in:
NaBian committed 2025-09-30 17:12:29 +08:00
1 parent 78e729fdc5
commit e0d72e1147
4 files changed
+39 -17

No files matched your search

+1 -1
View File
@@ -20,5 +20,5 @@ jobs:
working-directory: ./build
run: |
dotnet new tool-manifest
dotnet tool install cake.tool --version 4.0.0
dotnet tool install cake.tool --version 5.0.0
dotnet cake
+2 -11
View File
@@ -30,8 +30,8 @@ jobs:
git config --local user.name "${{ github.actor }}"
git config --local user.email "836904362@qq.com"
dotnet new tool-manifest
dotnet tool install cake.tool --version 4.0.0
dotnet cake --target publish --username="${{ github.actor }}" --email="836904362@qq.com" --pre-release=${{ inputs.pre_release }} --nuget-token=${{ secrets.NUGETTOKEN }}
dotnet tool install cake.tool --version 5.0.0
dotnet cake --target publish --username="${{ github.actor }}" --email="836904362@qq.com" --pre-release=${{ inputs.pre_release }} --nuget-token=${{ secrets.NUGETTOKEN }} --github-token=${{ secrets.GITHUB_TOKEN }}
- name: Push git changes
uses: ad-m/github-push-action@master
@@ -39,12 +39,3 @@ jobs:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: ${{ github.ref }}
tags: true
- name: Create github release
uses: softprops/action-gh-release@v2
with:
# For maximum compatibility, we choose the .net40
files: ./build/outputs/installer/net40/*
body_path: ./build/outputs/CHANGELOG.md
token: ${{ secrets.GITHUB_TOKEN }}
prerelease: ${{ inputs.pre_release }}
+35 -4
View File
@@ -1,4 +1,5 @@
#addin nuget:?package=Cake.Git&version=4.0.0
#addin nuget:?package=Cake.Git&version=5.0.1
#addin nuget:?package=Cake.GitHub&version=1.0.0
#tool nuget:?package=NuGet.CommandLine&version=6.9.1
using System;
@@ -26,6 +27,7 @@ var preRelease = Argument("pre-release", false);
var username = Argument("username", "NaBian");
var email = Argument("email", "836904362@qq.com");
var nugetToken = Argument("nuget-token", "");
var githubToken = Argument("github-token", "");
var libVersion = "";
var nugetVersion = "";
@@ -127,13 +129,14 @@ Task("commit files")
var exitCode = StartProcess(
"git",
new ProcessSettings {
new ProcessSettings
{
Arguments = "diff --cached --quiet",
WorkingDirectory = gitRootPath
}
);
if(exitCode == 0)
if (exitCode == 0)
{
Information("no change.");
return;
@@ -345,6 +348,33 @@ Task("push to nuget")
});
});
Task("create github release")
.Does(async () =>
{
await GitHubCreateReleaseAsync(
/// The user name to use for authentication (pass null when using an access token).
userName: null,
/// The access token or password to use for authentication.
apiToken: githubToken,
// The owner (user or group) of the repository to create a release in.
owner: "HandyOrg",
/// The name of the repository to create a release in.
repository: "HandyControl",
/// The name of the tag to create a release for.
/// If the tag does not yet exist, a new tag will be created (using either the HEAD of the default branch or the commit specified in the settings).
/// If the tag already exists, the existing tag will be used and the commit specified in the settings will be ignored.
tagName: $"v{nugetVersion}",
settints: new GitHubCreateReleaseSettings
{
ReleaseName = $"Release v{nugetVersion}",
Body = ReadAllText(Combine(buildConfig.OutputsFolder, "CHANGELOG.md"), Encoding.UTF8),
Prerelease = preRelease,
Overwrite = false,
Assets = GetFiles("../build/outputs/installer/net40/*").ToArray(),
}
);
});
Task("publish")
.IsDependentOn("update license")
.IsDependentOn("update version")
@@ -362,6 +392,7 @@ Task("publish")
.IsDependentOn("pack nuspec files")
.IsDependentOn("create demo installers")
.IsDependentOn("push to nuget")
.IsDependentOn("create github release")
;
Task("build")
@@ -6,7 +6,7 @@
<Description>Contains some simple and commonly used WPF controls</Description>
<PackageId>HandyControl</PackageId>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
<NoWarn>0067;0649;1591;MSB3061;SYSLIB0003;SYSLIB0004;SYSLIB0032</NoWarn>
<NoWarn>0067;0649;1591;MSB3061;SYSLIB0003;SYSLIB0004;SYSLIB0032;CA2022</NoWarn>
<MSBuildWarningsAsMessages>NETSDK1138</MSBuildWarningsAsMessages>
<AssemblyOriginatorKeyFile>..\..\Shared\HandyControl_Shared\key.snk</AssemblyOriginatorKeyFile>
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>