Fix NuGet managed identity #100
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
| name: dotnet | |
| permissions: | |
| contents: read | |
| packages: write | |
| id-token: write | |
| on: | |
| push: | |
| branches: [ main ] | |
| tags: ["*"] | |
| pull_request: | |
| branches: [ main ] | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - uses: actions/setup-dotnet@v4 | |
| with: | |
| dotnet-version: '8.0.x' | |
| - uses: actions/setup-dotnet@v4 | |
| with: | |
| dotnet-version: '3.1.x' | |
| - uses: gittools/actions/gitversion/setup@v0.9.7 | |
| with: | |
| versionSpec: "5.x" | |
| - id: gitversion | |
| uses: gittools/actions/gitversion/execute@v0.9.7 | |
| - name: Restore dependencies | |
| run: dotnet restore | |
| - name: Build | |
| run: dotnet build --configuration Release --no-restore | |
| - name: Test | |
| run: | | |
| if [ "$RUNNER_OS" = "Linux" ]; then | |
| # Skip net462 on Linux (Mono/OpenSSL compatibility issues) | |
| dotnet test --configuration Release --no-build --verbosity normal --framework '!net462' | |
| else | |
| dotnet test --configuration Release --no-build --verbosity normal | |
| fi | |
| shell: bash | |
| - run: | | |
| dotnet pack \ | |
| --include-source \ | |
| --include-symbols \ | |
| --configuration Release \ | |
| --no-build \ | |
| --no-restore \ | |
| -p:PackageVersion="${{ env.GitVersion_FullSemVer }}" \ | |
| RegExtract/RegExtract.csproj \ | |
| --output ${{ github.workspace }}/nugets/ | |
| - uses: actions/upload-artifact@v4 | |
| with: | |
| name: nugets | |
| path: nugets | |
| nuget-push-dev: | |
| runs-on: ubuntu-latest | |
| if: github.ref == 'refs/heads/main' | |
| needs: build | |
| steps: | |
| - name: download artifact | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: nugets | |
| - name: setup dotnet | |
| uses: actions/setup-dotnet@v4 | |
| with: | |
| dotnet-version: '8.0.x' | |
| source-url: https://nuget.pkg.github.com/sblom/index.json | |
| env: | |
| NUGET_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: nuget push | |
| run: dotnet nuget push *.nupkg *.snupkg --skip-duplicate --api-key ${{ secrets.GITHUB_TOKEN }} | |
| nuget-push-prod: | |
| runs-on: ubuntu-latest | |
| if: startsWith(github.ref, 'refs/tags/') | |
| needs: build | |
| steps: | |
| - uses: actions/download-artifact@v4 | |
| with: | |
| name: nugets | |
| # Get a short-lived NuGet API key | |
| - name: NuGet login (OIDC → temp API key) | |
| uses: NuGet/login@v1 | |
| id: login | |
| with: | |
| user: ${{secrets.NUGET_USER}} | |
| # Push the package | |
| - name: NuGet push | |
| run: dotnet nuget push *.nupkg *.snupkg --skip-duplicate --api-key ${{steps.login.outputs.NUGET_API_KEY}} --source https://api.nuget.org/v3/index.json |