Skip to content

Commit d797b38

Browse files
committed
[GITHUB] Add Nuget push workflow
Only Nuget Can Do!
1 parent b0f8cc4 commit d797b38

File tree

5 files changed

+187
-14
lines changed

5 files changed

+187
-14
lines changed
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: Nuget push Lagrange.Core
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
paths:
8+
- "Lagrange.Core/Lagrange.Core.csproj"
9+
workflow_dispatch:
10+
11+
jobs:
12+
nuget-push:
13+
runs-on: ubuntu-latest
14+
15+
steps:
16+
- uses: actions/checkout@v4
17+
18+
# Check Version
19+
- shell: pwsh
20+
run: |
21+
$lversion = ([xml](Get-Content .\Lagrange.Core\Lagrange.Core.csproj)).Project.PropertyGroup.Version
22+
echo "Local version: $lversion"
23+
24+
try {
25+
$response = Invoke-WebRequest -Uri "https://api.nuget.org/v3-flatcontainer/lagrange.core/index.json"
26+
} catch {
27+
if ($_.Exception.Response.StatusCode.value__ -eq 404) {
28+
echo "No remote version"
29+
echo "continued=true" >> $env:GITHUB_ENV
30+
exit 0
31+
} else {
32+
throw
33+
}
34+
}
35+
36+
$rversions = ($response.Content | ConvertFrom-Json).versions
37+
echo "Remote version: $rversions"
38+
if ($lversion -in $rversions) {
39+
echo "Version($lversion) already exists"
40+
echo "continued=false" >> $env:GITHUB_ENV
41+
exit 0
42+
}
43+
44+
echo "Version($lversion) does not exist"
45+
echo "continued=true" >> $env:GITHUB_ENV
46+
exit 0
47+
48+
- if: env.continued == 'true'
49+
uses: actions/setup-dotnet@v4
50+
with:
51+
dotnet-version: '9'
52+
53+
- if: env.continued == 'true'
54+
run: dotnet pack -c Release -p:IncludeSymbols=true -p:SymbolPackageFormat=snupkg Lagrange.Core
55+
56+
- if: env.continued == 'true'
57+
run: dotnet nuget push ./Lagrange.Core/bin/Release/*.nupkg --source https://api.nuget.org/v3/index.json --api-key ${{ secrets.NUGET_TOKEN }}
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: Nuget push Lagrange.Proto.CodeGen
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
paths:
8+
- "Lagrange.Proto.CodeGen/Lagrange.Proto.CodeGen.csproj"
9+
workflow_dispatch:
10+
11+
jobs:
12+
nuget-push:
13+
runs-on: ubuntu-latest
14+
15+
steps:
16+
- uses: actions/checkout@v4
17+
18+
# Check Version
19+
- shell: pwsh
20+
run: |
21+
$lversion = ([xml](Get-Content .\Lagrange.Proto.CodeGen\Lagrange.Proto.CodeGen.csproj)).Project.PropertyGroup.Version
22+
echo "Local version: $lversion"
23+
24+
try {
25+
$response = Invoke-WebRequest -Uri "https://api.nuget.org/v3-flatcontainer/lagrange.proto.codegen/index.json"
26+
} catch {
27+
if ($_.Exception.Response.StatusCode.value__ -eq 404) {
28+
echo "No remote version"
29+
echo "continued=true" >> $env:GITHUB_ENV
30+
exit 0
31+
} else {
32+
throw
33+
}
34+
}
35+
36+
$rversions = ($response.Content | ConvertFrom-Json).versions
37+
echo "Remote version: $rversions"
38+
if ($lversion -in $rversions) {
39+
echo "Version($lversion) already exists"
40+
echo "continued=false" >> $env:GITHUB_ENV
41+
exit 0
42+
}
43+
44+
echo "Version($lversion) does not exist"
45+
echo "continued=true" >> $env:GITHUB_ENV
46+
exit 0
47+
48+
- if: env.continued == 'true'
49+
uses: actions/setup-dotnet@v4
50+
with:
51+
dotnet-version: '9'
52+
53+
- if: env.continued == 'true'
54+
run: dotnet pack -c Release -p:IncludeSymbols=true -p:SymbolPackageFormat=snupkg Lagrange.Proto.CodeGen
55+
56+
- if: env.continued == 'true'
57+
run: dotnet nuget push ./Lagrange.Proto.CodeGen/bin/Release/*.nupkg --source https://api.nuget.org/v3/index.json --api-key ${{ secrets.NUGET_TOKEN }}
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: Nuget push Lagrange.Proto
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
paths:
8+
- "Lagrange.Proto/Lagrange.Proto.csproj"
9+
workflow_dispatch:
10+
11+
jobs:
12+
nuget-push:
13+
runs-on: ubuntu-latest
14+
15+
steps:
16+
- uses: actions/checkout@v4
17+
18+
# Check Version
19+
- shell: pwsh
20+
run: |
21+
$lversion = ([xml](Get-Content .\Lagrange.Proto\Lagrange.Proto.csproj)).Project.PropertyGroup.Version
22+
echo "Local version: $lversion"
23+
24+
try {
25+
$response = Invoke-WebRequest -Uri "https://api.nuget.org/v3-flatcontainer/lagrange.proto/index.json"
26+
} catch {
27+
if ($_.Exception.Response.StatusCode.value__ -eq 404) {
28+
echo "No remote version"
29+
echo "continued=true" >> $env:GITHUB_ENV
30+
exit 0
31+
} else {
32+
throw
33+
}
34+
}
35+
36+
$rversions = ($response.Content | ConvertFrom-Json).versions
37+
echo "Remote version: $rversions"
38+
if ($lversion -in $rversions) {
39+
echo "Version($lversion) already exists"
40+
echo "continued=false" >> $env:GITHUB_ENV
41+
exit 0
42+
}
43+
44+
echo "Version($lversion) does not exist"
45+
echo "continued=true" >> $env:GITHUB_ENV
46+
exit 0
47+
48+
- if: env.continued == 'true'
49+
uses: actions/setup-dotnet@v4
50+
with:
51+
dotnet-version: '9'
52+
53+
- if: env.continued == 'true'
54+
run: dotnet pack -c Release -p:IncludeSymbols=true -p:SymbolPackageFormat=snupkg Lagrange.Proto
55+
56+
- if: env.continued == 'true'
57+
run: dotnet nuget push ./Lagrange.Proto/bin/Release/*.nupkg --source https://api.nuget.org/v3/index.json --api-key ${{ secrets.NUGET_TOKEN }}

Lagrange.Core/Lagrange.Core.csproj

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
<Project Sdk="Microsoft.NET.Sdk">
2+
<PropertyGroup>
3+
<TargetFrameworks>net8.0;net9.0</TargetFrameworks>
4+
<ImplicitUsings>enable</ImplicitUsings>
5+
<Nullable>enable</Nullable>
6+
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
7+
<LangVersion>13</LangVersion>
8+
<IsAotCompatible>true</IsAotCompatible>
29

3-
<PropertyGroup>
4-
<TargetFrameworks>net8.0;net9.0</TargetFrameworks>
5-
<ImplicitUsings>enable</ImplicitUsings>
6-
<Nullable>enable</Nullable>
7-
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
8-
<LangVersion>13</LangVersion>
9-
<IsAotCompatible>true</IsAotCompatible>
10-
</PropertyGroup>
10+
<Version>2.0.0-beta</Version>
11+
</PropertyGroup>
1112

12-
<ItemGroup>
13-
<ProjectReference Include="..\Lagrange.Proto.Generator\Lagrange.Proto.Generator.csproj" PrivateAssets="all" OutputItemType="Analyzer" ReferenceOutputAssembly="false" />
14-
<ProjectReference Include="..\Lagrange.Proto\Lagrange.Proto.csproj" />
15-
</ItemGroup>
16-
17-
</Project>
13+
<ItemGroup>
14+
<ProjectReference Include="..\Lagrange.Proto.Generator\Lagrange.Proto.Generator.csproj" PrivateAssets="all" OutputItemType="Analyzer" ReferenceOutputAssembly="false" />
15+
<ProjectReference Include="..\Lagrange.Proto\Lagrange.Proto.csproj" />
16+
</ItemGroup>
17+
</Project>

Lagrange.Proto.CodeGen/Lagrange.Proto.CodeGen.csproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
<TrimMode>full</TrimMode>
1010
<PublishSingleFile>true</PublishSingleFile>
1111
<PublishTrimmed>true</PublishTrimmed>
12+
13+
<Version>0.0.1</Version>
1214
</PropertyGroup>
1315

1416
<ItemGroup>

0 commit comments

Comments
 (0)