Skip to content

Publish Package

Publish Package #7

Workflow file for this run

name: Publish Package
on:
push:
branches:
- "releases/**"
paths:
- "GitVersion.yml"
pull_request:
branches:
- "releases/**"
paths:
- "GitVersion.yml"
workflow_dispatch:
jobs:
build_and_publish:
runs-on: ubuntu-latest
steps:
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
6.0.x
7.0.x
8.0.x
9.0.x
- name: Install gitversion
uses: gittools/actions/gitversion/[email protected]
with:
versionSpec: "5.x"
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/cache@v4
with:
path: ~/.nuget/packages
key: ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }}
restore-keys: |
${{ runner.os }}-nuget-
- name: Determine version
id: gitversion
uses: gittools/actions/gitversion/[email protected]
with:
useConfigFile: true
- name: Restore
run: dotnet restore
working-directory: src/main/
- name: Build .NET
run: dotnet build WebsocketClientLite.sln --configuration release /p:Version=${{ steps.gitversion.outputs.MajorMinorPatch }} /p:AssemblyVersion=${{ steps.gitversion.outputs.AssemblySemVer }} /p:InformationalVersion=${{ steps.gitversion.outputs.InformationalVersion }} --no-restore
working-directory: src/main/
- name: Pack WebsocketClientLite
run: dotnet pack WebsocketClientLite.csproj -c Release --no-build /p:Version=${{ steps.gitversion.outputs.MajorMinorPatch }}
working-directory: src/main/WebsocketClientLite/
- name: Pack IWebsocketClientLite (Interface)
run: dotnet pack IWebsocketClientLite.csproj -c Release --no-build /p:Version=${{ steps.gitversion.outputs.MajorMinorPatch }}
working-directory: src/interface/IWebsocketClientLite/
- name: Prep GitHub Packages
run: dotnet nuget add source --username ${{ github.repository_owner }} --password ${{ secrets.GITHUB_TOKEN }} --store-password-in-clear-text --name github "https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json"
- name: Publish WebsocketClientLite to GitHub packages
run: dotnet nuget push "*.nupkg" --api-key ${{ secrets.GITHUB_TOKEN }} --source "github" --skip-duplicate
working-directory: src/main/WebsocketClientLite/bin/Release/
- name: Publish IWebsocketClientLite (interface) to GitHub packages
run: dotnet nuget push "*.nupkg" --api-key ${{ secrets.GITHUB_TOKEN }} --source "github" --skip-duplicate
working-directory: src/interface/IWebsocketClientLite/bin/Release/
- name: Pack WebsocketClientLite for NuGet.org
run: dotnet pack WebsocketClientLite.csproj -c Release --no-build /p:PackageID="WebsocketClientLite.PCL" /p:Version=${{ steps.gitversion.outputs.MajorMinorPatch }}
working-directory: src/main/WebsocketClientLite/
- name: Publish WebsocketClientLite to Nuget.Org
run: dotnet nuget push WebsocketClientLite.PCL.*.nupkg --api-key ${{ secrets.NUGET_TOKEN }} --source https://api.nuget.org/v3/index.json --skip-duplicate
working-directory: src/main/WebsocketClientLite/bin/Release/
- name: Publish IWebsocketClientLite (interface) to Nuget.Org
run: dotnet nuget push "*.nupkg" --api-key ${{ secrets.NUGET_TOKEN }} --source https://api.nuget.org/v3/index.json --skip-duplicate
working-directory: src/interface/IWebsocketClientLite/bin/Release/
- name: Create Release
id: create_release
uses: actions/create-release@v1 # Note: This is deprecated but retained for compatibility
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.gitversion.outputs.AssemblySemVer }}
release_name: Release ${{ steps.gitversion.outputs.AssemblySemVer }}
body: |
Changes in this Release
- Multi-framework targeting (.NET Standard 2.0, .NET Standard 2.1, .NET 6+)
- Split interface package from implementation package
- DevOps improvements
draft: true
prerelease: true