Skip to content

Commit 1b14723

Browse files
committed
Merge branch 'feature/github-workflow-nuget' into main
2 parents 84da987 + c22fef1 commit 1b14723

File tree

5 files changed

+92
-0
lines changed

5 files changed

+92
-0
lines changed
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: Build and publish .NET Core package
2+
3+
on:
4+
release:
5+
types:
6+
- created
7+
8+
jobs:
9+
Publish:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- name: Checkout code
14+
uses: actions/checkout@v2
15+
16+
- name: Get version info from Git
17+
id: git_version
18+
uses: battila7/get-version-action@v2
19+
20+
- name: Setup .NET
21+
uses: actions/setup-dotnet@v1
22+
with:
23+
dotnet-version: 5.0.x
24+
25+
- name: Restore dependencies
26+
run: dotnet restore
27+
28+
- name: Build
29+
run: dotnet build --no-restore --configuration=Release -p:Version=${{ steps.git_version.outputs.version-without-v }}
30+
31+
- name: Release to GitHub
32+
uses: softprops/action-gh-release@v1
33+
if: startsWith(github.ref, 'refs/tags/')
34+
env:
35+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
36+
with:
37+
fail_on_unmatched_files: true # needs action-gh-release@v2 but that doesn't exist yet, gives a warning now
38+
files: '**/*.nupkg'
39+
40+
- name: Release to NuGet.org
41+
if: startsWith(github.ref, 'refs/tags/')
42+
run: nuget push **/*.nupkg -Source 'https://api.nuget.org/v3/index.json' -ApiKey ${{secrets.NUGET_API_KEY}} -NoSymbols

CodeCaster.WindowsServiceExtensions.sln

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,15 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CodeCaster.WindowsServiceEx
77
EndProject
88
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{4B4ADAD2-7E93-44E5-8376-3B11173671EE}"
99
ProjectSection(SolutionItems) = preProject
10+
LICENSE = LICENSE
1011
Readme.md = Readme.md
1112
EndProjectSection
1213
EndProject
14+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "GitHub Workflows", "GitHub Workflows", "{37061E24-6F75-46D3-A86D-2B35A945A7A7}"
15+
ProjectSection(SolutionItems) = preProject
16+
.github\workflows\Publish-Package.yml = .github\workflows\Publish-Package.yml
17+
EndProjectSection
18+
EndProject
1319
Global
1420
GlobalSection(SolutionConfigurationPlatforms) = preSolution
1521
Debug|Any CPU = Debug|Any CPU
@@ -24,6 +30,9 @@ Global
2430
GlobalSection(SolutionProperties) = preSolution
2531
HideSolutionNode = FALSE
2632
EndGlobalSection
33+
GlobalSection(NestedProjects) = preSolution
34+
{37061E24-6F75-46D3-A86D-2B35A945A7A7} = {4B4ADAD2-7E93-44E5-8376-3B11173671EE}
35+
EndGlobalSection
2736
GlobalSection(ExtensibilityGlobals) = postSolution
2837
SolutionGuid = {6CA3DCF0-B9FE-471F-8709-C0EC776BA216}
2938
EndGlobalSection

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2021 CodeCaster
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

Readme.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,5 @@ These extensions allow your IHostedServices to respond to this power state chang
88
* On your Host Builder, call `UsePowerEventAwareWindowsService()` instead of [`UseWindowsService()`](https://docs.microsoft.com/en-us/dotnet/api/microsoft.extensions.hosting.windowsservicelifetimehostbuilderextensions.usewindowsservice?view=dotnet-plat-ext-3.1).
99
* Instead of letting your service inherit [`Microsoft.Extensions.Hosting.BackgroundService`](https://docs.microsoft.com/en-us/dotnet/api/microsoft.extensions.hosting.backgroundservice?view=dotnet-plat-ext-5.0), inherit from `CodeCaster.WindowsServiceExtensions.PowerEventAwareBackgroundService`.
1010
* Implement the method `public override bool OnPowerEvent(PowerBroadcastStatus powerStatus)`
11+
12+
Do note that the statuses received can vary. You get either `ResumeSuspend`, `ResumeAutomatic` or both, never neither, after a machine wake, reboot or boot.

src/CodeCaster.WindowsServiceExtensions/CodeCaster.WindowsServiceExtensions.csproj

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,29 @@
33
<PropertyGroup>
44
<TargetFramework>net5.0</TargetFramework>
55
<Nullable>enable</Nullable>
6+
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
7+
<PackageProjectUrl>https://github.com/CodeCasterNL/WindowsServiceExtensions</PackageProjectUrl>
8+
<RepositoryUrl>https://github.com/CodeCasterNL/WindowsServiceExtensions</RepositoryUrl>
9+
<RepositoryType>GitHub</RepositoryType>
10+
<PackageTags></PackageTags>
11+
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
12+
<PackageLicenseFile>LICENSE</PackageLicenseFile>
13+
<Authors>CodeCaster</Authors>
14+
<Company />
15+
<Copyright>CodeCaster</Copyright>
16+
<Description>Makes your .NET 5 BackgroundServices power-event-aware.</Description>
617
</PropertyGroup>
718

819
<ItemGroup>
920
<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="5.0.0" />
1021
<PackageReference Include="Microsoft.Extensions.Hosting.WindowsServices" Version="5.0.1" />
1122
</ItemGroup>
1223

24+
<ItemGroup>
25+
<None Include="..\..\LICENSE">
26+
<Pack>True</Pack>
27+
<PackagePath></PackagePath>
28+
</None>
29+
</ItemGroup>
30+
1331
</Project>

0 commit comments

Comments
 (0)