Repository navigation
Manually Publish GitHub Artifact #28
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # This is a basic workflow to help you get started with Actions | |
| name: Manually Publish GitHub Artifact | |
| on: | |
| # Allows you to run this workflow manually from the Actions tab | |
| workflow_dispatch: | |
| permissions: | |
| contents: read | |
| packages: write | |
| attestations: write | |
| id-token: write # REQUIRED for OIDC | |
| # A workflow run is made up of one or more jobs that can run sequentially or in parallel | |
| jobs: | |
| build: | |
| runs-on: windows-latest | |
| env: | |
| OUTPUT_DIRECTORY: ./output | |
| BINARIES_DIRECTORY: ./artifacts/build/net10.0 | |
| steps: | |
| # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it | |
| - uses: actions/checkout@v2 | |
| # Get the latest version tag to duplicate it in the nuget package | |
| - uses: oprypin/find-latest-tag@v1 | |
| with: | |
| repository: joelbyford/BasicAuth # The repository to scan. | |
| releases-only: true # We know that all relevant tags have a GitHub release for them. | |
| id: latesttag # The step ID to refer to later. | |
| # Install DotNet SDK | |
| - name: Setup dotnet 10.x | |
| uses: actions/setup-dotnet@v1 | |
| with: | |
| dotnet-version: 10.x | |
| source-url: https://nuget.pkg.github.com/joelbyford/index.json | |
| env: | |
| NUGET_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| # Restore Dependencies (can be omitted if you remove --no-restore on build step) | |
| - name: Restore package dependencies | |
| run: dotnet restore BasicAuth.csproj | |
| # Build the project | |
| - name: dotnet build | |
| run: dotnet build BasicAuth.csproj --no-restore --configuration Release | |
| - name: Verify build outputs exist | |
| shell: cmd | |
| run: | | |
| echo Listing build outputs in %BINARIES_DIRECTORY% | |
| dir "%BINARIES_DIRECTORY%" | |
| if not exist "%BINARIES_DIRECTORY%\BasicAuth.dll" ( | |
| echo BasicAuth.dll not found in %BINARIES_DIRECTORY% | |
| exit /b 1 | |
| ) | |
| # Authenticate to Azure to use Artifact Signing | |
| - name: 'Authenticate to Azure' | |
| uses: azure/login@v3 | |
| with: | |
| client-id: ${{ secrets.AZURE_CLIENTID }} | |
| tenant-id: ${{ secrets.AZURE_TENANTID }} | |
| subscription-id: ${{ secrets.AZURE_SUBSCRIPTIONID }} | |
| # Sign the binaries using Artifact Signing | |
| - name: Sign binaries with Artifact Signing | |
| uses: azure/artifact-signing-action@v1 | |
| with: | |
| endpoint: https://wus.codesigning.azure.net | |
| signing-account-name: artSignByford | |
| certificate-profile-name: pub-trust-github | |
| files-folder: ${{ env.BINARIES_DIRECTORY }} | |
| files-folder-filter: dll | |
| file-digest: SHA256 | |
| timestamp-rfc3161: http://timestamp.acs.microsoft.com | |
| timestamp-digest: SHA256 | |
| # Pack the project | |
| - name: dotnet pack | |
| if: success() # this should be implied, but adding just to be sure this runs only when the previous steps are successfull | |
| run: dotnet pack BasicAuth.csproj --no-build --no-restore -c Release -p:PackageVersion=${{ steps.latesttag.outputs.tag }} -o ${{env.OUTPUT_DIRECTORY}} | |
| - name: Verify package outputs exist | |
| shell: cmd | |
| run: | | |
| echo Listing package outputs in %OUTPUT_DIRECTORY% | |
| dir "%OUTPUT_DIRECTORY%" | |
| if not exist "%OUTPUT_DIRECTORY%\*.nupkg" ( | |
| echo No .nupkg files found in %OUTPUT_DIRECTORY% | |
| exit /b 1 | |
| ) | |
| dir "%OUTPUT_DIRECTORY%\*.nupkg" | |
| # Sign the NuGet package using Artifact Signing | |
| # ------ NOT SUPPORTED TODAY, USING THE DOTNET SIGNING CAPABILITY INSTEAD ------ | |
| #- name: Sign NuGet package with Artifact Signing | |
| # uses: azure/artifact-signing-action@v1 | |
| # with: | |
| # endpoint: https://wus.codesigning.azure.net | |
| # signing-account-name: artSignByford | |
| # certificate-profile-name: pub-trust-github | |
| # files-folder: ${{ env.OUTPUT_DIRECTORY }} | |
| # files-folder-filter: nupkg | |
| # file-digest: SHA256 | |
| # timestamp-rfc3161: http://timestamp.acs.microsoft.com | |
| # timestamp-digest: SHA256 | |
| - name: Install DotNet Sign Tool | |
| shell: pwsh | |
| run: dotnet tool install sign --tool-path . --prerelease | |
| - name: Sign NuGet package with DotNet Sign Tool | |
| shell: pwsh | |
| run: .\sign code trusted-signing -tse "https://wus.codesigning.azure.net" -tsa artSignByford -tscp pub-trust-github -t "http://timestamp.acs.microsoft.com" -d SHA256 "${{ env.OUTPUT_DIRECTORY }}/*.nupkg" | |
| # Publish the artifact to GitHub Packages | |
| - name: Publish to GitHub Packages | |
| shell: pwsh | |
| run: | | |
| $packages = Get-ChildItem -Path "${{ env.OUTPUT_DIRECTORY }}" -Filter *.nupkg -File | |
| if (-not $packages) { | |
| throw "No .nupkg files found in ${{ env.OUTPUT_DIRECTORY }}" | |
| } | |
| foreach ($package in $packages) { | |
| dotnet nuget push "$($package.FullName)" --source "https://nuget.pkg.github.com/joelbyford/index.json" --skip-duplicate | |
| } | |