Skip to content

Commit 1e6a22f

Browse files
committed
Update CI/CD workflow to specify output directory for NuGet packages and add conditional check for API key before publishing
1 parent 6b786ce commit 1e6a22f

1 file changed

Lines changed: 9 additions & 6 deletions

File tree

.github/workflows/ci-cd.yml

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,13 @@ jobs:
4444
echo "Generated client file found and verified"
4545
4646
- name: Pack
47-
run: dotnet pack ${{ env.PROJECT_PATH }} --no-build --configuration Release
47+
run: dotnet pack ${{ env.PROJECT_PATH }} --no-build --configuration Release --output ./nupkg
4848

4949
- name: Upload build artifacts
5050
uses: actions/upload-artifact@v4
5151
with:
5252
name: nuget-package
53-
path: TypescriptClientGenerator/bin/Release/*.nupkg
53+
path: ./nupkg/*.nupkg
5454

5555
publish:
5656
needs: build-and-test
@@ -85,22 +85,25 @@ jobs:
8585
run: dotnet build ${{ env.PROJECT_PATH }} --no-restore --configuration Release -p:Version=${{ steps.gitversion.outputs.semVer }}
8686

8787
- name: Pack
88-
run: dotnet pack ${{ env.PROJECT_PATH }} --no-build --configuration Release -p:PackageVersion=${{ steps.gitversion.outputs.semVer }}
88+
run: dotnet pack ${{ env.PROJECT_PATH }} --no-build --configuration Release -p:PackageVersion=${{ steps.gitversion.outputs.semVer }} --output ./nupkg
8989

9090
- name: Publish to NuGet
91-
if: ${{ secrets.NUGET_API_KEY != '' }}
9291
env:
9392
NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }}
9493
run: |
95-
for package in TypescriptClientGenerator/bin/Release/*.nupkg; do
94+
if [ -z "$NUGET_API_KEY" ]; then
95+
echo "NUGET_API_KEY secret is not set. Skipping publish."
96+
exit 0
97+
fi
98+
for package in ./nupkg/*.nupkg; do
9699
dotnet nuget push "$package" --api-key "$NUGET_API_KEY" --source https://api.nuget.org/v3/index.json --skip-duplicate
97100
done
98101
99102
- name: Upload release artifacts
100103
uses: actions/upload-artifact@v4
101104
with:
102105
name: release-package
103-
path: TypescriptClientGenerator/bin/Release/*.nupkg
106+
path: ./nupkg/*.nupkg
104107

105108
verify-package:
106109
needs: build-and-test

0 commit comments

Comments
 (0)