|
| 1 | +name: Package and publish nupkg |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + |
| 6 | +jobs: |
| 7 | + build: |
| 8 | + name: Build app, sign files with Trusted Signing and deploy to NuGet |
| 9 | + runs-on: windows-latest |
| 10 | + steps: |
| 11 | + - name: Checkout |
| 12 | + uses: actions/checkout@v4 |
| 13 | + |
| 14 | + - name: Setup MSBuild |
| 15 | + uses: microsoft/setup-msbuild@v1 |
| 16 | + |
| 17 | + - name: Restore NuGet packages |
| 18 | + run: cd src && nuget restore && cd .. |
| 19 | + |
| 20 | + - name: Build |
| 21 | + run: msbuild .\src\Org.Openfeed.Client\Org.Openfeed.Client.csproj /t:Pack /p:Configuration=Release /p:PackageOutputPath=..\..\publish |
| 22 | + |
| 23 | + - name: List files in publish directory |
| 24 | + run: dir .\publish |
| 25 | + |
| 26 | + - name: Upload build artifacts |
| 27 | + uses: actions/upload-artifact@v4 |
| 28 | + with: |
| 29 | + name: BuildArtifacts |
| 30 | + path: ./publish/*.nupkg |
| 31 | + |
| 32 | + sign: |
| 33 | + needs: build |
| 34 | + runs-on: windows-latest |
| 35 | + permissions: |
| 36 | + id-token: write # Required for requesting the JWT |
| 37 | + |
| 38 | + steps: |
| 39 | + - name: Download build artifacts |
| 40 | + uses: actions/download-artifact@v4 |
| 41 | + with: |
| 42 | + name: BuildArtifacts |
| 43 | + path: BuildArtifacts |
| 44 | + |
| 45 | + # .NET is required on the agent for the tool to run |
| 46 | + - name: Setup .NET |
| 47 | + uses: actions/setup-dotnet@v3 |
| 48 | + with: |
| 49 | + dotnet-version: "9.x" |
| 50 | + |
| 51 | + # Install the code signing tool |
| 52 | + - name: Install Sign CLI tool |
| 53 | + run: dotnet tool install --tool-path . --prerelease sign |
| 54 | + |
| 55 | + # Login to Azure using a ServicePrincipal configured to authenticate agaist a GitHub Action |
| 56 | + - name: "Az CLI login" |
| 57 | + uses: azure/login@v1 |
| 58 | + with: |
| 59 | + allow-no-subscriptions: true |
| 60 | + creds: ${{ secrets.AZURE_CREDS }} |
| 61 | + |
| 62 | + # Run the signing command |
| 63 | + - name: Sign artifacts |
| 64 | + uses: azure/powershell@v1 |
| 65 | + with: |
| 66 | + azPSVersion: "latest" |
| 67 | + inlineScript: | |
| 68 | + ./sign code trusted-signing *.nupkg -tse ${{ secrets.AZURE_ENDPOINT }} -tsa ${{secrets.AZURE_CODE_SIGNING_NAME}} -tscp ${{secrets.AZURE_CERT_PROFILE_NAME}} --base-directory "${{ github.workspace }}/BuildArtifacts" |
| 69 | +
|
| 70 | + # Publish the signed packages |
| 71 | + - name: Upload build artifacts |
| 72 | + uses: actions/upload-artifact@v4 |
| 73 | + with: |
| 74 | + name: BuildArtifacts |
| 75 | + path: SignedArtifacts |
0 commit comments