|
| 1 | +name: Publish Nuget |
| 2 | +run-name: ${{ github.actor }} is publishing NuGet 🚀 |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + inputs: |
| 6 | + SHOULD_RUN: |
| 7 | + description: 'True to run' |
| 8 | + required: true |
| 9 | + type: boolean |
| 10 | +jobs: |
| 11 | + build-then-publish: |
| 12 | + environment: production |
| 13 | + runs-on: macos-latest |
| 14 | + if: ${{ inputs.SHOULD_RUN }} |
| 15 | + steps: |
| 16 | + - uses: actions/checkout@v3 |
| 17 | + - name: Set default Xamarin SDK versions |
| 18 | + run: | |
| 19 | + $VM_ASSETS/select-xamarin-sdk-v2.sh --mono=6.12 --android=13.0 |
| 20 | +
|
| 21 | + - name: Setup .NET Core SDK 7.0.101 |
| 22 | + uses: actions/setup-dotnet@v3 |
| 23 | + with: |
| 24 | + dotnet-version: '7.0.101' |
| 25 | + |
| 26 | + - name: Install ios workload |
| 27 | + run: | |
| 28 | + dotnet workload install ios android maui maui-ios maui-android |
| 29 | +
|
| 30 | + - name: Build |
| 31 | + run: | |
| 32 | + sh build.sh |
| 33 | + |
| 34 | + - name: Publish NuGet and symbols |
| 35 | + id: nuget-push |
| 36 | + uses: edumserrano/nuget-push@v1.2.0 |
| 37 | + with: |
| 38 | + api-key: '${{ secrets.NUGET_PUSH_API_KEY }}' # this example is using GitHub secrets to pass the API key |
| 39 | + working-directory: 'nugets' |
| 40 | + # The next step is using powershell to parse the action's output but you can use whatever you prefer. |
| 41 | + # Note that in order to read the step outputs the action step must have an id. |
| 42 | + - name: Log output |
| 43 | + if: steps.nuget-push.conclusion != 'skipped' && always() # run regardless if the previous step failed or not, just as long as it wasn't skipped |
| 44 | + shell: pwsh |
| 45 | + run: | |
| 46 | + $pushResult = '${{ steps.nuget-push.outputs.push-result }}' | ConvertFrom-Json |
| 47 | + $pushResultAsJsonIndented = ConvertTo-Json $pushResult |
| 48 | + Write-Output $pushResultAsJsonIndented # outputs the result of the nuget push operation as an indented JSON string |
| 49 | + Write-Output '${{ steps.nuget-push.outputs.status }}' # outputs the overall status of the nuget push action |
| 50 | +
|
| 51 | + # iterates over all list of packages and outputs the data from the nuget push operation for each |
| 52 | + foreach($package in $pushResult.packages) { |
| 53 | + Write-Output "$($package.status)" # outputs the status of the nuget push operation |
| 54 | + Write-Output "$($package.package)" # outputs the NuGet package name that was pushed |
| 55 | + Write-Output "$($package.symbols)" # outputs the symbols package name that was pushed |
| 56 | + } |
0 commit comments