Skip to content

Commit

Permalink
#2874 - updated the workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
arturcic committed Feb 26, 2023
1 parent d58fcf6 commit 8a8d51e
Show file tree
Hide file tree
Showing 11 changed files with 104 additions and 31 deletions.
6 changes: 0 additions & 6 deletions .github/actions/artifacts-restore/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,6 @@ runs:
with:
path: tools
key: tools-${{ runner.os }}-${{ hashFiles('./build/**') }}
-
uses: actions/download-artifact@v3
name: Download gitversion tool
with:
name: tool
path: ${{ github.workspace }}/dogfood
-
name: Setup .NET SDK
uses: actions/setup-dotnet@v3
Expand Down
16 changes: 8 additions & 8 deletions .github/workflows/_prepare.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,22 @@ jobs:
with:
path: run
key: run-${{ runner.os }}-${{ hashFiles('./build/**') }}
- name: Use cached tools
id: cache-tools
uses: actions/cache@v3
with:
path: tools
key: tools-${{ runner.os }}-${{ hashFiles('./build/**') }}
-
name: Setup .NET SDK
uses: actions/setup-dotnet@v3
with:
global-json-file: global.json
-
name: '[Prepare]'
name: '[Build]'
if: steps.cache-cake.outputs.cache-hit != 'true'
run: dotnet build build/CI.sln --configuration=Release
-
name: '[DogFood]'
name: '[Prepare]'
shell: pwsh
run: dotnet run/build.dll --target=BuildPrepare
-
name: 'Upload gitversion tool'
uses: actions/upload-artifact@v3
with:
name: tool
path: ${{ github.workspace }}/dogfood
16 changes: 8 additions & 8 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,19 +80,14 @@ jobs:
with:
global-json-file: global.json
-
name: '[Prepare]'
name: '[Build]'
if: steps.cache-cake.outputs.cache-hit != 'true'
run: dotnet build build/CI.sln --configuration=Release
-
name: '[DogFood]'
name: '[Prepare]'
shell: pwsh
run: dotnet run/build.dll --target=BuildPrepare
-
name: 'Upload gitversion tool'
uses: actions/upload-artifact@v3
with:
name: tool
path: ${{ github.workspace }}/dogfood

validate:
name: Validates Html
needs: [prepare]
Expand Down Expand Up @@ -145,6 +140,11 @@ jobs:
-
name: Restore State
uses: ./.github/actions/artifacts-restore
-
name: '[Build Schemas]'
shell: pwsh
run: |
dotnet run/docs.dll --target=BuildSchemas
-
name: '[Publish Documentation]'
if: ${{ github.event_name == 'push' }}
Expand Down
20 changes: 20 additions & 0 deletions build/.run/GenerateSchemas.run.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="GenerateSchemas" type="DotNetProject" factoryName=".NET Project" folderName="Docs">
<option name="EXE_PATH" value="$PROJECT_DIR$/../run/docs.exe" />
<option name="PROGRAM_PARAMETERS" value="--target=GenerateSchemas" />
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/.." />
<option name="PASS_PARENT_ENVS" value="1" />
<option name="USE_EXTERNAL_CONSOLE" value="0" />
<option name="USE_MONO" value="0" />
<option name="RUNTIME_ARGUMENTS" value="" />
<option name="PROJECT_PATH" value="$PROJECT_DIR$/docs/docs.csproj" />
<option name="PROJECT_EXE_PATH_TRACKING" value="1" />
<option name="PROJECT_ARGUMENTS_TRACKING" value="1" />
<option name="PROJECT_WORKING_DIRECTORY_TRACKING" value="0" />
<option name="PROJECT_KIND" value="DotNetCore" />
<option name="PROJECT_TFM" value="net7.0" />
<method v="2">
<option name="Build" />
</method>
</configuration>
</component>
26 changes: 26 additions & 0 deletions build/CI.sln
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,32 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "docs", "docs\docs.csproj",
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "release", "release\release.csproj", "{8DAB65D8-57E8-4185-96FC-8A7C7373FC23}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "workflows", "workflows", "{8E5B758F-925A-49E4-9011-20AD2A9E1F43}"
ProjectSection(SolutionItems) = preProject
..\.github\workflows\ci.yml = ..\.github\workflows\ci.yml
..\.github\workflows\codeql-analysis.yml = ..\.github\workflows\codeql-analysis.yml
..\.github\workflows\docs.yml = ..\.github\workflows\docs.yml
..\.github\workflows\format.yml = ..\.github\workflows\format.yml
..\.github\workflows\homebrew.yml = ..\.github\workflows\homebrew.yml
..\.github\workflows\release.yml = ..\.github\workflows\release.yml
..\.github\workflows\_artifacts_linux.yml = ..\.github\workflows\_artifacts_linux.yml
..\.github\workflows\_artifacts_windows.yml = ..\.github\workflows\_artifacts_windows.yml
..\.github\workflows\_build.yml = ..\.github\workflows\_build.yml
..\.github\workflows\_docker.yml = ..\.github\workflows\_docker.yml
..\.github\workflows\_docker_manifests.yml = ..\.github\workflows\_docker_manifests.yml
..\.github\workflows\_prepare.yml = ..\.github\workflows\_prepare.yml
..\.github\workflows\_publish.yml = ..\.github\workflows\_publish.yml
..\.github\workflows\_unit_tests.yml = ..\.github\workflows\_unit_tests.yml
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "actions", "actions", "{A9B92261-AB9C-47D6-A8A7-616A5A62B063}"
ProjectSection(SolutionItems) = preProject
..\.github\actions\artifacts-restore\action.yml = ..\.github\actions\artifacts-restore\action.yml
..\.github\actions\docker-manifests\action.yml = ..\.github\actions\docker-manifests\action.yml
..\.github\actions\docker-publish\action.yml = ..\.github\actions\docker-publish\action.yml
..\.github\actions\docker-test\action.yml = ..\.github\actions\docker-test\action.yml
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down
15 changes: 12 additions & 3 deletions build/build/Tasks/BuildPrepare.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,29 @@ public override void Run(BuildContext context)
context.Information("Builds solution...");

const string sln = "./src/GitVersion.sln";
const string project = "./src/GitVersion.App/GitVersion.App.csproj";
context.DotNetRestore(sln,
new()
{
Verbosity = DotNetVerbosity.Minimal,
Sources = new[] { Constants.NugetOrgUrl },
});

context.DotNetBuild(project,
context.DotNetBuild("./src/GitVersion.App/GitVersion.App.csproj",
new()
{
Verbosity = DotNetVerbosity.Minimal,
Configuration = Constants.DefaultConfiguration,
OutputDirectory = Paths.Dogfood,
OutputDirectory = Paths.Tools.Combine("gitversion"),
Framework = Constants.NetVersionLatest,
NoRestore = true,
});

context.DotNetBuild("./src/GitVersion.Schema/GitVersion.Schema.csproj",
new()
{
Verbosity = DotNetVerbosity.Minimal,
Configuration = Constants.DefaultConfiguration,
OutputDirectory = Paths.Tools.Combine("schema"),
Framework = Constants.NetVersionLatest,
NoRestore = true,
});
Expand Down
2 changes: 1 addition & 1 deletion build/common/Lifetime/BuildLifetimeBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public override void Setup(T context, ISetupContext info)
context.Information("Running BuildPrepare...");
return;
}
var gitversionTool = context.GetDogFoodGitVersionToolLocation();
var gitversionTool = context.GetGitVersionDotnetToolLocation();
var gitVersionSettings = new GitVersionSettings
{
OutputTypes = new HashSet<GitVersionOutput> { GitVersionOutput.Json, GitVersionOutput.BuildServer },
Expand Down
6 changes: 4 additions & 2 deletions build/common/Utilities/ContextExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,8 @@ public static string GetBranchName(this ICakeContext context)

public static FilePath? GetGitVersionToolLocation(this ICakeContext context) =>
context.GetFiles($"src/GitVersion.App/bin/{Constants.DefaultConfiguration}/{Constants.NetVersionLatest}/gitversion.dll").SingleOrDefault();
public static FilePath? GetDogFoodGitVersionToolLocation(this ICakeContext context) =>
context.MakeAbsolute(Paths.Dogfood.CombineWithFilePath("gitversion.dll"));
public static FilePath? GetGitVersionDotnetToolLocation(this ICakeContext context) =>
context.MakeAbsolute(Paths.Tools.Combine("gitversion").CombineWithFilePath("gitversion.dll"));
public static FilePath? GetSchemaDotnetToolLocation(this ICakeContext context) =>
context.MakeAbsolute(Paths.Tools.Combine("schema").CombineWithFilePath("schema.dll"));
}
2 changes: 1 addition & 1 deletion build/common/Utilities/Paths.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public class Paths
public static readonly DirectoryPath Docs = Root.Combine("docs");
public static readonly DirectoryPath Build = Root.Combine("build");
public static readonly DirectoryPath Schemas = Root.Combine("schemas");
public static readonly DirectoryPath Dogfood = Root.Combine("dogfood");
public static readonly DirectoryPath Tools = Root.Combine("tools");
public static readonly DirectoryPath Integration = Root.Combine("tests").Combine("integration");

public static readonly DirectoryPath TestOutput = Artifacts.Combine("test-results");
Expand Down
21 changes: 21 additions & 0 deletions build/docs/Tasks/GenerateSchemas.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using Common.Utilities;

namespace Docs.Tasks;

[TaskName(nameof(GenerateSchemas))]
[TaskDescription("Generate schemas")]
public sealed class GenerateSchemas : FrostingTask<BuildContext>
{
public override void Run(BuildContext context)
{
var schemaTool = context.GetSchemaDotnetToolLocation();
var gitVersion = context.Version!.GitVersion;
var version = $"{gitVersion.Major}.{gitVersion.Minor}";
var schemaTargetDir = context.MakeAbsolute(Paths.Root.Combine("schemas"));
context.EnsureDirectoryExists(schemaTargetDir);
context.Information("Schema tool: {0}", schemaTool);
context.Information("Schema target dir: {0}", schemaTargetDir);
context.Information("Schema version: {0}", version);
context.DotNetExecute(schemaTool, $"--Version {version} --OutputDirectory {schemaTargetDir}");
}
}
5 changes: 3 additions & 2 deletions docs/input/_Bottom.cshtml
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
<div class="github-button">
<a href="https://github.com/GitTools/GitVersion"><i class="fa fa-github"></i> GitHub</a>
</div>
<script>
@* disable gitter sidecar - https://github.com/matrix-org/matrix-public-archive/issues/157 *@
@* <script>
((window.gitter = {}).chat = {}).options = {
room: 'GitTools/GitVersion'
};
</script>
<script src="https://sidecar.gitter.im/dist/sidecar.v1.js" async defer></script>
<script src="https://sidecar.gitter.im/dist/sidecar.v1.js" async defer></script> *@

0 comments on commit 8a8d51e

Please sign in to comment.