Skip to content

Commit 55443ce

Browse files
authored
Merge pull request #18 from PlainBytes/chore/project-info-cleanup
Workflow improvements
2 parents bc8090b + 73aa88d commit 55443ce

5 files changed

Lines changed: 125 additions & 56 deletions

File tree

.github/workflows/build.yml

Lines changed: 0 additions & 23 deletions
This file was deleted.

.github/workflows/publish.yml

Lines changed: 96 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,106 @@
1-
name: Publish
1+
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json
22

3+
name: publish
34
on:
5+
workflow_dispatch: # Allow running the workflow manually from the GitHub UI
46
push:
5-
branches: [ master ]
7+
branches:
8+
- 'master' # Run the workflow when pushing to the master branch
9+
pull_request:
10+
branches:
11+
- '*' # Run the workflow for all pull requests
12+
release:
13+
types:
14+
- published # Run the workflow when a new GitHub release is published
15+
16+
env:
17+
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1
18+
DOTNET_NOLOGO: true
19+
NuGetDirectory: ${{ github.workspace}}/nuget
20+
21+
defaults:
22+
run:
23+
shell: pwsh
624

725
jobs:
8-
build:
26+
create_nuget:
27+
runs-on: ubuntu-latest
28+
steps:
29+
- uses: actions/checkout@v3
30+
with:
31+
fetch-depth: 0 # Get all history to allow automatic versioning using MinVer
932

33+
# Install the .NET SDK indicated in the global.json file
34+
- name: Setup .NET
35+
uses: actions/setup-dotnet@v4
36+
37+
# Create the NuGet package in the folder from the environment variable NuGetDirectory
38+
- run: dotnet pack --configuration Release --output ${{ env.NuGetDirectory }}
39+
40+
# Publish the NuGet package as an artifact, so they can be used in the following jobs
41+
- uses: actions/upload-artifact@v4
42+
with:
43+
name: nuget
44+
if-no-files-found: error
45+
retention-days: 7
46+
path: ${{ env.NuGetDirectory }}/*.nupkg
47+
48+
validate_nuget:
1049
runs-on: ubuntu-latest
50+
needs: [ create_nuget ]
51+
steps:
52+
# Install the .NET SDK indicated in the global.json file
53+
- name: Setup .NET
54+
uses: actions/setup-dotnet@v4
1155

56+
# Download the NuGet package created in the previous job
57+
- uses: actions/download-artifact@v4
58+
with:
59+
name: nuget
60+
path: ${{ env.NuGetDirectory }}
61+
62+
- name: Install nuget validator
63+
run: dotnet tool update Meziantou.Framework.NuGetPackageValidation.Tool --global
64+
65+
# Validate metadata and content of the NuGet package
66+
# https://www.nuget.org/packages/Meziantou.Framework.NuGetPackageValidation.Tool#readme-body-tab
67+
# If some rules are not applicable, you can disable them
68+
# using the --excluded-rules or --excluded-rule-ids option
69+
- name: Validate package
70+
run: meziantou.validate-nuget-package (Get-ChildItem "${{ env.NuGetDirectory }}/*.nupkg")
71+
72+
run_test:
73+
runs-on: ubuntu-latest
1274
steps:
13-
- uses: actions/checkout@v2
14-
- name: Setup .NET Core
75+
- uses: actions/checkout@v3
76+
- name: Setup .NET
1577
uses: actions/setup-dotnet@v4
16-
with:
17-
dotnet-version: 9.0.100
18-
- name: Install dependencies
19-
run: dotnet restore
20-
- name: Build
21-
run: dotnet build --configuration Release --no-restore
22-
- name: Test
23-
run: dotnet test --no-restore --verbosity normal
24-
- name: Publish PlainBytes.System.Extensions
25-
uses: brandedoutcast/publish-nuget@v2.5.2
26-
with:
27-
PROJECT_FILE_PATH: source/PlainBytes.System.Extensions/PlainBytes.System.Extensions.csproj
28-
NUGET_KEY: ${{secrets.NUGET_API_KEY}}
78+
- name: Run tests
79+
run: dotnet test --configuration Release
80+
81+
deploy:
82+
# Publish only when creating a GitHub Release
83+
# https://docs.github.com/en/repositories/releasing-projects-on-github/managing-releases-in-a-repository
84+
# You can update this logic if you want to manage releases differently
85+
if: github.event_name == 'release'
86+
runs-on: ubuntu-latest
87+
needs: [ validate_nuget, run_test ]
88+
steps:
89+
# Download the NuGet package created in the previous job
90+
- uses: actions/download-artifact@v4
91+
with:
92+
name: nuget
93+
path: ${{ env.NuGetDirectory }}
94+
95+
# Install the .NET SDK indicated in the global.json file
96+
- name: Setup .NET Core
97+
uses: actions/setup-dotnet@v4
98+
99+
# Publish all NuGet packages to NuGet.org
100+
# Use --skip-duplicate to prevent errors if a package with the same version already exists.
101+
# If you retry a failed workflow, already published packages will be skipped without error.
102+
- name: Publish NuGet package
103+
run: |
104+
foreach($file in (Get-ChildItem "${{ env.NuGetDirectory }}" -Recurse -Include *.nupkg)) {
105+
dotnet nuget push $file --api-key "${{ secrets.NUGET_APIKEY }}" --source https://api.nuget.org/v3/index.json --skip-duplicate
106+
}

global.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"sdk": {
3+
"rollForward": "feature",
4+
"version": "9.0.304"
5+
}
6+
}

samples/ConsoleApp/ConsoleApp.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
<PropertyGroup>
44
<OutputType>Exe</OutputType>
55
<TargetFramework>net8.0</TargetFramework>
6+
<IsPackable>false</IsPackable>
67
</PropertyGroup>
78

89
<ItemGroup>

source/PlainBytes.System.Extensions/PlainBytes.System.Extensions.csproj

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,26 +3,33 @@
33
<PropertyGroup>
44
<TargetFrameworks>net8.0;net9.0</TargetFrameworks>
55

6-
<Description>Collection of utility extention methods for the System.* namespace.</Description>
7-
<AssemblyTitle>System extensions</AssemblyTitle>
6+
<EnablePackageValidation>true</EnablePackageValidation>
7+
<GenerateDocumentationFile>True</GenerateDocumentationFile>
8+
89
<Authors>PlainBytes</Authors>
9-
<AssemblyName>PlainBytes.System.Extensions</AssemblyName>
10-
<PackageId>PlainBytes.System.Extensions</PackageId>
10+
<Description>Collection of utility extension methods for the System.* namespace.</Description>
1111
<PackageTags>System;Extensions;iterators;bcl;</PackageTags>
12-
<PackageProjectUrl>https://github.com/PlainBytes/PlainBytes.System.Extensions</PackageProjectUrl>
13-
<RepositoryUrl>https://github.com/PlainBytes/PlainBytes.System.Extensions</RepositoryUrl>
14-
<PackageLicenseUrl>https://github.com/PlainBytes/PlainBytes.System.Extensions/blob/master/LICENSE</PackageLicenseUrl>
15-
<Version>1.1.0.0</Version>
16-
<AssemblyVersion>$(Version)</AssemblyVersion>
17-
<FileVersion>$(Version)</FileVersion>
18-
<PackageIcon>icon.png</PackageIcon>
12+
13+
<PackageLicenseFile>LICENSE</PackageLicenseFile>
1914
<PackageReadmeFile>README.md</PackageReadmeFile>
20-
<GenerateDocumentationFile>true</GenerateDocumentationFile>
15+
<PackageIcon>system-extensions.png</PackageIcon>
16+
<PackageProjectUrl>https://github.com/PlainBytes/PlainBytes.System.Extensions</PackageProjectUrl>
2117
</PropertyGroup>
2218

2319
<ItemGroup>
24-
<None Include="assets\README.md" Pack="true" PackagePath="\" />
25-
<None Include="assets\icon.png" Pack="true" PackagePath="\" />
20+
<PackageReference Include="DotNet.ReproducibleBuilds" Version="1.2.25">
21+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
22+
<PrivateAssets>all</PrivateAssets>
23+
</PackageReference>
24+
<PackageReference Include="MinVer" Version="6.0.0">
25+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
26+
<PrivateAssets>all</PrivateAssets>
27+
</PackageReference>
2628
</ItemGroup>
2729

28-
</Project>
30+
<ItemGroup>
31+
<None Include="../../README.md" Pack="true" PackagePath="" />
32+
<None Include="../../assets/system-extensions.png" Pack="true" PackagePath="" />
33+
<None Include="../../LICENSE" Pack="true" PackagePath="" />
34+
</ItemGroup>
35+
</Project>

0 commit comments

Comments
 (0)