Skip to content

Commit

Permalink
Merge branch 'main' into feature/multiple-targets
Browse files Browse the repository at this point in the history
  • Loading branch information
martinsmith1968 committed Aug 24, 2024
2 parents f5105c9 + ee78423 commit 4626d70
Show file tree
Hide file tree
Showing 11 changed files with 290 additions and 38 deletions.
187 changes: 150 additions & 37 deletions .github/workflows/ci-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,19 @@ name: CI Build
run-name: CIBuild_${{ github.event_name }}_${{ github.ref_name }}_${{ github.run_number }}.${{ github.run_attempt }}

env:
PKG_MAJOR_VERSION: 1.2
PKG_MAJOR_VERSION: 1.3
PROJECT_NAME: DNX.Extensions
DOTNET_VERSION: 8.0.x
NUGET_VERSION: 5.x
BUILD_CONFIG: Release
BUILD_PLATFORM: Any CPU
PACK_PARAMETERS: ''
COVERAGE_WARNING_THRESHOLD: 60
COVERAGE_ERROR_THRESHOLD: 80
COVERAGE_WARNING_THRESHOLD: 95
COVERAGE_ERROR_THRESHOLD: 85
NUGET_OUTPUT_FOLDER: nupkgs
BRANCH_PREFIX_RELEASE_CANDIDATE: rc/
BRANCH_PREFIX_PUBLISH_CANDIDATE: beta/
BRANCH_NAME_BENCHMARK_CANDIDATE: benchmark

on:
push:
Expand All @@ -40,39 +41,79 @@ jobs:

steps:
- name: Get Current Build Date
id: build_date
run: echo "build_date=$(date +'%y%j')" >> $GITHUB_ENV

- name: Set Package Suffix
id: package_suffix
- name: Evaluate pipeline conditions
run: |
branch="${{ github.ref }}"
package_suffix=''
is_primary_branch=false
is_pull_request_build=false
is_release_candidate_branch=false
is_publish_candidate_branch=false
is_benchmark_candidate_branch=false
if [ "$branch" != "refs/heads/main" ]
# Primary Branch ?
if [ "${{ github.ref }}" == 'refs/heads/main' ]
then
package_suffix='-beta'
is_primary_branch=true
fi
echo "package_suffix=${package_suffix}" >> $GITHUB_ENV
# Pull Request ?
if [ "${{ github.event_name }}" == "pull_request" ]
then
is_pull_request_build=true
fi
# If Release Candidate branch ?
if [[ "${{ github.ref }}" == refs/heads/${{ env.BRANCH_PREFIX_RELEASE_CANDIDATE }}* ]]
then
is_release_candidate_branch=true
fi
# Is Publish Candidate branch ?
if [[ "${{ github.ref }}" == refs/heads/${{ env.BRANCH_PREFIX_PUBLISH_CANDIDATE }}* ]]
then
is_publish_candidate_branch=true
fi
# Is Benchmark Candidate branch ?
if [[ "${{ github.ref }}" == *${{ env.BRANCH_NAME_BENCHMARK_CANDIDATE }}* ]]
then
is_benchmark_candidate_branch=true
fi
# Set for later steps
echo "is_primary_branch=${is_primary_branch}" >> $GITHUB_ENV
echo "is_pull_request_build=${is_pull_request_build}" >> $GITHUB_ENV
echo "is_release_candidate_branch=${is_release_candidate_branch}" >> $GITHUB_ENV
echo "is_publish_candidate_branch=${is_publish_candidate_branch}" >> $GITHUB_ENV
echo "is_benchmark_candidate_branch=${is_benchmark_candidate_branch}" >> $GITHUB_ENV
- name: Determine Tagging
run: |
should_tag=false
if $is_primary_branch
then
should_tag=true
fi
echo "should_tag=${should_tag}" >> $GITHUB_ENV
- name: Determing GitHub Releasing
id: should_release
- name: Determine GitHub Releasing
run: |
should_release=false
release_is_draft=false
release_is_prerelease=false
if [ "${{ github.ref }}" == 'refs/heads/main' ]
if $is_primary_branch
then
should_release=true
elif [[ "${{ github.ref }}" == refs/heads/${{ env.BRANCH_PREFIX_RELEASE_CANDIDATE }}* ]]
elif $is_release_candidate_branch
then
should_release=true
release_is_draft=true
if [ "${{ github.event_name }}" == "pull_request" ]
then
if $is_pull_request_build; then
release_is_draft=false
release_is_prerelease=true
fi
Expand All @@ -82,49 +123,80 @@ jobs:
echo "release_is_draft=${release_is_draft}" >> $GITHUB_ENV
echo "release_is_prerelease=${release_is_prerelease}" >> $GITHUB_ENV
- name: Determine Benchmarking
run: |
should_benchmark=false
if $should_release
then
should_benchmark=true
elif $is_pull_request_build
then
should_benchmark=true
elif $is_benchmark_candidate_branch
then
should_benchmark=true
fi
echo "should_benchmark=${should_benchmark}" >> $GITHUB_ENV
- name: Determine package publishing
id: should_publish
run: |
should_publish=false
if [ "${{ github.event_name }}" == "pull_request" ]
if $is_primary_branch
then
should_publish=true
elif [ "${{ github.ref }}" == "refs/heads/main" ]
elif $is_pull_request_build
then
should_publish=true
elif [[ "${{ github.ref }}" == refs/heads/${{ env.BRANCH_PREFIX_PUBLISH_CANDIDATE }}* ]]
elif $is_publish_candidate_branch
then
should_publish=true
fi
echo "should_publish=${should_publish}" >> $GITHUB_ENV
- name: Set Package Suffix
run: |
package_suffix=''
if !($is_primary_branch)
then
package_suffix='-beta'
if $should_release
then
package_suffix='-rc'
fi
fi
echo "package_suffix=${package_suffix}" >> $GITHUB_ENV
- name: Set Product Version
id: product_version
run: echo "product_version=${{ env.PKG_MAJOR_VERSION }}" >> $GITHUB_ENV

- name: Set Assembly Version
id: assembly_version
run: echo "assembly_version=${{ env.PKG_MAJOR_VERSION }}.${{ env.build_date }}.${{ github.run_number }}${{ github.run_attempt }}" >> $GITHUB_ENV

- name: Set Package Version
id: package_version
run: echo "package_version=${{ env.assembly_version }}${{ env.package_suffix }}" >> $GITHUB_ENV

- name: Show Configuration
id: show_configuration
run: env | sort

outputs:
assembly_version: ${{ env.assembly_version }}
product_version: ${{ env.product_version }}
package_version: ${{ env.package_version }}
should_tag: ${{ env.should_tag }}
should_publish: ${{ env.should_publish }}
should_release: ${{ env.should_release }}
should_benchmark: ${{ env.should_benchmark }}
release_is_draft: ${{ env.release_is_draft }}
release_is_prerelease: ${{ env.release_is_prerelease }}


##########################################################
## Build DotNet projects
build:
Expand Down Expand Up @@ -160,8 +232,6 @@ jobs:
comment-title: 'Unit Test Results'
results-path: "**/*.trx"
coverage-type: cobertura
#coverage-path: "**/coverage.cobertura.xml"
#coverage-threshold: ${{ env.COVERAGE_WARNING_THRESHOLD }}

- name: Code Coverage Report
uses: irongut/[email protected]
Expand Down Expand Up @@ -204,8 +274,32 @@ jobs:
path: "${{ env.NUGET_OUTPUT_FOLDER }}/**"
if-no-files-found: error


##########################################################
## Tag in git
tag:
name: Tag in GitHub
if: needs.setup.outputs.should_tag == 'true'

needs:
- setup
- build

runs-on: ubuntu-latest

steps:
- name: Tag git
uses: pkgdeps/git-tag-action@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
github_repo: ${{ github.repository }}
git_commit_sha: ${{ github.sha }}
git_tag_prefix: "v"
version: ${{ needs.setup.outputs.assembly_version }}


##########################################################
## Generate a Release and Tag in git
## Generate a GitHub Release
release:
name: Create GitHub Release
if: needs.setup.outputs.should_release == 'true'
Expand All @@ -226,7 +320,6 @@ jobs:
path: nuget

- name: Build Changelog
id: build_changelog
uses: mikepenz/release-changelog-builder-action@v5
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand All @@ -242,14 +335,35 @@ jobs:
removeArtifacts: true
artifacts: '**/*.nupkg'

- name: Tag git
uses: pkgdeps/git-tag-action@v3

##########################################################
## Benchmark Performance
benchmark:
name: Benchmark Performance
if: needs.setup.outputs.should_benchmark == 'true'

needs:
- setup
- build

runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Install .NET SDK
uses: actions/setup-dotnet@v4
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
github_repo: ${{ github.repository }}
git_commit_sha: ${{ github.sha }}
git_tag_prefix: "v"
version: ${{ needs.setup.outputs.assembly_version }}
dotnet-version: ${{ env.DOTNET_VERSION }}

- name: Run Benchmarks
run: dotnet run --configuration ${{ env.BUILD_CONFIG }} --project tests/DNX.Extensions.Benchmarks

- name: Publish Benchmark output
run: |
cat BenchmarkDotNet.Artifacts/results/*Benchmarks-report-github.md >> $GITHUB_STEP_SUMMARY
##########################################################
## Publish to NuGet
Expand All @@ -271,7 +385,6 @@ jobs:
nuget-version: ${{ env.NUGET_VERSION }}

- name: Download NuGet Output
id: download_nuget
uses: actions/download-artifact@v4
with:
name: nuget_output
Expand Down
9 changes: 9 additions & 0 deletions DNX.Extensions.sln
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,12 @@ EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".docs", ".docs", "{8700E3D9-9248-4679-A0E8-8AB3E0B3B09D}"
ProjectSection(SolutionItems) = preProject
LICENSE = LICENSE
README.md = README.md
To Do.md = To Do.md
EndProjectSection
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DNX.Extensions.Benchmarks", "tests\DNX.Extensions.Benchmarks\DNX.Extensions.Benchmarks.csproj", "{D9664527-B415-498F-B8A9-9AF016D7D91F}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -40,13 +44,18 @@ Global
{B14EFA70-CA77-4439-9C08-357061B97E4D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B14EFA70-CA77-4439-9C08-357061B97E4D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B14EFA70-CA77-4439-9C08-357061B97E4D}.Release|Any CPU.Build.0 = Release|Any CPU
{D9664527-B415-498F-B8A9-9AF016D7D91F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D9664527-B415-498F-B8A9-9AF016D7D91F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D9664527-B415-498F-B8A9-9AF016D7D91F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D9664527-B415-498F-B8A9-9AF016D7D91F}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{E2B8F640-BCFE-4BD7-B158-E7FE957A38CB} = {E832563B-3DD6-4CCD-B5DA-91F89AE3B98A}
{B14EFA70-CA77-4439-9C08-357061B97E4D} = {27BBD260-1C33-4F57-925A-12AB922D6AB5}
{D9664527-B415-498F-B8A9-9AF016D7D91F} = {27BBD260-1C33-4F57-925A-12AB922D6AB5}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {A971C3D4-3729-43C6-88E7-16371F03161F}
Expand Down
20 changes: 20 additions & 0 deletions To Do.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# TO DO

## Variables with multiple values

- https://github.com/orgs/community/discussions/46785

## Multi Targeting

- https://learn.microsoft.com/en-us/answers/questions/1398343/nuget-how-can-i-make-a-single-nuget-package-target
- https://runs-on.com/github-actions/the-matrix-strategy/
- https://github.com/NuGet/setup-nuget

## Better Test Reporting ?

- https://github.com/marketplace/actions/dotnet-test-reporter

## NuGet signing

- https://timheuer.com/blog/use-nuget-with-github-actions-github-packages/
-
7 changes: 6 additions & 1 deletion src/DNX.Extensions/DNX.Extensions.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<Platforms>x64;x86;AnyCPU</Platforms>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<Nullable>disable</Nullable>
<IsPackable>true</IsPackable>
</PropertyGroup>

<PropertyGroup>
Expand All @@ -19,11 +20,15 @@
<PackageIcon>favicon-32x32.png</PackageIcon>
<PackageIconUrl>https://raw.githubusercontent.com/martinsmith1968/DNX.Extensions/main/images/favicon-32x32.png</PackageIconUrl>
<PackageReleaseNotes>
Interpolation to a working version and some preparation for moving to .NET Standard
Migration from DNX.Helpers
</PackageReleaseNotes>
</PropertyGroup>

<ItemGroup>
<None Include="../../README.md">
<Pack>True</Pack>
<PackagePath></PackagePath>
</None>
<None Include="../../LICENSE">
<Pack>True</Pack>
<PackagePath></PackagePath>
Expand Down
2 changes: 2 additions & 0 deletions src/DNX.Extensions/IO/DirectoryInfoExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,12 @@ public static string GetRelativePath(this DirectoryInfo directoryInfo, Directory
: GetRelativePath(directoryInfo.FullName, owningDirectoryInfo.FullName)
.RemoveStartsWith($".{Path.DirectorySeparatorChar}");

#if NETSTANDARD2_1_OR_GREATER
if (relativePath == ".")
{
relativePath = string.Empty;
}
#endif

return relativePath;
}
Expand Down
Loading

0 comments on commit 4626d70

Please sign in to comment.