Publish to NuGet #7
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 to NuGet | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| version: | |
| description: 'Version to release (e.g., 0.0.1)' | |
| required: true | |
| type: string | |
| env: | |
| DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1 | |
| DOTNET_NOLOGO: true | |
| DOTNET_CLI_TELEMETRY_OPTOUT: 1 | |
| jobs: | |
| publish: | |
| name: Build, Pack & Publish | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Setup .NET | |
| uses: actions/setup-dotnet@v4 | |
| with: | |
| dotnet-version: '9.0.x' | |
| - name: Restore | |
| run: dotnet restore | |
| - name: Build | |
| run: dotnet build --configuration Release --no-restore -p:Version=${{ inputs.version }} | |
| - name: Pack | |
| run: dotnet pack src/ObsKit.NET/ObsKit.NET.csproj --configuration Release --no-build -p:PackageVersion=${{ inputs.version }} --output ./nupkg | |
| - name: Push to NuGet | |
| run: dotnet nuget push ./nupkg/*.nupkg --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json --skip-duplicate | |
| - name: Create tag | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| git tag "v${{ inputs.version }}" | |
| git push origin "v${{ inputs.version }}" | |
| - name: Create GitHub Release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: v${{ inputs.version }} | |
| name: v${{ inputs.version }} | |
| body: | | |
| ## ObsKit.NET v${{ inputs.version }} | |
| Install via NuGet: | |
| ``` | |
| dotnet add package ObsKit.NET --version ${{ inputs.version }} | |
| ``` | |
| Or via Package Manager: | |
| ``` | |
| Install-Package ObsKit.NET -Version ${{ inputs.version }} | |
| ``` | |
| files: ./nupkg/*.nupkg | |
| generate_release_notes: true |