Readme + xmldocs in sample #14
Workflow file for this run
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: Publish | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| version: | |
| description: 'Tag to publish v1.2.3[-prerelease]' | |
| required: true | |
| default: '' | |
| type: string | |
| dry-run: | |
| description: 'Dry run' | |
| required: false | |
| default: false | |
| type: boolean | |
| push: | |
| tags: | |
| - "v[0-9]+.[0-9]+.[0-9]+*" | |
| permissions: | |
| checks: write | |
| pull-requests: write | |
| jobs: | |
| version: | |
| name: Determine Version | |
| runs-on: ubuntu-latest | |
| outputs: | |
| version: ${{ steps.ver.outputs.version }} | |
| steps: | |
| - name: Determine and validate version | |
| id: ver | |
| shell: pwsh | |
| env: | |
| INPUT_VERSION: ${{ inputs.version }} | |
| REF_TYPE: ${{ github.ref_type }} | |
| REF_NAME: ${{ github.ref_name }} | |
| EVENT_NAME: ${{ github.event_name }} | |
| run: | | |
| $inputVersion = "$env:INPUT_VERSION".Trim() | |
| $tagVersion = if ($env:REF_TYPE -eq 'tag') { "$env:REF_NAME".Trim() } else { '' } | |
| $raw = if ($inputVersion) { $inputVersion } elseif ($tagVersion) { $tagVersion } else { '' } | |
| if (-not $raw) { Write-Error "No version provided via workflow_dispatch or tag push."; exit 1 } | |
| $ver = $raw -replace '^v', '' | |
| # SemVer 2.0.0: x.y.z with optional -prerelease and +build | |
| $semverPattern = '^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?(?:\+[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?$' | |
| if ($ver -notmatch $semverPattern) { | |
| Write-Error "Invalid SemVer: '$ver'. Expected x.y.z[ -prerelease ][ +build ]."; exit 1 | |
| } | |
| Write-Host "Version: $ver" | |
| "version=$ver" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append | |
| build: | |
| name: Main | |
| uses: ./.github/workflows/main.yml | |
| publish: | |
| name: 📦 Publish to NuGet | |
| needs: [version, build] | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Setup .NET | |
| uses: actions/setup-dotnet@v4 | |
| with: | |
| global-json-file: src/global.json | |
| - name: Restore | |
| run: dotnet restore src/TypeShim/TypeShim.csproj | |
| - name: Download all RID artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| pattern: pack-build-* | |
| path: src/TypeShim/bin/pack | |
| merge-multiple: true | |
| - name: Build TypeShim library | |
| run: > | |
| dotnet build src/TypeShim/TypeShim.csproj | |
| -c Release | |
| --no-restore | |
| - name: Pack TypeShim | |
| run: > | |
| dotnet pack src/TypeShim/TypeShim.csproj | |
| -c Release | |
| -o . | |
| --no-build | |
| -p:Version=${{ needs.version.outputs.version }} | |
| -p:ContinuousIntegrationBuild=true | |
| - name: Push to GitHub Packages | |
| if: ${{ !inputs.dry-run }} | |
| run: > | |
| dotnet nuget push | |
| TypeShim.${{ needs.version.outputs.version }}.nupkg | |
| -k ${{ secrets.NUGET_KEY }} | |
| -s https://api.nuget.org/v3/index.json | |
| - name: Upload NuGet package as artifact | |
| if: ${{ inputs.dry-run }} | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: typeshim-nupkg-${{ needs.version.outputs.version }} | |
| path: TypeShim.${{ needs.version.outputs.version }}.nupkg | |
| badge: | |
| name: 🏷️ Update Readme Badge | |
| needs: build | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Update badge | |
| uses: schneegans/dynamic-badges-action@v1.7.0 | |
| with: | |
| auth: ${{ secrets.GIST_TOKEN }} | |
| gistID: '0f24ed28316a25f6293d5771a247f19d' | |
| filename: typeshim-tests-badge.json | |
| label: Tests | |
| message: ${{ needs.build.outputs.badge-message }} | |
| color: ${{ needs.build.outputs.badge-color }} |