Skip to content

Commit

Permalink
Add additional build steps in preparation for opensourcing this repo (#…
Browse files Browse the repository at this point in the history
…24)

* add NOTICE.txt

* ensure NOTICE.txt gets packaged with every redistributable

* rename LICENSE to LICENSE.txt

* cleanup Directory Build props

* print and validate license information as part of the build

* ensure .NET 7 is installed on CI
  • Loading branch information
Mpdreamz authored Jan 16, 2024
1 parent 06a4de8 commit 1548ff4
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 7 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,11 @@ jobs:
git tag --list
- uses: actions/setup-dotnet@v1
with:
# .NET 7 is sadly required for the licenses check tool
# https://github.com/tomchavakis/nuget-license/issues/200
dotnet-version: |
6.0.x
7.0.x
8.0.x
source-url: https://nuget.pkg.github.com/elastic/index.json
env:
Expand Down
File renamed without changes.
2 changes: 2 additions & 0 deletions NOTICE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Elastic .NET OpenTelemetry Distribution
Copyright 2012-2024 Elasticsearch B.V.
1 change: 1 addition & 0 deletions build/forbidden-license-types.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
["AGPL-3.0-only", "OSL-3.0", "NPOSL-3.0", "AFL-3.0", "APSL-1.2", "RPSL-1.0", "RPL-1.5", "HPL"]
2 changes: 2 additions & 0 deletions build/scripts/CommandLine.fs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ type Build =

| [<CliPrefix(CliPrefix.None);Hidden;SubCommand>] PristineCheck
| [<CliPrefix(CliPrefix.None);Hidden;SubCommand>] GeneratePackages
| [<CliPrefix(CliPrefix.None);Hidden;SubCommand>] ValidateLicenses
| [<CliPrefix(CliPrefix.None);Hidden;SubCommand>] ValidatePackages
| [<CliPrefix(CliPrefix.None);Hidden;SubCommand>] GenerateReleaseNotes
| [<CliPrefix(CliPrefix.None);Hidden;SubCommand>] GenerateApiChanges
Expand All @@ -39,6 +40,7 @@ with
// steps
| PristineCheck
| GeneratePackages
| ValidateLicenses
| ValidatePackages
| GenerateReleaseNotes
| GenerateApiChanges -> "Undocumented, dependent target"
Expand Down
11 changes: 9 additions & 2 deletions build/scripts/Targets.fs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ let private version _ =
let version = Software.Version
printfn $"Informational version: %s{version.AsString}"
printfn $"Semantic version: %s{version.NormalizeToShorter()}"

let private generatePackages _ = exec { run "dotnet" "pack" }

let private pristineCheck (arguments:ParseResults<Build>) =
Expand All @@ -55,6 +55,12 @@ let private test _ =
)
}

let private validateLicenses _ =
let args = ["-u"; "-t"; "-i"; "Elastic.OpenTelemetry.sln"; "--use-project-assets-json"
"--forbidden-license-types"; "build/forbidden-license-types.json"
"--packages-filter"; "#System\..*#";]
exec { run "dotnet" (["dotnet-project-licenses"] @ args) }

let private validatePackages _ =
let packagesPath = Paths.ArtifactPath "package"
let output = Paths.RelativePathToRoot <| packagesPath.FullName
Expand Down Expand Up @@ -124,12 +130,13 @@ let Setup (parsed:ParseResults<Build>) =
| Release ->
Build.Cmd
[PristineCheck; Test]
[GeneratePackages; ValidatePackages; GenerateReleaseNotes; GenerateApiChanges]
[ValidateLicenses; GeneratePackages; ValidatePackages; GenerateReleaseNotes; GenerateApiChanges]
release

// steps
| PristineCheck -> Build.Step pristineCheck
| GeneratePackages -> Build.Step generatePackages
| ValidateLicenses -> Build.Step validateLicenses
| ValidatePackages -> Build.Step validatePackages
| GenerateReleaseNotes -> Build.Step generateReleaseNotes
| GenerateApiChanges -> Build.Step generateApiChanges
Expand Down
6 changes: 6 additions & 0 deletions dotnet-tools.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@
"commands": [
"nupkg-validator"
]
},
"dotnet-project-licenses": {
"version": "2.7.1",
"commands": [
"dotnet-project-licenses"
]
}
}
}
9 changes: 4 additions & 5 deletions src/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,16 @@
</PropertyGroup>

<ItemGroup>
<Content Include="README.md" Pack="true" PackagePath="README.md" CopyToOutputDirectory="PreserveNewest"/>
<Content Include="README.md" Pack="true" PackagePath="README.md" CopyToOutputDirectory="PreserveNewest" />
<None Include="$(SolutionRoot)\NOTICE.txt" CopyToOutputDirectory="PreserveNewest" Pack="True" PackagePath="NOTICE.txt" />
<None Include="$(SolutionRoot)\LICENSE.txt" CopyToOutputDirectory="PreserveNewest" Pack="True" PackagePath="LICENSE.txt" />
<Content Include="$(SolutionRoot)\build\nuget-icon.png" CopyToOutputDirectory="PreserveNewest">
<Link>nuget-icon.png</Link>
<Pack>True</Pack>
<PackagePath>nuget-icon.png</PackagePath>
</Content>
<None Include="$(SolutionRoot)\LICENSE" CopyToOutputDirectory="PreserveNewest">
<Pack>True</Pack>
<PackagePath>LICENSE</PackagePath>
</None>
</ItemGroup>


<ItemGroup>
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0" PrivateAssets="All"/>
Expand Down

0 comments on commit 1548ff4

Please sign in to comment.