Skip to content

Commit 1957a8e

Browse files
authored
Push to NuGet (#303)
* Push to NuGet * Add build step * Fix imports
1 parent f4f4e97 commit 1957a8e

File tree

10 files changed

+109
-5
lines changed

10 files changed

+109
-5
lines changed

.github/workflows/clean_environment_tests.yaml

+5-2
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,12 @@ jobs:
3232

3333
# - name: Clean
3434
# run: dotnet clean
35-
35+
36+
- name: Build
37+
run: dotnet build
38+
3639
- name: Tests
37-
run: dotnet test --filter "RequiresNetworking!=True" --collect:"XPlat Code Coverage;Format=opencover"
40+
run: dotnet test --no-build --filter "RequiresNetworking!=True" --collect:"XPlat Code Coverage;Format=opencover"
3841

3942
- uses: codecov/codecov-action@v3
4043
with:
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: Publish NuGet Packages
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
8+
jobs:
9+
build:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- uses: actions/checkout@v3
14+
15+
- name: Get Version
16+
id: get-version
17+
shell: pwsh
18+
run: |
19+
$version = [System.Version]::Parse("${{ github.ref_name }}".Replace('v', '')).ToString()
20+
echo "version=$version" >> $env:GITHUB_OUTPUT
21+
echo $version
22+
23+
- name: Print Debug Info
24+
run: dotnet --info
25+
26+
- name: Pack
27+
run: dotnet --pack -p:Version="${{ steps.get-version.outputs.version }}" -p:RepositoryCommit="${{ github.sha }}"
28+
29+
- name: Validate
30+
shell: pwsh
31+
run: ./scripts/validate-nupkgs.ps1
32+
33+
- name: Push to NuGet
34+
run: dotnet nuget push **/*.nupkg --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json

Directory.Build.props

+4
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
77
</PropertyGroup>
88

9+
<PropertyGroup>
10+
<IsPackable>false</IsPackable>
11+
</PropertyGroup>
12+
913
<PropertyGroup Condition="'$(GITHUB_ACTIONS)' == 'true'">
1014
<!-- https://github.com/dotnet/sourcelink/tree/main/docs#continuousintegrationbuild -->
1115
<ContinuousIntegrationBuild>true</ContinuousIntegrationBuild>

NuGet.Build.props

+5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
<Project>
2+
<PropertyGroup>
3+
<!-- Overwrites IsPackable from global Directory.Build.props -->
4+
<IsPackable>true</IsPackable>
5+
</PropertyGroup>
6+
27
<PropertyGroup>
38
<Authors>Nexus Mods</Authors>
49

scripts/validate-nupkgs.ps1

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# This script extracts all "*.nupkg" files and parses the ".nuspec" file.
2+
# It looks at the dependencies of that package and alerts if some dependencies
3+
# of this organization are not available.
4+
5+
$Organization = "NexusMods"
6+
7+
$nupkgs = Get-ChildItem -Path "*" -Recurse -Include "*.nupkg"
8+
9+
$allPackages = [System.Collections.Generic.HashSet[string]]::new()
10+
$allDependencies = [System.Collections.Generic.HashSet[string]]::new()
11+
12+
foreach ($item in $nupkgs)
13+
{
14+
$packageName = [System.IO.Path]::GetFileName(
15+
[System.IO.Path]::GetDirectoryName(
16+
[System.IO.Path]::GetDirectoryName(
17+
[System.IO.Path]::GetDirectoryName($item))))
18+
19+
$allPackages.Add($packageName)
20+
$extractedPath = [System.IO.Path]::Combine([System.IO.Path]::GetDirectoryName($item.FullName), "extracted")
21+
22+
Expand-Archive -Path $item.FullName -DestinationPath $extractedPath -Force
23+
24+
$nuspecFilePath = [System.IO.Path]::Combine($extractedPath, $packageName + ".nuspec")
25+
26+
if (![System.IO.File]::Exists($nuspecFilePath)) {
27+
echo "File $nuspecFilePath does not exist!"
28+
exit 1
29+
}
30+
31+
# Select-Xml doesn't want to work for whatever reason
32+
#$dependencies = Select-Xml -Path $nuspecFilePath -XPath "//dependency"
33+
34+
$xml = ([xml](Get-Content -Path $nuspecFilePath))
35+
$dependencies = $xml.ChildNodes[1].ChildNodes.dependencies.group.dependency.id
36+
37+
foreach ($dep in $dependencies) {
38+
if (!$dep.StartsWith($Organization)) {
39+
continue
40+
}
41+
42+
$allDependencies.Add($dep)
43+
}
44+
}
45+
46+
$allDependencies.ExceptWith($allPackages)
47+
48+
foreach ($missing in $allDependencies) {
49+
echo "The following package wasn't packed: $missing"
50+
}
51+
52+
if ($allDependencies.Count -ne 0) {
53+
exit 1
54+
} else {
55+
echo "All packages are correct"
56+
}

src/Networking/NexusMods.Networking.NexusWebApi/NexusMods.Networking.NexusWebApi.csproj

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
<Import Project="$([MSBuild]::GetPathOfFileAbove('NuGet.Build.props', '$(MSBuildThisFileDirectory)../'))" />
44

55
<ItemGroup>
6+
<PackageReference Include="System.Linq.Async" Version="6.0.1" />
67
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="6.29.0" />
78
</ItemGroup>
89

src/NexusMods.App.UI/RightContent/LoadoutGrid/Columns/IDataGridColumnFactory.cs

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
using Avalonia.Controls;
2-
using Mutagen.Bethesda.Skyrim;
32

43
namespace NexusMods.App.UI.RightContent.LoadoutGrid.Columns;
54

src/NexusMods.App.UI/RightContent/LoadoutGrid/Columns/ModInstalledViewModel.cs

-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
using NexusMods.DataModel.Abstractions;
44
using NexusMods.DataModel.Loadouts;
55
using NexusMods.DataModel.Loadouts.Cursors;
6-
using Noggog;
76
using ReactiveUI;
87
using ReactiveUI.Fody.Helpers;
98

src/NexusMods.App/NexusMods.App.csproj

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
</PropertyGroup>
66

77
<ItemGroup>
8+
<ProjectReference Include="..\Games\NexusMods.Games.BethesdaGameStudios\NexusMods.Games.BethesdaGameStudios.csproj" />
89
<ProjectReference Include="..\Games\NexusMods.Games.DarkestDungeon\NexusMods.Games.DarkestDungeon.csproj" />
910
<ProjectReference Include="..\Games\NexusMods.Games.StardewValley\NexusMods.Games.StardewValley.csproj" />
1011
<ProjectReference Include="..\Games\NexusMods.Games.FOMOD\NexusMods.Games.FOMOD.csproj" />

src/NexusMods.CLI/NexusMods.CLI.csproj

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
<Project Sdk="Microsoft.NET.Sdk">
2+
<!-- NuGet Package Shared Details -->
3+
<Import Project="$([MSBuild]::GetPathOfFileAbove('NuGet.Build.props', '$(MSBuildThisFileDirectory)../'))" />
4+
25
<ItemGroup>
36
<PackageReference Include="System.CommandLine" Version="2.0.0-beta4.22272.1" />
47
<PackageReference Include="System.CommandLine.NamingConventionBinder" Version="2.0.0-beta4.22272.1" />
58
</ItemGroup>
69

710
<ItemGroup>
811
<ProjectReference Include="..\ArchiveManagement\NexusMods.FileExtractor\NexusMods.FileExtractor.csproj" />
9-
<ProjectReference Include="..\Games\NexusMods.Games.BethesdaGameStudios\NexusMods.Games.BethesdaGameStudios.csproj" />
1012
<ProjectReference Include="..\NexusMods.DataModel\NexusMods.DataModel.csproj" />
1113
<ProjectReference Include="..\NexusMods.Paths\NexusMods.Paths.csproj" />
1214
<ProjectReference Include="..\NexusMods.StandardGameLocators\NexusMods.StandardGameLocators.csproj" />

0 commit comments

Comments
 (0)