Merge pull request #40 from FacturAPI/FAC-1703/feat/add-status-field-… #10
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: Deploy to NuGet | |
| on: | |
| push: | |
| branches: | |
| - main | |
| jobs: | |
| deploy: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Setup .NET | |
| uses: actions/setup-dotnet@v4 | |
| with: | |
| dotnet-version: '8.0.x' # Adjust the .NET version as needed | |
| - name: Restore dependencies | |
| run: dotnet restore | |
| - name: Build | |
| run: dotnet build --configuration Release --no-restore | |
| - name: Pack | |
| run: dotnet pack --configuration Release --no-build --output ./nupkg | |
| - name: Install xmllint | |
| run: sudo apt-get update && sudo apt-get install -y libxml2-utils | |
| - name: Check if version exists on NuGet | |
| id: version-check | |
| run: | | |
| PACKAGE_ID="Facturapi" | |
| VERSION=$(xmllint --xpath "string(//Project/PropertyGroup/Version)" facturapi-net.csproj) | |
| echo "Detected version: $VERSION" | |
| echo "version=$VERSION" >> $GITHUB_OUTPUT | |
| if curl -sSf "https://api.nuget.org/v3-flatcontainer/${PACKAGE_ID,,}/$VERSION/${PACKAGE_ID,,}.$VERSION.nupkg" > /dev/null; then | |
| echo "Version $VERSION already exists. Skipping push." | |
| echo "exists=true" >> $GITHUB_OUTPUT | |
| else | |
| echo "Version $VERSION does not exist. Proceeding with publish." | |
| echo "exists=false" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Publish to NuGet | |
| if: steps.version-check.outputs.exists == 'false' | |
| run: dotnet nuget push ./nupkg/*.nupkg --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json |