Skip to content

Commit f46a207

Browse files
committed
[Major] ready for nuget
1 parent 027099a commit f46a207

File tree

4 files changed

+181
-0
lines changed

4 files changed

+181
-0
lines changed

.github/workflows/publish.yaml

Lines changed: 148 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,148 @@
1+
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json
2+
3+
name: publish
4+
on:
5+
workflow_dispatch: # Allow running the workflow manually from the GitHub UI
6+
push:
7+
branches:
8+
- 'main' # Run the workflow when pushing to the main branch (test only)
9+
tags:
10+
- '*' # Run the workflow with a tag
11+
12+
env:
13+
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1
14+
DOTNET_NOLOGO: true
15+
NuGetDirectory: ${{ github.workspace }}/nuget
16+
17+
defaults:
18+
run:
19+
shell: pwsh
20+
21+
jobs:
22+
set_version:
23+
if: startsWith(github.ref, 'refs/tags/')
24+
runs-on: ubuntu-latest
25+
steps:
26+
- name: Checkout
27+
uses: actions/checkout@v4
28+
with:
29+
fetch-depth: 0
30+
31+
- name: Set Version
32+
id: package_version
33+
uses: KageKirin/set-csproj-version@v0
34+
with:
35+
file: ./ModShardDiff.csproj
36+
version: ${{ github.ref_name }}
37+
38+
- name: Set user info
39+
run: |
40+
git config user.name github-actions
41+
git config user.email [email protected]
42+
43+
- name: Commit Files & Pull
44+
run: |
45+
git commit -a -m "Updated version with CI."
46+
git pull origin main --rebase
47+
48+
- name: Push Changes
49+
uses: ad-m/github-push-action@master
50+
with:
51+
github_token: ${{ secrets.GITHUB_TOKEN }}
52+
branch: main
53+
54+
create_nuget:
55+
runs-on: ubuntu-latest
56+
needs: [ set_version ]
57+
steps:
58+
- uses: actions/checkout@v4
59+
with:
60+
fetch-depth: 0 # Get all history to allow automatic versioning using MinVer
61+
62+
# Install the .NET SDK indicated in the global.json file
63+
- name: Setup .NET
64+
uses: actions/setup-dotnet@v4
65+
66+
# Build the project
67+
- run: dotnet build --configuration Release
68+
69+
# Create the NuGet package in the folder from the environment variable NuGetDirectory
70+
- run: dotnet pack --configuration Release --output ${{ env.NuGetDirectory }}
71+
72+
# Publish the NuGet package as an artifact, so they can be used in the following jobs
73+
- uses: actions/upload-artifact@v3
74+
with:
75+
name: nuget
76+
if-no-files-found: error
77+
retention-days: 7
78+
path: ${{ env.NuGetDirectory }}/*.nupkg
79+
80+
validate_nuget:
81+
runs-on: ubuntu-latest
82+
needs: [ create_nuget ]
83+
steps:
84+
# Install the .NET SDK indicated in the global.json file
85+
- name: Setup .NET
86+
uses: actions/setup-dotnet@v4
87+
88+
# Download the NuGet package created in the previous job
89+
- uses: actions/download-artifact@v3
90+
with:
91+
name: nuget
92+
path: ${{ env.NuGetDirectory }}
93+
94+
- name: Install nuget validator
95+
run: dotnet tool update Meziantou.Framework.NuGetPackageValidation.Tool --global
96+
97+
# Validate metadata and content of the NuGet package
98+
# https://www.nuget.org/packages/Meziantou.Framework.NuGetPackageValidation.Tool#readme-body-tab
99+
# If some rules are not applicable, you can disable them
100+
# using the --excluded-rules or --excluded-rule-ids option
101+
- name: Validate package
102+
run: meziantou.validate-nuget-package (Get-ChildItem "${{ env.NuGetDirectory }}/*.nupkg")
103+
104+
run_test:
105+
runs-on: ubuntu-latest
106+
steps:
107+
- uses: actions/checkout@v3
108+
- name: Setup .NET
109+
uses: actions/setup-dotnet@v4
110+
- name: Run tests
111+
run: dotnet test --configuration Release
112+
113+
create_release:
114+
runs-on: ubuntu-latest
115+
needs: [ validate_nuget, run_test ]
116+
steps:
117+
- uses: actions/checkout@v4
118+
119+
- name: Create Release
120+
run: gh release create ${{ github.ref_name }} --generate-notes
121+
env:
122+
GITHUB_TOKEN: ${{ github.TOKEN }}
123+
124+
deploy:
125+
# Publish only when creating a GitHub Release
126+
# https://docs.github.com/en/repositories/releasing-projects-on-github/managing-releases-in-a-repository
127+
# You can update this logic if you want to manage releases differently
128+
runs-on: ubuntu-latest
129+
needs: [ create_release ]
130+
steps:
131+
# Download the NuGet package created in the previous job
132+
- uses: actions/download-artifact@v3
133+
with:
134+
name: nuget
135+
path: ${{ env.NuGetDirectory }}
136+
137+
# Install the .NET SDK indicated in the global.json file
138+
- name: Setup .NET Core
139+
uses: actions/setup-dotnet@v4
140+
141+
# Publish all NuGet packages to NuGet.org
142+
# Use --skip-duplicate to prevent errors if a package with the same version already exists.
143+
# If you retry a failed workflow, already published packages will be skipped without error.
144+
- name: Publish NuGet package
145+
run: |
146+
foreach($file in (Get-ChildItem "${{ env.NuGetDirectory }}" -Recurse -Include *.nupkg)) {
147+
dotnet nuget push $file --api-key "${{ secrets.NUGET_APIKEY }}" --source https://api.nuget.org/v3/index.json --skip-duplicate
148+
}

ModShardDiff.csproj

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,23 @@
55
<TargetFramework>net6.0</TargetFramework>
66
<ImplicitUsings>enable</ImplicitUsings>
77
<Nullable>enable</Nullable>
8+
<Version>0.1.0</Version>
9+
<PackAsTool>true</PackAsTool>
10+
<ToolCommandName>msd</ToolCommandName>
11+
<PackageOutputPath>./nupkg</PackageOutputPath>
12+
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
13+
<PackageReadmeFile>README.md</PackageReadmeFile>
14+
<PackageLicenseExpression>MIT</PackageLicenseExpression>
15+
<Authors>zizani</Authors>
16+
<PackageTags>msl;cli</PackageTags>
17+
<PackageProjectUrl>https://github.com/ModShardTeam/ModShardDiff</PackageProjectUrl>
18+
<Description>A cli tool to export all differences between two .win files.</Description>
819
</PropertyGroup>
920

21+
<ItemGroup>
22+
<None Include="README.md" Pack="true" PackagePath=""/>
23+
</ItemGroup>
24+
1025
<ItemGroup>
1126
<PackageReference Include="Microsoft.CodeAnalysis.Common" Version="4.7.0"/>
1227
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.7.0"/>
@@ -30,4 +45,19 @@
3045
</Reference>
3146
</ItemGroup>
3247

48+
<ItemGroup>
49+
<None Include="icon.png" Pack="true" PackagePath="\"/>
50+
</ItemGroup>
51+
52+
<PropertyGroup>
53+
<RepositoryUrl>https://github.com/ModShardTeam/ModShardDiff</RepositoryUrl>
54+
</PropertyGroup>
55+
56+
<PropertyGroup>
57+
<ProjectUrl>https://github.com/ModShardTeam/ModShardDiff</ProjectUrl>
58+
</PropertyGroup>
59+
60+
<PropertyGroup>
61+
<PackageIcon>icon.png</PackageIcon>
62+
</PropertyGroup>
3363
</Project>

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# ModShardDiff
2+
3+
A cli tool to export all differences between two .win files.

icon.png

2.7 KB
Loading

0 commit comments

Comments
 (0)