Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 78 additions & 0 deletions .github/workflows/build-and-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
name: Build and Publish NuGet Package

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
release:
types: [ published ]
workflow_dispatch:

env:
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
DOTNET_NOLOGO: true
DOTNET_CLI_TELEMETRY_OPTOUT: true

jobs:
build:
runs-on: windows-latest

steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0 # Required for Nerdbank.GitVersioning

- name: Setup .NET Framework 4.7.2
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
8.0.x

- name: Setup MSBuild
uses: microsoft/setup-msbuild@v1.3
with:
msbuild-architecture: x64

- name: Restore NuGet packages
run: dotnet restore Ancora.CodeSignTool.MSBuild.sln

- name: Build solution
run: dotnet build Ancora.CodeSignTool.MSBuild.sln --configuration Release --no-restore

- name: Pack NuGet package
run: dotnet pack src/Ancora.CodeSignTool.MSBuild/Ancora.CodeSignTool.MSBuild.csproj --configuration Release --no-build --output ./artifacts

- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: nuget-package
path: ./artifacts/*.nupkg

publish:
needs: build
runs-on: windows-latest
if: github.event_name == 'push' && github.ref == 'refs/heads/main' || github.event_name == 'release' || github.event_name == 'workflow_dispatch'

steps:
- name: Download build artifacts
uses: actions/download-artifact@v4
with:
name: nuget-package
path: ./artifacts

- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '8.0.x'

- name: Add GitHub NuGet source
run: dotnet nuget add source --username ${{ github.actor }} --password ${{ secrets.GITHUB_TOKEN }} --store-password-in-clear-text --name github "https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json"

- name: Publish to GitHub Packages
run: dotnet nuget push ./artifacts/*.nupkg --api-key ${{ secrets.GITHUB_TOKEN }} --source "github" --skip-duplicate

- name: Publish to NuGet.org (on release only)
if: github.event_name == 'release'
run: dotnet nuget push ./artifacts/*.nupkg --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json --skip-duplicate
2 changes: 1 addition & 1 deletion CodeSignToolTask.sln → Ancora.CodeSignTool.MSBuild.sln
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.0.32112.339
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CodeSignTool.MSBuild", "src\CodeSignTool.MSBuild\CodeSignTool.MSBuild.csproj", "{EEAC490E-8EA0-4AF1-9E62-16F7107BFFBF}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Ancora.CodeSignTool.MSBuild", "src\Ancora.CodeSignTool.MSBuild\Ancora.CodeSignTool.MSBuild.csproj", "{EEAC490E-8EA0-4AF1-9E62-16F7107BFFBF}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down
109 changes: 57 additions & 52 deletions Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,55 +1,60 @@
<Project TreatAsLocalProperty="RepoRoot">
<!-- Set these properties early enough for libraries. -->
<PropertyGroup>
<RepoRoot>$([MSBuild]::EnsureTrailingSlash('$(MSBuildThisFileDirectory)'))</RepoRoot>
</PropertyGroup>

<!-- Dependency versions -->
<PropertyGroup>
<NerdbankGitVersioningVersion>3.4.255</NerdbankGitVersioningVersion>
</PropertyGroup>

<!-- Branding -->
<PropertyGroup>
<Company>Ancora Software, Inc.</Company>
<CopyrightYear Condition=" '$(CopyrightYear)' == '' ">$([System.DateTime]::Now.ToString("yyyy"))</CopyrightYear>
<Copyright Condition=" '$(Copyright)' == '' ">Copyright © $(Company) $(CopyrightYear)</Copyright>
</PropertyGroup>

<!-- Nuget settings -->
<PropertyGroup>
<!-- Disable warning that we are using SemVer 2.0 verisioning -->
<NoWarn>$(NoWarn);NU5105</NoWarn>
<MinClientVersion>4.3</MinClientVersion>
<!-- Support nuget caching
<!-- Set these properties early enough for libraries. -->
<PropertyGroup>
<RepoRoot>$([MSBuild]::EnsureTrailingSlash('$(MSBuildThisFileDirectory)'))</RepoRoot>
</PropertyGroup>

<!-- Dependency versions -->
<PropertyGroup>
<NerdbankGitVersioningVersion>3.4.255</NerdbankGitVersioningVersion>
</PropertyGroup>

<!-- Branding -->
<PropertyGroup>
<Company>Ancora Software, Inc.</Company>
<CopyrightYear Condition=" '$(CopyrightYear)' == '' ">$([System.DateTime]::Now.ToString("yyyy"))</CopyrightYear>
<Copyright Condition=" '$(Copyright)' == '' ">Copyright © $(Company) $(CopyrightYear)</Copyright>
</PropertyGroup>

<!-- Nuget settings -->
<PropertyGroup>
<!-- Disable warning that we are using SemVer 2.0 verisioning -->
<NoWarn>$(NoWarn);NU5105</NoWarn>
<MinClientVersion>4.3</MinClientVersion>
<!-- Support nuget caching
see: https://devblogs.microsoft.com/nuget/enable-repeatable-package-restores-using-a-lock-file/ -->
<RestorePackagesWithLockFile>true</RestorePackagesWithLockFile>
</PropertyGroup>

<!-- Define test projects and companions -->
<PropertyGroup>
<IsTestProject>false</IsTestProject>
<IsTestProject Condition="$(MSBuildProjectName.EndsWith('Tests')) or $(MSBuildProjectName.EndsWith('Tests'))">true</IsTestProject>

<IsTestSupportProject>false</IsTestSupportProject>
<IsTestSupportProject Condition="($(MSBuildProjectFullPath.Contains('\tests\')) or $(MSBuildProjectFullPath.Contains('/tests/'))) and '$(IsTestProject)' != 'true'">true</IsTestSupportProject>

<!-- Treat test assemblies as non-shipping (do not publish or sign them). -->
<IsShipping Condition="'$(IsTestProject)' == 'true' or '$(IsTestSupportProject)' == 'true'">false</IsShipping>
</PropertyGroup>

<!-- Test environment -->
<PropertyGroup Condition="$(IsTestProject) == 'true'">
<IsPackable>false</IsPackable>
<IsPublishable>false</IsPublishable>
</PropertyGroup>

<!-- Common dependencies -->
<ItemGroup>
<PackageReference Include="Nerdbank.GitVersioning" Version="$(NerdbankGitVersioningVersion)">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
</ItemGroup>

<RestorePackagesWithLockFile>true</RestorePackagesWithLockFile>
</PropertyGroup>

<!-- Define test projects and companions -->
<PropertyGroup>
<IsTestProject>false</IsTestProject>
<IsTestProject
Condition="$(MSBuildProjectName.EndsWith('Tests')) or $(MSBuildProjectName.EndsWith('Tests'))">
true</IsTestProject>

<IsTestSupportProject>false</IsTestSupportProject>
<IsTestSupportProject
Condition="($(MSBuildProjectFullPath.Contains('\tests\')) or $(MSBuildProjectFullPath.Contains('/tests/'))) and '$(IsTestProject)' != 'true'">
true</IsTestSupportProject>

<!-- Treat test assemblies as non-shipping (do not publish or sign them). -->
<IsShipping Condition="'$(IsTestProject)' == 'true' or '$(IsTestSupportProject)' == 'true'">
false</IsShipping>
</PropertyGroup>

<!-- Test environment -->
<PropertyGroup Condition="$(IsTestProject) == 'true'">
<IsPackable>false</IsPackable>
<IsPublishable>false</IsPublishable>
</PropertyGroup>

<!-- Common dependencies -->
<ItemGroup>
<PackageReference Include="Nerdbank.GitVersioning" Version="$(NerdbankGitVersioningVersion)">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
</ItemGroup>

</Project>
17 changes: 17 additions & 0 deletions Directory.Build.targets
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

<!--
Copyright including year.
-->
<Target Name="Copyright" DependsOnTargets="GetBuildVersion" BeforeTargets="BeforeBuild;BeforePublish">
<PropertyGroup>
<!--
For properties available from the GetBuildVersion target,
see https://github.com/dotnet/Nerdbank.GitVersioning/blob/main/doc/msbuild.md#custom-build-authoring
-->
<CopyrightYear>$([System.DateTime]::New($(GitCommitDateTicks)).Year)</CopyrightYear>
<Copyright>Copyright © $(Company) $(CopyrightYear)</Copyright>
</PropertyGroup>
</Target>

</Project>
Loading