Skip to content

Commit

Permalink
ci: publish all packages instead of affected packages (#6)
Browse files Browse the repository at this point in the history
  • Loading branch information
phamhongphuc1403 authored Aug 6, 2024
1 parent 18c1695 commit bd670cb
Showing 1 changed file with 11 additions and 39 deletions.
50 changes: 11 additions & 39 deletions .github/workflows/build-and-push-nuget-packages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,49 +17,21 @@ jobs:
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Work out last successful commit
id: setSHAs
uses: nrwl/nx-set-shas@v4

- name: Determine affected projects
id: dotnet_affected
run: |
dotnet new tool-manifest && dotnet tool install dotnet-affected
if dotnet affected -f text traversal \
--from "${{ steps.setSHAs.outputs.base }}" \
--to "${{ github.sha }}"; then
if [ -s affected.txt ]; then
cat affected.txt
echo "Number of affected projects: " $(wc -l < affected.txt)
echo "has_output=true" >> $GITHUB_OUTPUT
else
echo "No affected projects."
echo "has_output=false" >> $GITHUB_OUTPUT
fi
elif [ $? -ne 166 ]; then
echo "Exiting, error occurred"
exit 1
else
echo "No affected projects."
echo "has_output=false" >> $GITHUB_OUTPUT
fi

- name: Test affected projects
if: steps.dotnet_affected.outputs.has_output == 'true'
run: dotnet test affected.proj

- name: Pack affected projects
if: steps.dotnet_affected.outputs.has_output == 'true'

- name: Restore dependencies
run: dotnet restore

- name: Test projects
run: dotnet test

- name: Pack projects
run: |
if [ "${{ github.ref_name }}" == "main" ]; then
dotnet pack affected.proj
dotnet pack --configuration Release
else
VERSION=$(date +"%Y.%m.%d.%H%M")
dotnet pack affected.proj /p:Version=${VERSION}-dev
dotnet pack --configuration Release /p:Version=${VERSION}-dev
fi
- name: Push NuGet packages
if: steps.dotnet_affected.outputs.has_output == 'true'
run: dotnet nuget push **/Release/*.nupkg --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json

0 comments on commit bd670cb

Please sign in to comment.