Skip to content

Commit e0d72e1

Browse files
committed
chore: Update Cake and GitHub release automation.
1 parent 78e729f commit e0d72e1

File tree

4 files changed

+39
-17
lines changed

4 files changed

+39
-17
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,5 @@ jobs:
2020
working-directory: ./build
2121
run: |
2222
dotnet new tool-manifest
23-
dotnet tool install cake.tool --version 4.0.0
23+
dotnet tool install cake.tool --version 5.0.0
2424
dotnet cake

.github/workflows/bump-up-version.yml

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -30,21 +30,12 @@ jobs:
3030
git config --local user.name "${{ github.actor }}"
3131
git config --local user.email "[email protected]"
3232
dotnet new tool-manifest
33-
dotnet tool install cake.tool --version 4.0.0
34-
dotnet cake --target publish --username="${{ github.actor }}" --email="[email protected]" --pre-release=${{ inputs.pre_release }} --nuget-token=${{ secrets.NUGETTOKEN }}
33+
dotnet tool install cake.tool --version 5.0.0
34+
dotnet cake --target publish --username="${{ github.actor }}" --email="[email protected]" --pre-release=${{ inputs.pre_release }} --nuget-token=${{ secrets.NUGETTOKEN }} --github-token=${{ secrets.GITHUB_TOKEN }}
3535
3636
- name: Push git changes
3737
uses: ad-m/github-push-action@master
3838
with:
3939
github_token: ${{ secrets.GITHUB_TOKEN }}
4040
branch: ${{ github.ref }}
4141
tags: true
42-
43-
- name: Create github release
44-
uses: softprops/action-gh-release@v2
45-
with:
46-
# For maximum compatibility, we choose the .net40
47-
files: ./build/outputs/installer/net40/*
48-
body_path: ./build/outputs/CHANGELOG.md
49-
token: ${{ secrets.GITHUB_TOKEN }}
50-
prerelease: ${{ inputs.pre_release }}

build/build.cake

Lines changed: 35 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
#addin nuget:?package=Cake.Git&version=4.0.0
1+
#addin nuget:?package=Cake.Git&version=5.0.1
2+
#addin nuget:?package=Cake.GitHub&version=1.0.0
23
#tool nuget:?package=NuGet.CommandLine&version=6.9.1
34

45
using System;
@@ -26,6 +27,7 @@ var preRelease = Argument("pre-release", false);
2627
var username = Argument("username", "NaBian");
2728
var email = Argument("email", "[email protected]");
2829
var nugetToken = Argument("nuget-token", "");
30+
var githubToken = Argument("github-token", "");
2931

3032
var libVersion = "";
3133
var nugetVersion = "";
@@ -127,13 +129,14 @@ Task("commit files")
127129

128130
var exitCode = StartProcess(
129131
"git",
130-
new ProcessSettings {
132+
new ProcessSettings
133+
{
131134
Arguments = "diff --cached --quiet",
132135
WorkingDirectory = gitRootPath
133136
}
134137
);
135-
136-
if(exitCode == 0)
138+
139+
if (exitCode == 0)
137140
{
138141
Information("no change.");
139142
return;
@@ -345,6 +348,33 @@ Task("push to nuget")
345348
});
346349
});
347350

351+
Task("create github release")
352+
.Does(async () =>
353+
{
354+
await GitHubCreateReleaseAsync(
355+
/// The user name to use for authentication (pass null when using an access token).
356+
userName: null,
357+
/// The access token or password to use for authentication.
358+
apiToken: githubToken,
359+
// The owner (user or group) of the repository to create a release in.
360+
owner: "HandyOrg",
361+
/// The name of the repository to create a release in.
362+
repository: "HandyControl",
363+
/// The name of the tag to create a release for.
364+
/// 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).
365+
/// If the tag already exists, the existing tag will be used and the commit specified in the settings will be ignored.
366+
tagName: $"v{nugetVersion}",
367+
settints: new GitHubCreateReleaseSettings
368+
{
369+
ReleaseName = $"Release v{nugetVersion}",
370+
Body = ReadAllText(Combine(buildConfig.OutputsFolder, "CHANGELOG.md"), Encoding.UTF8),
371+
Prerelease = preRelease,
372+
Overwrite = false,
373+
Assets = GetFiles("../build/outputs/installer/net40/*").ToArray(),
374+
}
375+
);
376+
});
377+
348378
Task("publish")
349379
.IsDependentOn("update license")
350380
.IsDependentOn("update version")
@@ -362,6 +392,7 @@ Task("publish")
362392
.IsDependentOn("pack nuspec files")
363393
.IsDependentOn("create demo installers")
364394
.IsDependentOn("push to nuget")
395+
.IsDependentOn("create github release")
365396
;
366397

367398
Task("build")

src/Net_GE45/HandyControl_Net_GE45/HandyControl_Net_GE45.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<Description>Contains some simple and commonly used WPF controls</Description>
77
<PackageId>HandyControl</PackageId>
88
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
9-
<NoWarn>0067;0649;1591;MSB3061;SYSLIB0003;SYSLIB0004;SYSLIB0032</NoWarn>
9+
<NoWarn>0067;0649;1591;MSB3061;SYSLIB0003;SYSLIB0004;SYSLIB0032;CA2022</NoWarn>
1010
<MSBuildWarningsAsMessages>NETSDK1138</MSBuildWarningsAsMessages>
1111
<AssemblyOriginatorKeyFile>..\..\Shared\HandyControl_Shared\key.snk</AssemblyOriginatorKeyFile>
1212
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>

0 commit comments

Comments
 (0)