Skip to content

Merge branch 'main' of https://github.com/DerekGooding/SimpleDataGrid #48

Merge branch 'main' of https://github.com/DerekGooding/SimpleDataGrid

Merge branch 'main' of https://github.com/DerekGooding/SimpleDataGrid #48

Workflow file for this run

name: Publish .NET Package to NuGet
on:
push:
branches:
- main
workflow_dispatch:
jobs:
publish:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup .NET SDK
uses: actions/setup-dotnet@v4
with:
dotnet-version: '9.0'
- name: Get the version from the .csproj file
id: get_version
run: |
VERSION=$(cat SimpleDataGrid/SimpleDataGrid.csproj | grep -oPm1 "(?<=<Version>)[^<]+")
echo "VERSION=$VERSION" >> $GITHUB_ENV
- name: Get the latest published version from NuGet
id: get_latest_version
run: |
echo "Debugging curl output for NuGet versions:"
HTTP_CODE=$(curl -s -o curl_output.txt -w "%{http_code}" "https://api.nuget.org/v3-flatcontainer/SimpleDataGrid/index.json")
echo "HTTP Status Code: $HTTP_CODE"
cat curl_output.txt
if [ "$HTTP_CODE" -eq 200 ]; then
LATEST_VERSION=$(cat curl_output.txt | jq -r '.versions[-1]')
else
echo "Curl failed or returned non-200 status. Assuming no previous version."
LATEST_VERSION=""
fi
echo "LATEST_VERSION=$LATEST_VERSION" >> $GITHUB_ENV
- name: Compare versions
id: version_check
run: |
if [ "$VERSION" != "$LATEST_VERSION" ]; then
echo "New version detected: $VERSION"
echo "run_publish=true" >> $GITHUB_ENV
else
echo "No new version detected"
echo "run_publish=false" >> $GITHUB_ENV
fi
- name: Build the project
run: dotnet build SimpleDataGrid/SimpleDataGrid.csproj --configuration Release
- name: Pack the NuGet package
run: dotnet pack SimpleDataGrid/SimpleDataGrid.csproj --configuration Release --no-build --output ./nupkg
- name: Publish to NuGet
if: env.run_publish == 'true'
run: dotnet nuget push ./nupkg/*.nupkg --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json
continue-on-error: true