Skip to content

Commit

Permalink
feat: add condition to release (only when new SF version is available)
Browse files Browse the repository at this point in the history
  • Loading branch information
loekd authored Aug 21, 2024
1 parent 83e53c2 commit b57c80e
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion .github/workflows/NuGetCD.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:
run: |
Set-ExecutionPolicy -ExecutionPolicy Unrestricted -Force -Scope CurrentUser
$ProgressPreference = 'SilentlyContinue'
Invoke-RestMethod -OutFile setup.exe -Method GET -Uri https://download.microsoft.com/download/b/8/a/b8a2fb98-0ec1-41e5-be98-9d8b5abf7856/MicrosoftServiceFabric.10.1.1951.9590.exe
Invoke-RestMethod -OutFile setup.exe -Method GET -Uri https://download.microsoft.com/download/b/8/a/b8a2fb98-0ec1-41e5-be98-9d8b5abf7856/MicrosoftServiceFabric.10.1.2338.9590.exe
#.\setup.exe /accepteula /force /quiet
Start-Process setup.exe -UseNewEnvironment -ArgumentList '/accepteula /force /quiet' -Wait
Expand Down Expand Up @@ -66,8 +66,24 @@ jobs:
- name: Run build
run: dotnet pack --configuration RELEASE -p:PackageVersion=${{ steps.tag_version.outputs.new_version }} -o ${{ github.workspace }}

# Check for SF updates before creating a new release
- name: Check for SF NuGet Package Version Change
id: check_version
run: |
# Specify the package you want to check
PACKAGE_NAME="Microsoft.ServiceFabric.Actors"
# Check for changes in the .csproj file for the package version
if git diff origin/master -- /src/ServiceFabric.Mocks/ServiceFabric.Mocks.csproj | grep -q "<PackageReference Include=\"$PACKAGE_NAME\""; then
echo "Package version has changed."
echo "sf_ver_changed=true" >> $GITHUB_OUTPUT
else
echo "No changes to package version."
echo "sf_ver_changed=false" >> $GITHUB_OUTPUT
fi
# create GH release
- name: Create a GitHub release
if: ${{ steps.check_version.outputs.sf_ver_changed == 'true' }}
uses: loekd/release-action@v1
with:
tag: ${{ steps.tag_version.outputs.new_tag }}
Expand All @@ -76,17 +92,20 @@ jobs:

# publish nuget package artifact
- name: Upload Package for Publishing
if: ${{ steps.check_version.outputs.sf_ver_changed == 'true' }}
uses: actions/upload-artifact@v3
with:
name: PackedLib
path: ${{ github.workspace }}/ServiceFabric.Mocks.${{ steps.tag_version.outputs.new_version }}.nupkg

# publish GH nuget package artifact
- name: Push Package to GitHub
if: ${{ steps.check_version.outputs.sf_ver_changed == 'true' }}
run: dotnet nuget push --api-key ${{secrets.GITHUB_TOKEN}} --source "https://nuget.pkg.github.com/loekd/index.json" ${{ github.workspace }}/ServiceFabric.Mocks.${{ steps.tag_version.outputs.new_version }}.nupkg

# publish packge to nuget
- name: Push Package to GitHub
if: ${{ steps.check_version.outputs.sf_ver_changed == 'true' }}
run: dotnet nuget push --api-key ${{secrets.NUGETPUSH}} --source "https://api.nuget.org/v3/index.json" ${{ github.workspace }}/ServiceFabric.Mocks.${{ steps.tag_version.outputs.new_version }}.nupkg


0 comments on commit b57c80e

Please sign in to comment.