add workflows #7
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Nuget push Lagrange.Core | |
| on: | |
| push: | |
| branches: | |
| - main | |
| paths: | |
| - "Lagrange.Core/Lagrange.Core.csproj" | |
| workflow_dispatch: | |
| jobs: | |
| nuget-push: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/setup-dotnet@v4 | |
| with: | |
| dotnet-version: '9' | |
| - uses: actions/checkout@v4 | |
| # Check Version | |
| - shell: pwsh | |
| run: | | |
| $lversion = ([xml](Get-Content .\Lagrange.Core\Lagrange.Core.csproj)).Project.PropertyGroup.Version | |
| echo "Local version: $lversion" | |
| $response = Invoke-WebRequest -Uri "https://api.nuget.org/v3-flatcontainer/lagrange.core/index.json" | |
| if ($response.StatusCode -eq 404) { | |
| echo "No remote version" | |
| echo "continued=true" >> $env:GITHUB_ENV | |
| exit 0 | |
| } | |
| $rversions = ($response.Content | ConvertFrom-Json).versions | |
| echo "Remote version: $rversions" | |
| if ($lversion -in $rversions) { | |
| echo "Version($lversion) already exists" | |
| echo "continued=false" >> $env:GITHUB_ENV | |
| exit 0 | |
| } | |
| echo "Version($lversion) does not exist" | |
| echo "continued=true" >> $env:GITHUB_ENV | |
| exit 0 | |
| - if: env.continued == 'true' | |
| run: dotnet pack -c Release -p:IncludeSymbols=true -p:SymbolPackageFormat=snupkg Lagrange.Core | |
| - if: env.continued == 'true' | |
| run: dotnet nuget push ./Lagrange.Core/bin/Release/*.nupkg --source https://api.nuget.org/v3/index.json --api-key ${{ secrets.NUGET_TOKEN }} |