Skip to content

Commit

Permalink
Added publishing as NuGet #132 (#139)
Browse files Browse the repository at this point in the history
  • Loading branch information
BernieWhite committed Aug 4, 2022
1 parent 62c4e5c commit 6c30662
Show file tree
Hide file tree
Showing 19 changed files with 106 additions and 37 deletions.
2 changes: 1 addition & 1 deletion .ps-rule/Rule.Rule.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Rule 'Rule.Name' -Type 'PSRule.Rules.Rule' {
Recommend 'Rule name should be less than 35 characters to prevent being truncated.'
Reason 'The rule name is too long.'
$Assert.LessOrEqual($TargetObject, 'RuleName', 35)
$Assert.StartsWith($TargetObject, 'RuleName', 'GitHub.')
$Assert.StartsWith($TargetObject, 'RuleName', "$($Configuration.RULE_AUTHORING_PREFIX).")
}

# Synopsis: Complete help documentation
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
What's changed since v0.2.0:

- Engineering:
- Added support for NuGet publishing by @BernieWhite.
[#132](https://github.com/microsoft/PSRule.Rules.GitHub/issues/132)
- Bump PSRule to v2.2.0.
[#123](https://github.com/microsoft/PSRule.Rules.GitHub/pull/123)
- Bump Octokit to v1.0.1.
Expand Down
44 changes: 29 additions & 15 deletions PSRule.Rules.GitHub.sln
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.30104.148
# Visual Studio Version 17
VisualStudioVersion = 17.2.32630.192
MinimumVisualStudioVersion = 15.0.26124.0
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PSRule.Rules.GitHub", "src\PSRule.Rules.GitHub\PSRule.Rules.GitHub.csproj", "{D6140D02-6DFF-40BB-A472-3A79AF7341FC}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PSRule.Rules.GitHub.Tests", "tests\PSRule.Rules.GitHub.Tests\PSRule.Rules.GitHub.Tests.csproj", "{60EEBE4F-78B9-47A1-9F4C-FF4E704D23C3}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PSRule.Rules.GitHub.Tests", "tests\PSRule.Rules.GitHub.Tests\PSRule.Rules.GitHub.Tests.csproj", "{9FF459F0-C7BC-4936-9FC3-4D92B30B02A1}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SDK", "src\SDK\SDK.csproj", "{2698482D-5A3D-4D8E-983E-DE70D45BF3B2}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand All @@ -29,18 +31,30 @@ Global
{D6140D02-6DFF-40BB-A472-3A79AF7341FC}.Release|x64.Build.0 = Release|Any CPU
{D6140D02-6DFF-40BB-A472-3A79AF7341FC}.Release|x86.ActiveCfg = Release|Any CPU
{D6140D02-6DFF-40BB-A472-3A79AF7341FC}.Release|x86.Build.0 = Release|Any CPU
{60EEBE4F-78B9-47A1-9F4C-FF4E704D23C3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{60EEBE4F-78B9-47A1-9F4C-FF4E704D23C3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{60EEBE4F-78B9-47A1-9F4C-FF4E704D23C3}.Debug|x64.ActiveCfg = Debug|Any CPU
{60EEBE4F-78B9-47A1-9F4C-FF4E704D23C3}.Debug|x64.Build.0 = Debug|Any CPU
{60EEBE4F-78B9-47A1-9F4C-FF4E704D23C3}.Debug|x86.ActiveCfg = Debug|Any CPU
{60EEBE4F-78B9-47A1-9F4C-FF4E704D23C3}.Debug|x86.Build.0 = Debug|Any CPU
{60EEBE4F-78B9-47A1-9F4C-FF4E704D23C3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{60EEBE4F-78B9-47A1-9F4C-FF4E704D23C3}.Release|Any CPU.Build.0 = Release|Any CPU
{60EEBE4F-78B9-47A1-9F4C-FF4E704D23C3}.Release|x64.ActiveCfg = Release|Any CPU
{60EEBE4F-78B9-47A1-9F4C-FF4E704D23C3}.Release|x64.Build.0 = Release|Any CPU
{60EEBE4F-78B9-47A1-9F4C-FF4E704D23C3}.Release|x86.ActiveCfg = Release|Any CPU
{60EEBE4F-78B9-47A1-9F4C-FF4E704D23C3}.Release|x86.Build.0 = Release|Any CPU
{9FF459F0-C7BC-4936-9FC3-4D92B30B02A1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9FF459F0-C7BC-4936-9FC3-4D92B30B02A1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9FF459F0-C7BC-4936-9FC3-4D92B30B02A1}.Debug|x64.ActiveCfg = Debug|Any CPU
{9FF459F0-C7BC-4936-9FC3-4D92B30B02A1}.Debug|x64.Build.0 = Debug|Any CPU
{9FF459F0-C7BC-4936-9FC3-4D92B30B02A1}.Debug|x86.ActiveCfg = Debug|Any CPU
{9FF459F0-C7BC-4936-9FC3-4D92B30B02A1}.Debug|x86.Build.0 = Debug|Any CPU
{9FF459F0-C7BC-4936-9FC3-4D92B30B02A1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9FF459F0-C7BC-4936-9FC3-4D92B30B02A1}.Release|Any CPU.Build.0 = Release|Any CPU
{9FF459F0-C7BC-4936-9FC3-4D92B30B02A1}.Release|x64.ActiveCfg = Release|Any CPU
{9FF459F0-C7BC-4936-9FC3-4D92B30B02A1}.Release|x64.Build.0 = Release|Any CPU
{9FF459F0-C7BC-4936-9FC3-4D92B30B02A1}.Release|x86.ActiveCfg = Release|Any CPU
{9FF459F0-C7BC-4936-9FC3-4D92B30B02A1}.Release|x86.Build.0 = Release|Any CPU
{2698482D-5A3D-4D8E-983E-DE70D45BF3B2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2698482D-5A3D-4D8E-983E-DE70D45BF3B2}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2698482D-5A3D-4D8E-983E-DE70D45BF3B2}.Debug|x64.ActiveCfg = Debug|Any CPU
{2698482D-5A3D-4D8E-983E-DE70D45BF3B2}.Debug|x64.Build.0 = Debug|Any CPU
{2698482D-5A3D-4D8E-983E-DE70D45BF3B2}.Debug|x86.ActiveCfg = Debug|Any CPU
{2698482D-5A3D-4D8E-983E-DE70D45BF3B2}.Debug|x86.Build.0 = Debug|Any CPU
{2698482D-5A3D-4D8E-983E-DE70D45BF3B2}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2698482D-5A3D-4D8E-983E-DE70D45BF3B2}.Release|Any CPU.Build.0 = Release|Any CPU
{2698482D-5A3D-4D8E-983E-DE70D45BF3B2}.Release|x64.ActiveCfg = Release|Any CPU
{2698482D-5A3D-4D8E-983E-DE70D45BF3B2}.Release|x64.Build.0 = Release|Any CPU
{2698482D-5A3D-4D8E-983E-DE70D45BF3B2}.Release|x86.ActiveCfg = Release|Any CPU
{2698482D-5A3D-4D8E-983E-DE70D45BF3B2}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
category: Branch
severity: Awareness
online version: https://github.com/Microsoft/PSRule.Rules.GitHub/blob/main/docs/rules/en/GitHub.Branch.Name.md
online version: https://github.com/microsoft/PSRule.Rules.GitHub/blob/main/docs/en/rules/GitHub.Branch.Name.md
---

# Use consistent branch names
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
category: Repository
severity: Awareness
online version: https://github.com/Microsoft/PSRule.Rules.GitHub/blob/main/docs/rules/en/GitHub.Repo.CodeOfConduct.md
online version: https://github.com/microsoft/PSRule.Rules.GitHub/blob/main/docs/en/rules/GitHub.Repo.CodeOfConduct.md
---

# Use a CODE_OF_CONDUCT file
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
category: Repository
severity: Important
online version: https://github.com/Microsoft/PSRule.Rules.GitHub/blob/main/docs/rules/en/GitHub.Repo.CodeOwners.md
online version: https://github.com/microsoft/PSRule.Rules.GitHub/blob/main/docs/en/rules/GitHub.Repo.CodeOwners.md
---

# Use a CODEOWNERS file
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
category: Repository
severity: Important
online version: https://github.com/Microsoft/PSRule.Rules.GitHub/blob/main/docs/rules/en/GitHub.Repo.Contributing.md
online version: https://github.com/microsoft/PSRule.Rules.GitHub/blob/main/docs/en/rules/GitHub.Repo.Contributing.md
---

# Use a CONTRIBUTING file
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
category: Repository
severity: Awareness
online version: https://github.com/Microsoft/PSRule.Rules.GitHub/blob/main/docs/rules/en/GitHub.Repo.Description.md
online version: https://github.com/microsoft/PSRule.Rules.GitHub/blob/main/docs/en/rules/GitHub.Repo.Description.md
---

# Set a repository description
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
category: Repository
severity: Awareness
online version: https://github.com/Microsoft/PSRule.Rules.GitHub/blob/main/docs/rules/en/GitHub.Repo.IssueTemplate.md
online version: https://github.com/microsoft/PSRule.Rules.GitHub/blob/main/docs/en/rules/GitHub.Repo.IssueTemplate.md
---

# Use issue templates
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
category: Repository
severity: Important
online version: https://github.com/Microsoft/PSRule.Rules.GitHub/blob/main/docs/rules/en/GitHub.Repo.License.md
online version: https://github.com/microsoft/PSRule.Rules.GitHub/blob/main/docs/en/rules/GitHub.Repo.License.md
---

# Use a LICENSE file
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
category: Repository
severity: Awareness
online version: https://github.com/Microsoft/PSRule.Rules.GitHub/blob/main/docs/rules/en/GitHub.Repo.PRTemplate.md
online version: https://github.com/microsoft/PSRule.Rules.GitHub/blob/main/docs/en/rules/GitHub.Repo.PRTemplate.md
---

# Use a PR template
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
category: Repository
severity: Critical
online version: https://github.com/Microsoft/PSRule.Rules.GitHub/blob/main/docs/rules/en/GitHub.Repo.Protected.md
online version: https://github.com/microsoft/PSRule.Rules.GitHub/blob/main/docs/en/rules/GitHub.Repo.Protected.md
---

# Use branch protection on the default branch
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
category: Repository
severity: Important
online version: https://github.com/Microsoft/PSRule.Rules.GitHub/blob/main/docs/rules/en/GitHub.Repo.Readme.md
online version: https://github.com/microsoft/PSRule.Rules.GitHub/blob/main/docs/en/rules/GitHub.Repo.Readme.md
---

# Use a README file
Expand Down
File renamed without changes.
8 changes: 4 additions & 4 deletions pipeline.build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ task ModuleDependencies Dependencies, {
task BuildDotNet {
exec {
# Build library
# dotnet build src/SDK -c $Configuration -f netstandard2.0 -p:version=$Build
dotnet build src/SDK -c $Configuration -f netstandard2.0 -p:version=$Build
dotnet publish src/PSRule.Rules.GitHub -c $Configuration -f netstandard2.0 -o $(Join-Path -Path $PWD -ChildPath out/modules/PSRule.Rules.GitHub) -p:version=$Build
}
}
Expand Down Expand Up @@ -299,8 +299,8 @@ task Analyze Build, Dependencies, {
# Synopsis: Build table of content for rules
task BuildRuleDocs Build, Dependencies, {
Import-Module (Join-Path -Path $PWD -ChildPath out/modules/PSRule.Rules.GitHub) -Force;
$Null = Invoke-PSDocument -Name module -OutputPath .\docs\rules\en\ -Path .\RuleToc.Doc.ps1;
$Null = Invoke-PSDocument -Name resource -OutputPath .\docs\rules\en\ -Path .\RuleToc.Doc.ps1;
$Null = Invoke-PSDocument -Name module -OutputPath .\docs\en\rules\ -Path .\RuleToc.Doc.ps1;
$Null = Invoke-PSDocument -Name resource -OutputPath .\docs\en\rules\ -Path .\RuleToc.Doc.ps1;
}

# Synopsis: Build help
Expand All @@ -318,7 +318,7 @@ task BuildHelp BuildModule, Dependencies, {
$Null = New-Item -Path out/modules/PSRule.Rules.GitHub/en-GB/ -ItemType Directory -Force;
}

$Null = Copy-Item -Path docs/rules/en/*.md -Destination out/modules/PSRule.Rules.GitHub/en/;
$Null = Copy-Item -Path docs/en/rules/*.md -Destination out/modules/PSRule.Rules.GitHub/en/;

# Avoid YamlDotNet issue in same app domain
exec {
Expand Down
11 changes: 11 additions & 0 deletions src/PSRule.Common.props
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,14 @@
<!-- Project defaults -->
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<LangVersion>9.0</LangVersion>
<NeutralLanguage>en-US</NeutralLanguage>
<DebugSymbols>true</DebugSymbols>
<DebugType>portable</DebugType>
<IncludeSymbols>true</IncludeSymbols>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
<EmbedUntrackedSources>true</EmbedUntrackedSources>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
</PropertyGroup>

<!-- Package metadata -->
Expand Down Expand Up @@ -39,6 +46,10 @@ This project uses GitHub Issues to track bugs and feature requests. See GitHub p
<ContinuousIntegrationBuild>true</ContinuousIntegrationBuild>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="All" />
</ItemGroup>

<ItemGroup>
<None Include="..\..\docs\assets\package_icon.png">
<Pack>True</Pack>
Expand Down
7 changes: 0 additions & 7 deletions src/PSRule.Rules.GitHub/PSRule.Rules.GitHub.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,14 @@
<PropertyGroup>
<AssemblyName>Microsoft.PSRule.Rules.GitHub.Core</AssemblyName>
<RootNamespace>PSRule.Rules.GitHub</RootNamespace>
<LangVersion>8.0</LangVersion>
<OutputType>Library</OutputType>
<ProjectGuid>{d6140d02-6dff-40bb-a472-3a79af7341fc}</ProjectGuid>
<DebugType>portable</DebugType>
<DebugSymbols>true</DebugSymbols>
<GenerateAssemblyInfo>true</GenerateAssemblyInfo>
<PackageId>Microsoft.PSRule.Rules.GitHub.Core</PackageId>
<EnableNuget>false</EnableNuget>
<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="All" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Octokit" Version="1.0.1" />
<PackageReference Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="6.0.0">
Expand Down
3 changes: 3 additions & 0 deletions src/SDK/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# PSRule for GitHub

This package contains rules for evaluating GitHub repositories using PSRule.
46 changes: 46 additions & 0 deletions src/SDK/SDK.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="..\PSRule.Common.props" />
<PropertyGroup>
<PackageId>Microsoft.PSRule.Rules.GitHub</PackageId>
<ProjectGuid>cf95c5d3-c49a-4af1-9c3c-e9515126868e</ProjectGuid>
<EnableNuget>true</EnableNuget>
<PackageReadmeFile>README.md</PackageReadmeFile>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\PSRule.Rules.GitHub\PSRule.Rules.GitHub.csproj" PrivateAssets="all" />
</ItemGroup>

<ItemGroup>
<Content Include="..\PSRule.Rules.GitHub\*.psd1;..\PSRule.Rules.GitHub\*.psm1;">
<PackageCopyToOutput>true</PackageCopyToOutput>
<PackagePath>contentFiles\any\any\Modules\PSRule.Rules.GitHub;content\Modules\PSRule.Rules.GitHub</PackagePath>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
</Content>
<Content Include="..\PSRule.Rules.GitHub\rules\*">
<PackageCopyToOutput>true</PackageCopyToOutput>
<PackagePath>contentFiles\any\any\Modules\PSRule.Rules.GitHub\rules;content\Modules\PSRule.Rules.GitHub\rules</PackagePath>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
</Content>
<Content Include="..\..\docs\en\rules\*.md">
<PackageCopyToOutput>true</PackageCopyToOutput>
<PackagePath>contentFiles\any\any\Modules\PSRule.Rules.GitHub\en;content\Modules\PSRule.Rules.GitHub\en</PackagePath>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
</Content>

<Content Include="$(OutputPath)\Microsoft.PSRule.Rules.GitHub.Core.dll">
<Pack>true</Pack>
<PackageCopyToOutput>true</PackageCopyToOutput>
<PackagePath>contentFiles\any\any\Modules\PSRule.Rules.GitHub;content\Modules\PSRule.Rules.GitHub</PackagePath>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
</Content>
</ItemGroup>

<!-- <ItemGroup>
<PackageReference Include="Microsoft.PSRule.SDK" Version="2.3.0-B0001" />
</ItemGroup> -->
</Project>

0 comments on commit 6c30662

Please sign in to comment.