|
| 1 | +name: NuGet Push to Production - ESDM Nexus and nuget.org |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + |
| 6 | +jobs: |
| 7 | + push-nuget: |
| 8 | + runs-on: ubuntu-latest |
| 9 | + steps: |
| 10 | + - uses: actions/checkout@v4 |
| 11 | + - name: Setup .NET |
| 12 | + uses: actions/setup-dotnet@v4 |
| 13 | + with: |
| 14 | + dotnet-version: 8.0.x |
| 15 | + - name: Exit if the branch is not master |
| 16 | + run: | |
| 17 | + if [[ "${{ github.ref }}" != "refs/heads/master" ]]; then |
| 18 | + echo "Branch is not master, exiting." |
| 19 | + exit 1 |
| 20 | + fi |
| 21 | + - name: Setup NuGet |
| 22 | + run: dotnet nuget add source ${{ secrets.NUGET_SOURCE_URL }} -u ${{ secrets.NUGET_USERNAME }} -p ${{ secrets.NUGET_PASSWORD }} --store-password-in-clear-text --name esdm-nuget-testing |
| 23 | + - name: Restore dependencies |
| 24 | + run: dotnet restore |
| 25 | + - name: Build |
| 26 | + run: dotnet build -c Release |
| 27 | + - name: Create NuGet package |
| 28 | + run: dotnet pack -c Release |
| 29 | + - name: Auth to other Nexus repo |
| 30 | + run: dotnet nuget add source ${{ secrets.ESDM_NUGET_HOSTED_URL }} -u ${{ secrets.NUGET_USERNAME }} -p ${{ secrets.NUGET_PASSWORD }} --store-password-in-clear-text --name esdm-nuget-hosted |
| 31 | + - name: Find and Push NuGet packages to Nexus |
| 32 | + run: | |
| 33 | + PACKAGES=$(find . -name "*.nupkg" | grep -E "cloudscribe|sts\.Common") |
| 34 | + if [ -z "$PACKAGES" ]; then |
| 35 | + echo "No matching package found. Exiting." |
| 36 | + exit 1 |
| 37 | + fi |
| 38 | + echo "Found packages: $PACKAGES" |
| 39 | + for PACKAGE in $PACKAGES; do |
| 40 | + echo "Pushing $PACKAGE to Nexus" |
| 41 | + dotnet nuget push "$PACKAGE" --source esdm-nuget-hosted --skip-duplicate || echo "WARNING - skipping duplicate package: $PACKAGE" |
| 42 | + done |
| 43 | + - name: Find and Push NuGet packages to nuget.org |
| 44 | + run: | |
| 45 | + PACKAGES=$(find . -name "*.nupkg" | grep -E "cloudscribe|sts\.Common") |
| 46 | + if [ -z "$PACKAGES" ]; then |
| 47 | + echo "No matching package found. Exiting." |
| 48 | + exit 1 |
| 49 | + fi |
| 50 | + echo "Found packages: $PACKAGES" |
| 51 | + for PACKAGE in $PACKAGES; do |
| 52 | + echo "Pushing $PACKAGE to nuget.org" |
| 53 | + dotnet nuget push "$PACKAGE" --api-key "$NUGET_ORG_API_KEY" --source "https://api.nuget.org/v3/index.json" --skip-duplicate || echo "WARNING - failed to upload package: $PACKAGE" |
| 54 | + done |
0 commit comments