Skip to content

Commit ffbaa9d

Browse files
committed
Add GitHub Actions, Update Cake & .NET
* Add GitHub Actions * Add Funding yml * Update to .NET 6 SDK * Add .NET 6 TFM * Add .NET Standard 2.1 TFM * Update to Cake 2.1 * Update GitVersion to 5.9 * Update SourceLink to 1.1.1
1 parent a161b2b commit ffbaa9d

8 files changed

Lines changed: 102 additions & 35 deletions

File tree

.github/FUNDING.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
github: devlead

.github/workflows/build.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: Build
2+
on:
3+
pull_request:
4+
push:
5+
branches:
6+
- main
7+
- develop
8+
- hotfix/*
9+
10+
jobs:
11+
build:
12+
name: Build
13+
runs-on: ${{ matrix.os }}
14+
strategy:
15+
fail-fast: false
16+
matrix:
17+
os: [windows-latest, ubuntu-latest, macos-latest]
18+
steps:
19+
- name: Get the sources
20+
uses: actions/checkout@v2
21+
with:
22+
fetch-depth: 0
23+
24+
- name: Install .NET Core SDK
25+
uses: actions/setup-dotnet@v1
26+
27+
- name: Run Cake script
28+
uses: cake-build/cake-action@v1
29+
env:
30+
GH_PACKAGES_NUGET_SOURCE: https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json
31+
GH_PACKAGES_NUGET_APIKEY: ${{ secrets.GITHUB_TOKEN }}
32+
NUGET_SOURCE: ${{ secrets.NUGET_API_URL }}
33+
NUGET_APIKEY: ${{ secrets.NUGET_API_KEY }}
34+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
35+
with:
36+
cake-version: tool-manifest
37+
target: GitHub-Actions

azure-pipelines.yaml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,6 @@ pool:
1111
vmImage: $(imageName)
1212

1313
steps:
14-
- task: UseDotNet@2
15-
displayName: 'Use .NET Core sdk 2.1.202'
16-
inputs:
17-
version: 2.1.202
18-
1914
- task: UseDotNet@2
2015
displayName: 'Use .NET Core sdk'
2116
inputs:

build.cake

Lines changed: 54 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
1-
// Install modules
2-
#module nuget:?package=Cake.DotNetTool.Module&version=0.3.0
3-
41
// Install tools
52
#tool nuget:?package=NUnit.ConsoleRunner&version=3.4.0
63

74
// Install .NET Core Global tools.
8-
#tool "dotnet:https://api.nuget.org/v3/index.json?package=GitVersion.Tool&version=5.0.1"
5+
#tool "dotnet:?package=GitVersion.Tool&version=5.9.0"
96

107
///////////////////////////////////////////////////////////////////////////////
118
// ARGUMENTS
@@ -18,7 +15,7 @@ var configuration = Argument("configuration", "Release");
1815
// PARAMETERS
1916
//////////////////////////////////////////////////////////////////////
2017

21-
DotNetCoreMSBuildSettings msBuildSettings = null;
18+
DotNetMSBuildSettings msBuildSettings = null;
2219
string version = null,
2320
semVersion = null,
2421
milestone = null;
@@ -54,10 +51,12 @@ Setup(ctx =>
5451

5552
Information("Calculated Semantic Version: {0}", semVersion);
5653

57-
msBuildSettings = new DotNetCoreMSBuildSettings()
54+
msBuildSettings = new DotNetMSBuildSettings()
5855
.WithProperty("Version", semVersion)
5956
.WithProperty("AssemblyVersion", version)
60-
.WithProperty("FileVersion", version);
57+
.WithProperty("FileVersion", version)
58+
.WithProperty("ContinuousIntegrationBuild", BuildSystem.IsLocalBuild ? bool.FalseString : bool.TrueString);
59+
6160

6261
if(!IsRunningOnWindows())
6362
{
@@ -107,16 +106,16 @@ Task("Clean")
107106
Task("Restore")
108107
.IsDependentOn("Clean")
109108
.Does(() => {
110-
DotNetCoreRestore("./LitJSON.sln",
111-
new DotNetCoreRestoreSettings { MSBuildSettings = msBuildSettings }
109+
DotNetRestore("./LitJSON.sln",
110+
new DotNetRestoreSettings { MSBuildSettings = msBuildSettings }
112111
);
113112
});
114113

115114
Task("Build")
116115
.IsDependentOn("Restore")
117116
.Does(() => {
118-
DotNetCoreBuild("./LitJSON.sln",
119-
new DotNetCoreBuildSettings {
117+
DotNetBuild("./LitJSON.sln",
118+
new DotNetBuildSettings {
120119
Configuration = configuration,
121120
MSBuildSettings = msBuildSettings,
122121
ArgumentCustomization = args => args.Append("--no-restore")
@@ -127,10 +126,10 @@ Task("Build")
127126
Task("Test")
128127
.IsDependentOn("Build")
129128
.Does(() => {
130-
DotNetCoreTest("./test/LitJSON.Tests.csproj",
131-
new DotNetCoreTestSettings {
129+
DotNetTest("./test/LitJSON.Tests.csproj",
130+
new DotNetTestSettings {
132131
Configuration = configuration,
133-
Framework = "netcoreapp2.0",
132+
Framework = "net6.0",
134133
NoBuild = true,
135134
ArgumentCustomization = args => args.Append("--no-restore")
136135
}
@@ -143,20 +142,20 @@ Task("Test")
143142

144143
Task("Test-SourceLink")
145144
.IsDependentOn("Build")
146-
.WithCriteria(IsRunningOnWindows())
145+
.WithCriteria(IsRunningOnWindows() && AppVeyor.IsRunningOnAppVeyor)
147146
.Does(() => {
148147
foreach(var asssembly in GetFiles("./src/LitJson/bin/" + configuration + "/**/*.dll"))
149148
{
150-
DotNetCoreTool(litjsonProjectPath.FullPath, "sourcelink", $"test {asssembly}");
149+
DotNetTool(litjsonProjectPath.FullPath, "sourcelink", $"test {asssembly}");
151150
}
152151
});
153152

154153
Task("Package")
155154
.IsDependentOn("Test")
156155
.IsDependentOn("Test-SourceLink")
157156
.Does(() => {
158-
DotNetCorePack(litjsonProjectPath.FullPath,
159-
new DotNetCorePackSettings {
157+
DotNetPack(litjsonProjectPath.FullPath,
158+
new DotNetPackSettings {
160159
Configuration = configuration,
161160
NoBuild = true,
162161
IncludeSymbols = true,
@@ -197,8 +196,8 @@ Task("Publish-MyGet")
197196

198197
foreach(var package in (GetFiles("./artifacts/nuget/*.nupkg") - GetFiles("./artifacts/nuget/*.symbols.nupkg")))
199198
{
200-
DotNetCoreNuGetPush(package.FullPath,
201-
new DotNetCoreNuGetPushSettings {
199+
DotNetNuGetPush(package.FullPath,
200+
new DotNetNuGetPushSettings {
202201
ApiKey = apiKey,
203202
Source = apiUrl
204203
}
@@ -215,19 +214,47 @@ Task("Publish-NuGet")
215214
// Resolve the API key.
216215
var apiKey = EnvironmentVariable("NUGET_API_KEY");
217216
if(string.IsNullOrEmpty(apiKey)) {
218-
throw new InvalidOperationException("Could not resolve MyGet API key.");
217+
throw new InvalidOperationException("Could not resolve NuGet API key.");
219218
}
220219

221220
// Resolve the API url.
222221
var apiUrl = EnvironmentVariable("NUGET_API_URL");
223222
if(string.IsNullOrEmpty(apiUrl)) {
224-
throw new InvalidOperationException("Could not resolve MyGet API url.");
223+
throw new InvalidOperationException("Could not resolve NuGet API url.");
224+
}
225+
226+
foreach(var package in (GetFiles("./artifacts/nuget/*.nupkg") - GetFiles("./artifacts/nuget/*.symbols.nupkg")))
227+
{
228+
DotNetNuGetPush(package.FullPath,
229+
new DotNetNuGetPushSettings {
230+
ApiKey = apiKey,
231+
Source = apiUrl
232+
}
233+
);
234+
}
235+
});
236+
237+
Task("Push-GitHub-Packages")
238+
.IsDependentOn("Package")
239+
.WithCriteria(GitHubActions.IsRunningOnGitHubActions && !GitHubActions.Environment.PullRequest.IsPullRequest)
240+
.Does(() => {
241+
242+
// Resolve the API key.
243+
var apiKey = EnvironmentVariable("GH_PACKAGES_NUGET_APIKEY");
244+
if(string.IsNullOrEmpty(apiKey)) {
245+
throw new InvalidOperationException("Could not resolve GitHub API key.");
246+
}
247+
248+
// Resolve the API url.
249+
var apiUrl = EnvironmentVariable("GH_PACKAGES_NUGET_SOURCE");
250+
if(string.IsNullOrEmpty(apiUrl)) {
251+
throw new InvalidOperationException("Could not resolve GitHub API url.");
225252
}
226253

227254
foreach(var package in (GetFiles("./artifacts/nuget/*.nupkg") - GetFiles("./artifacts/nuget/*.symbols.nupkg")))
228255
{
229-
DotNetCoreNuGetPush(package.FullPath,
230-
new DotNetCoreNuGetPushSettings {
256+
DotNetNuGetPush(package.FullPath,
257+
new DotNetNuGetPushSettings {
231258
ApiKey = apiKey,
232259
Source = apiUrl
233260
}
@@ -240,6 +267,9 @@ Task("AppVeyor")
240267
.IsDependentOn("Publish-MyGet")
241268
.IsDependentOn("Publish-NuGet");
242269

270+
Task("GitHub-Actions")
271+
.IsDependentOn("Push-GitHub-Packages");
272+
243273
Task("Default")
244274
.IsDependentOn("Package");
245275

build.config

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
#!/usr/bin/env bash
2-
CAKE_VERSION=0.36.0
3-
DOTNET_VERSION=3.0.101
2+
CAKE_VERSION=2.1.0
3+
DOTNET_VERSION=6.0.201

global.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
"src"
44
],
55
"sdk": {
6-
"version": "3.0.101"
6+
"version": "6.0.201",
7+
"allowPrerelease": false,
8+
"rollForward": "feature"
79
}
810
}

src/LitJson/LitJSON.csproj

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFrameworks>netstandard2.0;net45;netstandard1.5;net40;net35;net20</TargetFrameworks>
4+
<TargetFrameworks>netstandard2.1;netstandard2.0;net45;netstandard1.5;net40;net35;net20;net6.0</TargetFrameworks>
55
</PropertyGroup>
66

77
<PropertyGroup>
88
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
99
<DebugType>embedded</DebugType>
10+
<EmbedUntrackedSources>true</EmbedUntrackedSources>
11+
<PublishRepositoryUrl>true</PublishRepositoryUrl>
1012
<SourceLinkCreate Condition="'$(OS)' == 'Windows_NT'">true</SourceLinkCreate>
1113
</PropertyGroup>
1214

1315
<ItemGroup Condition="'$(OS)' == 'Windows_NT'">
14-
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0" PrivateAssets="All" />
16+
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="All" />
1517
<DotNetCliToolReference Include="dotnet-sourcelink-git" Version="2.8.3" />
1618
<DotNetCliToolReference Include="dotnet-sourcelink" Version="2.8.3" />
1719
</ItemGroup>

test/LitJSON.Tests.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFrameworks>netcoreapp2.0;net45</TargetFrameworks>
4+
<TargetFrameworks>net6.0;net45</TargetFrameworks>
55

66
<IsPackable>false</IsPackable>
77
</PropertyGroup>

0 commit comments

Comments
 (0)