Skip to content

Commit 7608db0

Browse files
author
Christian
committed
ci: Correct build script and publish workflow
1 parent 838969e commit 7608db0

5 files changed

Lines changed: 162 additions & 25 deletions

File tree

.github/workflows/publish-nuget.yaml

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
name: "Publish"
22

3-
on: [push]
4-
# on:
5-
# push:
6-
# tags:
7-
# - "v**.**.**" # Semantic Versioning like "v1.22.3"
8-
# - "v**.**.**-**" # Prerelease Semantic Versioning like "v1.22.3-rc4"
3+
on:
4+
push:
5+
tags:
6+
- "v**.**.**" # Semantic Versioning like "v1.22.3"
7+
- "v**.**.**-**" # Prerelease Semantic Versioning like "v1.22.3-rc4"
98

109
jobs:
1110
publish:
@@ -36,8 +35,5 @@ jobs:
3635
- name: Install openapi-generator-cli
3736
run: npm install @openapitools/openapi-generator-cli -g
3837

39-
- name: Test Packing
40-
run: ./build/build.sh -Target Pack -Configuration Release --nuget_api_key_gitlabclient ${{ secrets.NUGET_API_KEY_GITLABCLIENT }}
41-
42-
# - name: Run publish with nuke
43-
# run: ./build/build.sh -Target Publish -Configuration Release --nuget_api_key_gitlabclient ${{ secrets.NUGET_API_KEY_GITLABCLIENT }}
38+
- name: Publish with nuke
39+
run: ./build/build.sh -Target Publish -Configuration Release --nuget_api_key_gitlabclient ${{ secrets.NUGET_API_KEY_GITLABCLIENT }}

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,6 @@ build/.idea/.idea.GitLabClient.Build.dir/.idea/.name
1212
/build/.idea
1313
/build/bin
1414
/build/obj
15-
/openapitools.json
15+
/openapitools.json
16+
/.nuke/temp
17+
/packages

.nuke/build.schema.json

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
{
2+
"$schema": "http://json-schema.org/draft-04/schema#",
3+
"title": "Build Schema",
4+
"$ref": "#/definitions/build",
5+
"definitions": {
6+
"build": {
7+
"type": "object",
8+
"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+
},
17+
"Continue": {
18+
"type": "boolean",
19+
"description": "Indicates to continue a previously failed build attempt"
20+
},
21+
"Help": {
22+
"type": "boolean",
23+
"description": "Shows the help text for this build assembly"
24+
},
25+
"Host": {
26+
"type": "string",
27+
"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+
]
45+
},
46+
"NoLogo": {
47+
"type": "boolean",
48+
"description": "Disables displaying the NUKE logo"
49+
},
50+
"NUGET_API_KEY_GITLABCLIENT": {
51+
"type": "string",
52+
"description": "NuGet API Key for io.juenger.GitLabClient Package"
53+
},
54+
"Partition": {
55+
"type": "string",
56+
"description": "Partition to use on CI"
57+
},
58+
"Plan": {
59+
"type": "boolean",
60+
"description": "Shows the execution plan (HTML)"
61+
},
62+
"Profile": {
63+
"type": "array",
64+
"description": "Defines the profiles to load",
65+
"items": {
66+
"type": "string"
67+
}
68+
},
69+
"Root": {
70+
"type": "string",
71+
"description": "Root directory during build execution"
72+
},
73+
"Skip": {
74+
"type": "array",
75+
"description": "List of targets to be skipped. Empty list skips all dependencies",
76+
"items": {
77+
"type": "string",
78+
"enum": [
79+
"Clean",
80+
"Compile",
81+
"Generate",
82+
"Pack",
83+
"Publish",
84+
"Restore",
85+
"Setup"
86+
]
87+
}
88+
},
89+
"Target": {
90+
"type": "array",
91+
"description": "List of targets to be invoked. Default is '{default_target}'",
92+
"items": {
93+
"type": "string",
94+
"enum": [
95+
"Clean",
96+
"Compile",
97+
"Generate",
98+
"Pack",
99+
"Publish",
100+
"Restore",
101+
"Setup"
102+
]
103+
}
104+
},
105+
"Verbosity": {
106+
"type": "string",
107+
"description": "Logging verbosity during build execution. Default is 'Normal'",
108+
"enum": [
109+
"Minimal",
110+
"Normal",
111+
"Quiet",
112+
"Verbose"
113+
]
114+
}
115+
}
116+
}
117+
}
118+
}

build/Build.cs

Lines changed: 30 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@
1313
[ShutdownDotNetAfterServerBuild]
1414
class Build : NukeBuild
1515
{
16-
public static int Main () => Execute<Build>(x => x.Generate);
16+
Solution Solution;
17+
18+
public static int Main () => Execute<Build>(x => x.Compile);
1719

1820
[Parameter("NuGet API Key for io.juenger.GitLabClient Package", Name = "NUGET_API_KEY_GITLABCLIENT")]
1921
readonly string NuGetApiKey;
@@ -51,27 +53,42 @@ class Build : NukeBuild
5153
.DependsOn(Setup)
5254
.Executes(() =>
5355
{
54-
// NpmTasks.Npm("exec @openapitools/openapi-generator-cli generate -g csharp-netcore " +
55-
// "--additional-properties=targetFramework=net5.0 " +
56-
// "--additional-properties=packageName=IO.Juenger.GitLabClient " +
57-
// "-i ./openapi.yaml " +
58-
// $"-o {OutputDirectory}");
59-
6056
OpenApiGeneratorCli("generate -g csharp-netcore " +
6157
"--additional-properties=targetFramework=net5.0 " +
6258
"--additional-properties=packageName=Io.Juenger.GitLabClient " +
6359
"-i ./openapi.yaml " +
6460
$"-o {OutputDirectory}");
61+
62+
var solutionFile = OutputDirectory / "Io.Juenger.GitLabClient.sln";
63+
Solution = ProjectModelTasks.ParseSolution(solutionFile);
6564
});
6665

67-
Target Pack => _ => _
66+
Target Restore => _ => _
6867
.DependsOn(Generate)
6968
.Executes(() =>
7069
{
71-
var solutionFile = OutputDirectory / "Io.Juenger.GitLabClient.sln";
72-
var solution = ProjectModelTasks.ParseSolution(solutionFile);
73-
74-
var packableProjects = solution
70+
DotNetRestore(settings => settings.SetProjectFile(Solution));
71+
});
72+
73+
Target Compile => _ => _
74+
.DependsOn(Restore)
75+
.Executes(() =>
76+
{
77+
DotNetBuild(settings =>
78+
settings
79+
.SetProjectFile(Solution)
80+
.SetConfiguration(Configuration)
81+
.SetAssemblyVersion(GitVersion?.AssemblySemVer)
82+
.SetFileVersion(GitVersion?.AssemblySemFileVer)
83+
.SetInformationalVersion(GitVersion?.InformationalVersion)
84+
.EnableNoRestore());
85+
});
86+
87+
Target Pack => _ => _
88+
.DependsOn(Compile)
89+
.Executes(() =>
90+
{
91+
var packableProjects = Solution
7592
.AllProjects
7693
.Where(project => project.GetProperty<bool>("IsPackable")) ?? Enumerable.Empty<Project>();
7794

@@ -85,7 +102,7 @@ class Build : NukeBuild
85102
"This library provides client to GitLab's web API.\n" +
86103
"It is generated from an OpenAPI specification by using the tool openapi-generator-cli.")
87104
.SetAuthors("Christian Jünger")
88-
.SetProperty("PackageLicenseExpression", "MIT")
105+
// .SetProperty("PackageLicenseExpression", "MIT")
89106
.SetRepositoryUrl("https://github.com/cjuenger/gitlab-openapi")
90107
.SetOutputDirectory(PackageOutputDirectory)
91108
.SetConfiguration(Configuration)

build/GitLabClient.Build.csproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,8 @@
1414
<PackageReference Include="Nuke.Common" Version="6.1.2" />
1515
</ItemGroup>
1616

17+
<ItemGroup>
18+
<PackageDownload Include="GitVersion.Tool" Version="[5.10.3]" />
19+
</ItemGroup>
20+
1721
</Project>

0 commit comments

Comments
 (0)