Sitelet https://github.com/NodeOps-app/createos-csharp-sdk/actions/runs/35094639124/workflow
Skip to content

v0.1.2

v0.1.2 #4

Workflow file for this run

name: Publish NuGet Package
on:
release:
types: [published]
permissions:
contents: read
id-token: write
jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
- name: Validate release tag
id: version
shell: bash
run: |
if [[ ! "$GITHUB_REF_NAME" =~ ^v?[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z][0-9A-Za-z.-]*)?$ ]]; then
echo "Release tag must be a NuGet version such as v0.1.0 or v0.2.0-rc.1" >&2
exit 1
fi
echo "value=${GITHUB_REF_NAME#v}" >> "$GITHUB_OUTPUT"
- name: Validate package version
env:
PACKAGE_VERSION: ${{ steps.version.outputs.value }}
run: |
project_version="$(dotnet msbuild src/CreateOS.Sandbox/CreateOS.Sandbox.csproj -getProperty:Version)"
if [[ "$project_version" != "$PACKAGE_VERSION" ]]; then
echo "Release tag version $PACKAGE_VERSION does not match project version $project_version." >&2
exit 1
fi
- run: dotnet restore CreateOS.Sandbox.sln
- run: dotnet format CreateOS.Sandbox.sln --verify-no-changes --no-restore
- name: Build solution
run: dotnet build CreateOS.Sandbox.sln --configuration Release --no-restore -p:Version="$PACKAGE_VERSION"
env:
PACKAGE_VERSION: ${{ steps.version.outputs.value }}
- run: dotnet test CreateOS.Sandbox.sln --configuration Release --no-build
- name: Pack SDK
run: dotnet pack src/CreateOS.Sandbox/CreateOS.Sandbox.csproj --configuration Release --no-build --no-restore -p:Version="$PACKAGE_VERSION" --output artifacts
env:
PACKAGE_VERSION: ${{ steps.version.outputs.value }}
- name: Validate nuget.org account
env:
NUGET_USER: ${{ vars.NUGET_USER }}
run: |
if [[ -z "$NUGET_USER" ]]; then
echo "Set the NUGET_USER repository variable to the nuget.org profile name." >&2
exit 1
fi
- name: Sign in to nuget.org with GitHub OIDC
id: login
uses: NuGet/login@v1
with:
user: ${{ vars.NUGET_USER }}
- name: Publish to nuget.org
run: dotnet nuget push "artifacts/CreateOS.Sandbox.${PACKAGE_VERSION}.nupkg" --source https://api.nuget.org/v3/index.json --api-key "$NUGET_API_KEY" --skip-duplicate
env:
PACKAGE_VERSION: ${{ steps.version.outputs.value }}
NUGET_API_KEY: ${{ steps.login.outputs.NUGET_API_KEY }}