Skip to content

Commit b6538ba

Browse files
authored
chore: Improve SH github workflows BED-7214 (#200)
* normalize SH pull request templates * build with local version of SHCommon lib if available # Conflicts: # Sharphound.csproj * fix branch name * build dependency fixes * test commonlib change in pipeline * pipeline test * use Common v4 to build common lib * resolve coderabbit comments * done testing * explicit restore steps * add msbuild property PreferLocalLibs * test local libs build pipeline * fix csproj conditional * debug local libs in pipeline * fix syntax * debug logs * more logging * with common lib breaking change * syntax fix * msbuild diagnostics * minimal verbosity * implicit dotnet restore * implicit dotnet restore * try separate restore and build steps * final test against bed-7214 * switch order * asdf * build with breaking lib change * build off common v4 * setup csproj to handle dev, stable, or local libs * log common version used in build * test build with dev package * cleanup * versioned -dev common packages
1 parent 48d7c8f commit b6538ba

5 files changed

Lines changed: 74 additions & 78 deletions

File tree

.github/pull_request_template.md

Lines changed: 27 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,40 @@
11
## Description
2-
3-
<!--- Describe your changes in detail -->
2+
<!-- Describe your changes in detail -->
43

54
## Motivation and Context
5+
<!-- Why is this change required? What problem does it solve? -->
66

7-
<!--- Why is this change required? What problem does it solve? -->
8-
<!--- If it fixes an open issue, please link to the issue here. -->
7+
This PR addresses: [GitHub issue or Jira ticket number]
98

109
## How Has This Been Tested?
11-
12-
<!--- Please describe in detail how you tested your changes. -->
13-
<!--- Include details of your testing environment, and the tests you ran to -->
14-
<!--- see how your change affects other areas of the code, etc. -->
10+
<!--
11+
Please describe in detail how you tested your changes.
12+
Include details of your testing environment, and the tests you ran to
13+
see how your change affects other areas of the code, etc.*
14+
-->
1515

1616
## Screenshots (if appropriate):
1717

1818
## Types of changes
19+
<!-- What types of changes does your code introduce? Put an `x` in all the boxes that apply: -->
1920

20-
<!--- What types of changes does your code introduce? Put an `x` in all the boxes that apply: -->
21-
22-
- [ ] Chore (a change that does not modify the application functionality)
23-
- [ ] Bug fix (non-breaking change which fixes an issue)
24-
- [ ] New feature (non-breaking change which adds functionality)
25-
- [ ] Breaking change (fix or feature that would cause existing functionality to change)
21+
- [ ] Chore (a change that does not modify the application functionality)
22+
- [ ] Bug fix (non-breaking change which fixes an issue)
23+
- [ ] New feature (non-breaking change which adds functionality)
24+
- [ ] Breaking change (fix or feature that would cause existing functionality to change)
2625

2726
## Checklist:
28-
29-
<!--- Go over all the following points, and put an `x` in all the boxes that apply. -->
30-
<!--- If you're unsure about any of these, don't hesitate to ask. We're here to help! -->
31-
32-
- [ ] Documentation updates are needed, and have been made accordingly.
33-
- [ ] I have added and/or updated tests to cover my changes.
34-
- [ ] All new and existing tests passed.
35-
- [ ] My changes include a database migration.
27+
<!-- Please make sure you have completed all following checks. -->
28+
<!-- If you're unsure about any of these, don't hesitate to ask. We're here to help! -->
29+
30+
- [ ] I have met the contributing prerequisites
31+
- Assigned myself to this PR
32+
- Added the appropriate labels
33+
- Associated an issue: https://github.com/SpecterOps/BloodHound/issues/672
34+
- Read the Contributing guide: https://github.com/SpecterOps/BloodHound/wiki/Contributing
35+
- [ ] I have ensured that related documentation is up-to-date
36+
- Open API docs
37+
- Code comments
38+
- [ ] I have followed proper test practices
39+
- Added/updated tests to cover my changes
40+
- All new and existing tests passed

.github/workflows/build.yml

Lines changed: 6 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,21 @@
11
name: Build
22

33
on:
4-
push:
5-
branches: [ dev ]
64
pull_request:
7-
branches: [ dev ]
5+
branches: [ 2.X ]
86

97
jobs:
108
build:
119
runs-on: windows-latest
12-
defaults:
13-
run:
14-
shell: bash
15-
16-
strategy:
17-
matrix:
18-
release:
19-
- type: Debug
20-
suffix: '-debug'
21-
- type: Release
22-
suffix: ''
23-
24-
name: Build (${{ matrix.release.type }})
2510

2611
steps:
27-
- uses: actions/checkout@v2
28-
2912
- name: Setup .NET
30-
uses: actions/setup-dotnet@v1
13+
uses: actions/setup-dotnet@v5
3114
with:
3215
dotnet-version: 5.0.x
3316

34-
- name: Restore Dependencies
35-
run: dotnet restore
36-
17+
- name: Checkout repository
18+
uses: actions/checkout@v6
19+
3720
- name: Build
38-
run: dotnet build -c ${{ matrix.release.type }} -p:Version=0.0.0-rolling+${{ github.sha }}
39-
40-
- name: Zip
41-
if: "! startsWith(github.event_name, 'pull_request')"
42-
run: 7z a -tzip -mx9 SharpHound${{ matrix.release.suffix }}.zip $PWD/bin/${{ matrix.release.type }}/net472/*
43-
44-
- name: Update Rolling Release
45-
if: "! startsWith(github.event_name, 'pull_request')"
46-
uses: softprops/action-gh-release@v1
47-
with:
48-
name: Rolling Release (unstable)
49-
tag_name: rolling
50-
prerelease: true
51-
files: SharpHound${{ matrix.release.suffix }}.zip
52-
body: |
53-
Rolling release of SharpHound compiled from source (${{ github.sha }})
54-
This is automatically kept up-to-date with the `${{ github.ref_name }}` ${{ github.ref_type }}.
21+
run: dotnet build -p:CommonSource=Dev

.github/workflows/publish.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: Publish
33
on:
44
push:
55
tags:
6-
- "v*.*.*"
6+
- v[0-9]+.[0-9]+.[0-9]+*
77

88
jobs:
99
build:
@@ -36,7 +36,7 @@ jobs:
3636
- name: Build
3737
run: |
3838
VERSION=${{ github.ref_name }}
39-
dotnet build -c ${{ matrix.release.type }} -p:Version=${VERSION:1}
39+
dotnet build -c ${{ matrix.release.type }} -p:Version=${VERSION:1} -p:CommonLibSource=Stable
4040
4141
- name: Zip
4242
run: 7z a -tzip -mx9 SharpHound_${{ github.ref_name }}${{ matrix.release.suffix }}_windows_x86.zip $PWD/bin/${{ matrix.release.type }}/net472/*

README.md

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,15 @@ dotnet restore .
2121
dotnet build
2222
```
2323

24-
## Requirements
24+
By default, the project will build with the latest version of the [SharpHoundCommon Library](https://github.com/SpecterOps/SharpHoundCommon).
2525

26-
SharpHound is designed targeting .Net 4.6.2. SharpHound must be run from the context of a domain user, either directly through a logon or through another method such as RUNAS.
26+
To build against the latest stable release of the library, you can run `dotnet build -p:CommonLibSource=Stable`.
2727

28-
# SharpHound
28+
If you wish to build against a local copy of the library, ensure the `CommonLibPath` and `RPCPath` properties point to the correct DLLs, and run `dotnet build -p:CommonLibSource=Local`.
2929

30-
```csharp
31-
dotnet restore .
32-
dotnet build
33-
```
30+
## Requirements
31+
32+
SharpHound is designed targeting .Net 4.7.2. SharpHound must be run from the context of a domain user, either directly through a logon or through another method such as RUNAS.
3433

3534
# CLI Arguments
3635
The listing below details the CLI arguments SharpHound supports. Additional details about these options can be found in the [BloodHound CE Collection documentation](https://bloodhound.specterops.io/collect-data/ce-collection/sharphound-flags).

Sharphound.csproj

Lines changed: 33 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,22 @@
1313
<AssemblyName>SharpHound</AssemblyName>
1414
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
1515
</PropertyGroup>
16+
17+
<PropertyGroup>
18+
<CommonLibsStableVersion>4.6.0</CommonLibsStableVersion>
19+
<CommonLibPath>..\SharpHoundCommon\src\CommonLib\bin\$(Configuration)\net472\SharpHoundCommonLib.dll</CommonLibPath>
20+
<RPCPath>..\SharpHoundCommon\src\SharpHoundRPC\bin\$(Configuration)\net472\SharpHoundRPC.dll</RPCPath>
21+
22+
<CommonSource>Dev</CommonSource>
23+
24+
<!-- Determine if we should use local DLLs -->
25+
<_UseLocalLibs Condition="'$(CommonSource.ToLower())' == 'local'">true</_UseLocalLibs>
26+
<_UseLocalLibs Condition="'$(_UseLocalLibs)' == ''">false</_UseLocalLibs>
27+
28+
<!-- Determine the package version -->
29+
<_CommonLibsVersion Condition="'$(CommonSource.ToLower())' == 'stable'">$(CommonLibsStableVersion)</_CommonLibsVersion>
30+
<_CommonLibsVersion Condition="'$(_CommonLibsVersion)' == ''">$(CommonLibsStableVersion)-dev*</_CommonLibsVersion>
31+
</PropertyGroup>
1632

1733
<ItemGroup>
1834
<PackageReference Include="CommandLineParser" Version="2.8.0" />
@@ -25,20 +41,24 @@
2541
<PackageReference Include="Microsoft.Bcl.AsyncInterfaces" Version="8.0.0" />
2642
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.0" />
2743
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
28-
<PackageReference Include="SharpHoundCommon" Version="4.6.0" />
29-
<PackageReference Include="SharpHoundRPC" Version="4.6.0" />
3044
<PackageReference Include="SharpZipLib" Version="1.3.3" />
3145
<PackageReference Include="System.Runtime.CompilerServices.Unsafe" Version="6.0.0" />
3246
<PackageReference Include="System.Threading.Channels" Version="8.0.0" />
3347
<PackageReference Include="System.ValueTuple" Version="4.5.0" />
3448
</ItemGroup>
49+
<ItemGroup Condition="'$(_UseLocalLibs)' == 'true'">
50+
<Reference Include="SharpHoundCommonLib">
51+
<HintPath>$(CommonLibPath)</HintPath>
52+
</Reference>
53+
<Reference Include="SharpHoundRPC">
54+
<HintPath>$(RPCPath)</HintPath>
55+
</Reference>
56+
</ItemGroup>
57+
<ItemGroup Condition="'$(_UseLocalLibs)' != 'true'">
58+
<PackageReference Include="SharpHoundCommon" Version="$(_CommonLibsVersion)" />
59+
<PackageReference Include="SharpHoundRPC" Version="$(_CommonLibsVersion)" />
60+
</ItemGroup>
3561
<ItemGroup>
36-
<!-- <Reference Include="SharpHoundCommon">-->
37-
<!-- <HintPath>..\SharpHoundCommon\src\CommonLib\bin\Debug\net472\SharpHoundCommonLib.dll</HintPath>-->
38-
<!-- </Reference>-->
39-
<!-- <Reference Include="SharpHoundRPC">-->
40-
<!-- <HintPath>..\SharpHoundCommon\src\SharpHoundRPC\bin\Debug\net472\SharpHoundRPC.dll</HintPath>-->
41-
<!-- </Reference>-->
4262
<Reference Include="System.DirectoryServices" />
4363
<Reference Include="System.DirectoryServices.Protocols" />
4464
<Reference Include="System.IO.Compression" />
@@ -47,4 +67,9 @@
4767
<Message Text="Test" />
4868
<Exec Command="powershell -ep bypass -c &quot;. '$(ProjectDir)src\Powershell\Out-CompressedDLL.ps1';Out-CompressedDll -FilePath '$(TargetPath)' -TemplatePath '$(ProjectDir)src\\Powershell\Template.ps1' | Out-File -Encoding ASCII '$(TargetDir)$(TargetName).ps1'&quot;" />
4969
</Target>
70+
<Target Name="LogCommonLibsVersion" BeforeTargets="Build">
71+
<Message Text="Loading CommonLib Dependency:" Importance="high" />
72+
<Message Condition="'$(_UseLocalLibs)' == 'true'" Text=" Using Local DLLs" Importance="high" />
73+
<Message Condition="'$(_UseLocalLibs)' == 'false'" Text=" Package Version: $(_CommonLibsVersion)" Importance="high" />
74+
</Target>
5075
</Project>

0 commit comments

Comments
 (0)