Skip to content

Commit 99932f9

Browse files
authored
Migrate from AppVeyor to GitHub Actions (#68)
* Migrate from AppVeyor to GitHub Actions - Replace AppVeyor CI configuration with GitHub Actions workflows - Add CI workflow for builds, tests, and SonarQube analysis on push/PR - Add manual publish workflow for NuGet package deployment - Update build system to use GitHubActions instead of AppVeyor - Upgrade SonarScanner to version 10.4.1 - Remove deprecated framework specification from SonarScanner end * Remove AppVeyor-specific UpdateBuildVersion target * Skip JRE provisioning in SonarScanner - use pre-installed Java * Add NuGet and SonarQube caching to workflows * Remove unnecessary artifact name * Remove unnecessary step * Fix SonarQube cache key and preserve NuGet package format in artifacts * Remove compression level * Update dependencies
1 parent c4f149e commit 99932f9

File tree

9 files changed

+186
-113
lines changed

9 files changed

+186
-113
lines changed

.github/workflows/ci.yml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [ master ]
6+
pull_request:
7+
branches: [ master ]
8+
9+
jobs:
10+
build:
11+
runs-on: windows-latest
12+
13+
steps:
14+
- uses: actions/checkout@v5
15+
16+
- name: Setup .NET
17+
uses: actions/setup-dotnet@v5
18+
with:
19+
dotnet-version: 9.x
20+
21+
- name: Setup Java
22+
uses: actions/setup-java@v5
23+
with:
24+
distribution: 'temurin'
25+
java-version: '21'
26+
27+
- name: Cache NuGet packages
28+
uses: actions/cache@v4
29+
with:
30+
path: ~/.nuget/packages
31+
key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj') }}
32+
restore-keys: |
33+
${{ runner.os }}-nuget-
34+
35+
- name: Cache SonarQube
36+
uses: actions/cache@v4
37+
with:
38+
path: ~/.sonar/cache
39+
key: ${{ runner.os }}-sonar
40+
41+
- name: Build and Test
42+
run: .\build.cmd sonar unit-test nuget-pack --configuration Release
43+
env:
44+
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
45+
46+
- name: Upload NuGet package
47+
uses: actions/upload-artifact@v4
48+
with:
49+
path: artifacts/*.nupkg

.github/workflows/publish.yml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: Publish to NuGet
2+
3+
on:
4+
workflow_dispatch:
5+
6+
permissions:
7+
id-token: write
8+
contents: read
9+
10+
jobs:
11+
publish:
12+
runs-on: windows-latest
13+
if: github.ref == 'refs/heads/master'
14+
15+
steps:
16+
- uses: actions/checkout@v5
17+
18+
- name: Setup .NET
19+
uses: actions/setup-dotnet@v5
20+
with:
21+
dotnet-version: 9.x
22+
23+
- name: Cache NuGet packages
24+
uses: actions/cache@v4
25+
with:
26+
path: ~/.nuget/packages
27+
key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj') }}
28+
restore-keys: |
29+
${{ runner.os }}-nuget-
30+
31+
- name: Build and Pack
32+
run: .\build.cmd nuget-pack --configuration Release
33+
34+
- name: Upload NuGet package
35+
uses: actions/upload-artifact@v4
36+
with:
37+
path: artifacts/*.nupkg
38+
39+
- name: NuGet login (OIDC → temp API key)
40+
uses: NuGet/login@v1
41+
id: login
42+
with:
43+
user: ${{ secrets.NUGET_USER }}
44+
45+
- name: NuGet push
46+
run: dotnet nuget push artifacts/*.nupkg --api-key ${{steps.login.outputs.NUGET_API_KEY}} --source https://api.nuget.org/v3/index.json

.nuke/build.schema.json

Lines changed: 70 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,49 @@
11
{
22
"$schema": "http://json-schema.org/draft-04/schema#",
3-
"$ref": "#/definitions/build",
4-
"title": "Build Schema",
53
"definitions": {
6-
"build": {
7-
"type": "object",
4+
"Host": {
5+
"type": "string",
6+
"enum": [
7+
"AppVeyor",
8+
"AzurePipelines",
9+
"Bamboo",
10+
"Bitbucket",
11+
"Bitrise",
12+
"GitHubActions",
13+
"GitLab",
14+
"Jenkins",
15+
"Rider",
16+
"SpaceAutomation",
17+
"TeamCity",
18+
"Terminal",
19+
"TravisCI",
20+
"VisualStudio",
21+
"VSCode"
22+
]
23+
},
24+
"ExecutableTarget": {
25+
"type": "string",
26+
"enum": [
27+
"Compile",
28+
"NugetPack",
29+
"Sonar",
30+
"SonarBegin",
31+
"Test",
32+
"UnitTest"
33+
]
34+
},
35+
"Verbosity": {
36+
"type": "string",
37+
"description": "",
38+
"enum": [
39+
"Verbose",
40+
"Normal",
41+
"Minimal",
42+
"Quiet"
43+
]
44+
},
45+
"NukeBuild": {
846
"properties": {
9-
"Configuration": {
10-
"type": "string",
11-
"description": "Configuration to build - Default is 'Debug' (local) or 'Release' (server)",
12-
"enum": [
13-
"Debug",
14-
"Release"
15-
]
16-
},
1747
"Continue": {
1848
"type": "boolean",
1949
"description": "Indicates to continue a previously failed build attempt"
@@ -23,25 +53,8 @@
2353
"description": "Shows the help text for this build assembly"
2454
},
2555
"Host": {
26-
"type": "string",
2756
"description": "Host for execution. Default is 'automatic'",
28-
"enum": [
29-
"AppVeyor",
30-
"AzurePipelines",
31-
"Bamboo",
32-
"Bitbucket",
33-
"Bitrise",
34-
"GitHubActions",
35-
"GitLab",
36-
"Jenkins",
37-
"Rider",
38-
"SpaceAutomation",
39-
"TeamCity",
40-
"Terminal",
41-
"TravisCI",
42-
"VisualStudio",
43-
"VSCode"
44-
]
57+
"$ref": "#/definitions/Host"
4558
},
4659
"NoLogo": {
4760
"type": "boolean",
@@ -70,53 +83,46 @@
7083
"type": "array",
7184
"description": "List of targets to be skipped. Empty list skips all dependencies",
7285
"items": {
73-
"type": "string",
74-
"enum": [
75-
"Compile",
76-
"NugetPack",
77-
"Sonar",
78-
"SonarBegin",
79-
"Test",
80-
"UnitTest",
81-
"UpdateBuildVersion"
82-
]
86+
"$ref": "#/definitions/ExecutableTarget"
8387
}
8488
},
85-
"Solution": {
86-
"type": "string",
87-
"description": "Path to a solution file that is automatically loaded"
88-
},
89-
"sonar:apikey": {
90-
"type": "string",
91-
"description": "SonarQube API key"
92-
},
9389
"Target": {
9490
"type": "array",
9591
"description": "List of targets to be invoked. Default is '{default_target}'",
9692
"items": {
97-
"type": "string",
98-
"enum": [
99-
"Compile",
100-
"NugetPack",
101-
"Sonar",
102-
"SonarBegin",
103-
"Test",
104-
"UnitTest",
105-
"UpdateBuildVersion"
106-
]
93+
"$ref": "#/definitions/ExecutableTarget"
10794
}
10895
},
10996
"Verbosity": {
110-
"type": "string",
11197
"description": "Logging verbosity during build execution. Default is 'Normal'",
98+
"$ref": "#/definitions/Verbosity"
99+
}
100+
}
101+
}
102+
},
103+
"allOf": [
104+
{
105+
"properties": {
106+
"Configuration": {
107+
"type": "string",
108+
"description": "Configuration to build - Default is 'Debug' (local) or 'Release' (server)",
112109
"enum": [
113-
"Minimal",
114-
"Normal",
115-
"Quiet",
116-
"Verbose"
110+
"Debug",
111+
"Release"
117112
]
113+
},
114+
"Solution": {
115+
"type": "string",
116+
"description": "Path to a solution file that is automatically loaded"
117+
},
118+
"SONAR_TOKEN": {
119+
"type": "string",
120+
"description": "SonarQube token"
118121
}
119122
}
123+
},
124+
{
125+
"$ref": "#/definitions/NukeBuild"
120126
}
121-
}
127+
]
122128
}

Todoist.Net.sln

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{32567012-95F
77
EndProject
88
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{28A18847-32D8-4A08-A1BF-BC51E3FBAB96}"
99
ProjectSection(SolutionItems) = preProject
10-
appveyor.yml = appveyor.yml
1110
README.md = README.md
1211
.gitignore = .gitignore
12+
.github\workflows\ci.yml = .github\workflows\ci.yml
13+
.github\workflows\publish.yml = .github\workflows\publish.yml
1314
EndProjectSection
1415
EndProject
1516
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Todoist.Net", "src\Todoist.Net\Todoist.Net.csproj", "{0D84413B-43C0-4F0E-92A6-669F2E9EA5CB}"

appveyor.yml

Lines changed: 0 additions & 21 deletions
This file was deleted.

build/Build.cs

Lines changed: 14 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1+
using System.Collections.Generic;
12
using Nuke.Common;
23
using Nuke.Common.CI;
3-
using Nuke.Common.CI.AppVeyor;
4+
using Nuke.Common.CI.GitHubActions;
45
using Nuke.Common.ProjectModel;
56
using Nuke.Common.Tooling;
67
using Nuke.Common.Tools.DotNet;
@@ -16,19 +17,11 @@ class Build : NukeBuild
1617
[Parameter("Configuration to build - Default is 'Debug' (local) or 'Release' (server)")]
1718
readonly Configuration Configuration = IsLocalBuild ? Configuration.Debug : Configuration.Release;
1819

19-
[Parameter("SonarQube API key", Name = "sonar:apikey")] readonly string SonarQubeApiKey;
20+
[Parameter("SonarQube token", Name = "SONAR_TOKEN")] readonly string SonarQubeToken;
2021

2122
[Solution(GenerateProjects = true)] readonly Solution Solution;
2223

23-
[CI] readonly AppVeyor AppVeyor;
24-
25-
Target UpdateBuildVersion => _ => _
26-
.Requires(() => AppVeyor)
27-
.Before(Compile)
28-
.Executes(() =>
29-
{
30-
AppVeyor.Instance.UpdateBuildVersion($"{Solution.src.Todoist_Net.GetProperty("Version")}.{AppVeyor.BuildNumber}");
31-
});
24+
[CI] readonly GitHubActions GitHubActions;
3225

3326
Target Compile => _ => _
3427
.Executes(() =>
@@ -83,26 +76,26 @@ class Build : NukeBuild
8376
{
8477
s = s
8578
.SetServer("https://sonarcloud.io")
86-
.SetFramework("net5.0")
87-
.SetToken(SonarQubeApiKey)
79+
.SetToken(SonarQubeToken)
8880
.SetProjectKey("todoist-net")
8981
.SetName("Todoist.Net")
9082
.SetOrganization("olsh")
91-
.SetVersion("1.0.0.0");
83+
.SetVersion("1.0.0.0")
84+
.SetAdditionalParameters(new Dictionary<string, string> { ["sonar.scanner.skipJreProvisioning"] = "true" });
9285

93-
if (AppVeyor != null)
86+
if (GitHubActions != null)
9487
{
95-
if (AppVeyor.PullRequestNumber != null)
88+
if (GitHubActions.IsPullRequest)
9689
{
9790
s = s
98-
.SetPullRequestKey(AppVeyor.PullRequestNumber.ToString())
99-
.SetPullRequestBase(AppVeyor.RepositoryBranch)
100-
.SetPullRequestBranch(AppVeyor.PullRequestHeadRepositoryBranch);
91+
.SetPullRequestKey(GitHubActions.PullRequestNumber.ToString())
92+
.SetPullRequestBase(GitHubActions.BaseRef)
93+
.SetPullRequestBranch(GitHubActions.HeadRef);
10194
}
10295
else
10396
{
10497
s = s
105-
.SetBranchName(AppVeyor.RepositoryBranch);
98+
.SetBranchName(GitHubActions.RefName);
10699
}
107100
}
108101

@@ -115,7 +108,6 @@ class Build : NukeBuild
115108
.Executes(() =>
116109
{
117110
SonarScannerEnd(s => s
118-
.SetToken(SonarQubeApiKey)
119-
.SetFramework("net5.0"));
111+
.SetToken(SonarQubeToken));
120112
});
121113
}

build/_build.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
<ItemGroup>
1515
<PackageReference Include="Nuke.Common" Version="9.0.4" />
16-
<PackageDownload Include="dotnet-sonarscanner" Version="[9.0.2]" />
16+
<PackageDownload Include="dotnet-sonarscanner" Version="[10.4.1]" />
1717
</ItemGroup>
1818

1919
</Project>

src/Todoist.Net.Tests/Todoist.Net.Tests.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
</PropertyGroup>
77

88
<ItemGroup>
9-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />
9+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.0.0" />
1010
<PackageReference Include="xunit" Version="2.9.3" />
11-
<PackageReference Include="xunit.runner.visualstudio" Version="3.0.1">
11+
<PackageReference Include="xunit.runner.visualstudio" Version="3.1.5">
1212
<PrivateAssets>all</PrivateAssets>
1313
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
1414
</PackageReference>

0 commit comments

Comments
 (0)