-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
447 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# Remove the line below if you want to inherit .editorconfig settings from higher directories | ||
|
||
# C# or VB files | ||
[*.{cs,vb,ts,tsx}] | ||
guidelines = 120 | ||
|
||
#### Core EditorConfig Options #### | ||
|
||
#Formatting - header template | ||
file_header_template = ----------------------------------------------------------------------------------\nCopyright (c) The Standard Organization: A coalition of the Good-Hearted Engineers\n---------------------------------------------------------------------------------- | ||
|
||
#sort System.* using directives alphabetically, and place them before other usings | ||
dotnet_sort_system_directives_first = true | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,145 @@ | ||
name: Build | ||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
types: | ||
- opened | ||
- synchronize | ||
- reopened | ||
- closed | ||
branches: | ||
- main | ||
env: | ||
IS_RELEASE_CANDIDATE: >- | ||
${{ | ||
( | ||
github.event_name == 'pull_request' && | ||
startsWith(github.event.pull_request.title, 'RELEASES:') && | ||
contains(github.event.pull_request.labels.*.name, 'RELEASES') | ||
) | ||
|| | ||
( | ||
github.event_name == 'push' && | ||
startsWith(github.event.head_commit.message, 'RELEASES:') && | ||
startsWith(github.ref_name, 'RELEASE') | ||
) | ||
}} | ||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Check out | ||
uses: actions/checkout@v3 | ||
- name: Setup .Net | ||
uses: actions/setup-dotnet@v3 | ||
with: | ||
dotnet-version: 7.0.201 | ||
- name: Restore | ||
run: dotnet restore | ||
- name: Build | ||
run: dotnet build --no-restore | ||
- name: Test | ||
run: dotnet test --no-build --verbosity normal | ||
add_tag: | ||
runs-on: ubuntu-latest | ||
needs: | ||
- build | ||
if: >- | ||
needs.build.result == 'success' && | ||
github.event.pull_request.merged && | ||
github.event.pull_request.base.ref == 'main' && | ||
startsWith(github.event.pull_request.title, 'RELEASES:') && | ||
contains(github.event.pull_request.labels.*.name, 'RELEASES') | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
with: | ||
token: ${{ secrets.PAT_FOR_TAGGING }} | ||
- name: Configure Git | ||
run: >- | ||
git config user.name "GitHub Action" | ||
git config user.email "[email protected]" | ||
- name: Extract Version | ||
id: extract_version | ||
run: > | ||
# Running on Linux/Unix | ||
sudo apt-get install xmlstarlet | ||
version_number=$(xmlstarlet sel -t -v "//Version" -n STX.SPAL.Core/STX.SPAL.Core.csproj) | ||
echo "$version_number" | ||
echo "version_number<<EOF" >> $GITHUB_OUTPUT | ||
echo "$version_number" >> $GITHUB_OUTPUT | ||
echo "EOF" >> $GITHUB_OUTPUT | ||
shell: bash | ||
- name: Display Version | ||
run: 'echo "Version number: ${{ steps.extract_version.outputs.version_number }}"' | ||
- name: Extract Package Release Notes | ||
id: extract_package_release_notes | ||
run: > | ||
# Running on Linux/Unix | ||
sudo apt-get install xmlstarlet | ||
package_release_notes=$(xmlstarlet sel -t -v "//PackageReleaseNotes" -n STX.SPAL.Core/STX.SPAL.Core.csproj) | ||
echo "$package_release_notes" | ||
echo "package_release_notes<<EOF" >> $GITHUB_OUTPUT | ||
echo "$package_release_notes" >> $GITHUB_OUTPUT | ||
echo "EOF" >> $GITHUB_OUTPUT | ||
shell: bash | ||
- name: Display Package Release Notes | ||
run: 'echo "Package Release Notes: ${{ steps.extract_package_release_notes.outputs.package_release_notes }}"' | ||
- name: Create GitHub Tag | ||
run: >- | ||
git tag -a "v${{ steps.extract_version.outputs.version_number }}" -m "Release - v${{ steps.extract_version.outputs.version_number }}" | ||
git push origin --tags | ||
- name: Create GitHub Release | ||
uses: actions/create-release@v1 | ||
with: | ||
tag_name: v${{ steps.extract_version.outputs.version_number }} | ||
release_name: Release - v${{ steps.extract_version.outputs.version_number }} | ||
body: >- | ||
## Release - v${{ steps.extract_version.outputs.version_number }} | ||
### Release Notes | ||
${{ steps.extract_package_release_notes.outputs.package_release_notes }} | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.PAT_FOR_TAGGING }} | ||
publish: | ||
runs-on: ubuntu-latest | ||
needs: | ||
- add_tag | ||
if: needs.add_tag.result == 'success' | ||
steps: | ||
- name: Check out | ||
uses: actions/checkout@v3 | ||
- name: Setup .Net | ||
uses: actions/setup-dotnet@v3 | ||
with: | ||
dotnet-version: 7.0.201 | ||
- name: Restore | ||
run: dotnet restore | ||
- name: Build | ||
run: dotnet build --no-restore --configuration Release | ||
- name: Pack NuGet Package | ||
run: dotnet pack --configuration Release --include-symbols | ||
- name: Push NuGet Package | ||
run: dotnet nuget push **/bin/Release/**/*.nupkg --source https://api.nuget.org/v3/index.json --api-key ${{ secrets.NUGET_ACCESS }} --skip-duplicate |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// ---------------------------------------------------------------------------------- | ||
// Copyright (c) The Standard Organization: A coalition of the Good-Hearted Engineers | ||
// ---------------------------------------------------------------------------------- | ||
|
||
using STX.SPAL.Core.Infrastructure.Build.Services; | ||
|
||
namespace STX.SPAL.Core.Infrastructure.Build | ||
{ | ||
internal class Program | ||
{ | ||
static void Main(string[] args) | ||
{ | ||
var scriptGenerationService = new ScriptGenerationService(); | ||
scriptGenerationService.GenerateBuildScript(); | ||
} | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
STX.SPAL.Core.Infrastructure.Build/STX.SPAL.Core.Infrastructure.Build.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>net8.0</TargetFramework> | ||
<ImplicitUsings>disable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
<IsPackable>false</IsPackable> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="ADotNet" Version="3.0.2" /> | ||
</ItemGroup> | ||
|
||
</Project> |
123 changes: 123 additions & 0 deletions
123
STX.SPAL.Core.Infrastructure.Build/Services/ScriptGenerationService.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
// ---------------------------------------------------------------------------------- | ||
// Copyright (c) The Standard Organization: A coalition of the Good-Hearted Engineers | ||
// ---------------------------------------------------------------------------------- | ||
|
||
using System.Collections.Generic; | ||
using System.IO; | ||
using ADotNet.Clients; | ||
using ADotNet.Models.Pipelines.GithubPipelines.DotNets; | ||
using ADotNet.Models.Pipelines.GithubPipelines.DotNets.Tasks; | ||
using ADotNet.Models.Pipelines.GithubPipelines.DotNets.Tasks.SetupDotNetTaskV3s; | ||
|
||
namespace STX.SPAL.Core.Infrastructure.Build.Services | ||
{ | ||
internal class ScriptGenerationService | ||
{ | ||
private readonly ADotNetClient adotNetClient; | ||
|
||
public ScriptGenerationService() => | ||
adotNetClient = new ADotNetClient(); | ||
|
||
public void GenerateBuildScript() | ||
{ | ||
string branchName = "main"; | ||
|
||
var githubPipeline = new GithubPipeline | ||
{ | ||
Name = "Build", | ||
|
||
OnEvents = new Events | ||
{ | ||
Push = new PushEvent | ||
{ | ||
Branches = new string[] { branchName } | ||
}, | ||
|
||
PullRequest = new PullRequestEvent | ||
{ | ||
Types = new string[] { "opened", "synchronize", "reopened", "closed" }, | ||
Branches = new string[] { branchName } | ||
} | ||
}, | ||
|
||
EnvironmentVariables = new Dictionary<string, string> | ||
{ | ||
{ "IS_RELEASE_CANDIDATE", EnvironmentVariables.IsGitHubReleaseCandidate() } | ||
}, | ||
|
||
Jobs = new Dictionary<string, Job> | ||
{ | ||
{ | ||
"build", | ||
new Job | ||
{ | ||
RunsOn = BuildMachines.UbuntuLatest, | ||
|
||
Steps = new List<GithubTask> | ||
{ | ||
new CheckoutTaskV3 | ||
{ | ||
Name = "Check out" | ||
}, | ||
|
||
new SetupDotNetTaskV3 | ||
{ | ||
Name = "Setup .Net", | ||
|
||
With = new TargetDotNetVersionV3 | ||
{ | ||
DotNetVersion = "7.0.201" | ||
} | ||
}, | ||
|
||
new RestoreTask | ||
{ | ||
Name = "Restore" | ||
}, | ||
|
||
new DotNetBuildTask | ||
{ | ||
Name = "Build" | ||
}, | ||
|
||
new TestTask | ||
{ | ||
Name = "Test" | ||
} | ||
} | ||
} | ||
}, | ||
{ | ||
"add_tag", | ||
new TagJob( | ||
runsOn: BuildMachines.UbuntuLatest, | ||
dependsOn: "build", | ||
projectRelativePath: "STX.SPAL.Core/" + | ||
"STX.SPAL.Core.csproj", | ||
githubToken: "${{ secrets.PAT_FOR_TAGGING }}", | ||
branchName: branchName) | ||
}, | ||
{ | ||
"publish", | ||
new PublishJob( | ||
runsOn: BuildMachines.UbuntuLatest, | ||
dependsOn: "add_tag", | ||
nugetApiKey: "${{ secrets.NUGET_ACCESS }}") | ||
} | ||
} | ||
}; | ||
|
||
string buildScriptPath = "../../../../.github/workflows/build.yml"; | ||
string directoryPath = Path.GetDirectoryName(buildScriptPath); | ||
|
||
if (!Directory.Exists(directoryPath)) | ||
{ | ||
Directory.CreateDirectory(directoryPath); | ||
} | ||
|
||
adotNetClient.SerializeAndWriteToFile( | ||
adoPipeline: githubPipeline, | ||
path: buildScriptPath); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio Version 17 | ||
VisualStudioVersion = 17.9.34607.119 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "STX.SPAL.Abstractions.Infrastructure.Build", "STX.SPAL.Abstractions.Infrastructure.Build\STX.SPAL.Abstractions.Infrastructure.Build.csproj", "{2D431C20-BE0E-4C25-9C89-3111EFE3737E}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{2D431C20-BE0E-4C25-9C89-3111EFE3737E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{2D431C20-BE0E-4C25-9C89-3111EFE3737E}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{2D431C20-BE0E-4C25-9C89-3111EFE3737E}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{2D431C20-BE0E-4C25-9C89-3111EFE3737E}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
GlobalSection(ExtensibilityGlobals) = postSolution | ||
SolutionGuid = {6D7B900D-5E0A-4553-8E9C-E6AA90E02CC2} | ||
EndGlobalSection | ||
EndGlobal |
28 changes: 28 additions & 0 deletions
28
STX.SPAL.Core/STX.SPAL.Core.Tests.Acceptance/STX.SPAL.Core.Tests.Acceptance.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net8.0</TargetFramework> | ||
<ImplicitUsings>disable</ImplicitUsings> | ||
<Nullable>disable</Nullable> | ||
<IsPackable>false</IsPackable> | ||
<IsTestProject>true</IsTestProject> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.6.0" /> | ||
<PackageReference Include="xunit" Version="2.4.2" /> | ||
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5"> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
<PrivateAssets>all</PrivateAssets> | ||
</PackageReference> | ||
<PackageReference Include="coverlet.collector" Version="6.0.0"> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
<PrivateAssets>all</PrivateAssets> | ||
</PackageReference> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<Using Include="Xunit" /> | ||
</ItemGroup> | ||
|
||
</Project> |
Oops, something went wrong.