110 lines
3.6 KiB
YAML
110 lines
3.6 KiB
YAML
name: nuget-pack-and-compare
|
|
description: "Pack a .sln or .csproj file into a .nupkg."
|
|
inputs:
|
|
name:
|
|
description: "The name of the package."
|
|
required: true
|
|
project:
|
|
description: "The .sln or .csproj project to pack."
|
|
required: true
|
|
configuration:
|
|
description: "The build configuration to use. Default: Release"
|
|
required: false
|
|
default: "Release"
|
|
additionalArgs:
|
|
description: "Additional arguments to use when packing project."
|
|
required: false
|
|
keepSymbols:
|
|
description: "Keep the '.symbols.nupkg' artifacts. Default: true"
|
|
required: false
|
|
default: "true"
|
|
defaultVersion:
|
|
description: "Version of the .nupkg file."
|
|
required: true
|
|
default: 1.0.0
|
|
outputDirectory:
|
|
description: "Directory for the output .nupkg."
|
|
required: true
|
|
default: "out"
|
|
url:
|
|
description: "Url of the GitHub server instance."
|
|
required: true
|
|
default: ${{ github.server_url }}
|
|
organization:
|
|
description: "Organization to search."
|
|
required: true
|
|
default: ${{ github.repository_owner }}
|
|
username:
|
|
description: "Username for the nuget repository to search."
|
|
required: true
|
|
default: ${{ github.actor }}
|
|
password:
|
|
description: "Password or ApiKey of the nuget repository to search."
|
|
required: true
|
|
default: ${{ github.token }}
|
|
outputs:
|
|
nupkg:
|
|
description: "The generated output .nupkg file."
|
|
value: ${{ steps.package.outputs.nupkg }}
|
|
nupkgName:
|
|
description: "The generated output .nupkg file's name."
|
|
value: ${{ steps.package.outputs.nupkgName }}
|
|
hasChanged:
|
|
description: "Whether or not the .nupkg files match."
|
|
value: ${{ steps.compare.outputs.success != 'true' }}
|
|
runs:
|
|
using: "composite"
|
|
steps:
|
|
- run: echo "Own workspace."
|
|
shell: bash
|
|
- name: "Own workspace."
|
|
uses: act/common/utils/chown@master
|
|
- run: echo "Get the next version of the package."
|
|
shell: bash
|
|
- name: "Get the next version of the package."
|
|
uses: act/common/nuget/nuget-get-next-branched-version@master
|
|
id: nuget
|
|
with:
|
|
name: ${{ inputs.name }}
|
|
defaultVersion: ${{ inputs.defaultVersion }}
|
|
url: ${{ inputs.url }}
|
|
organization: ${{ inputs.organization }}
|
|
apiToken: ${{ inputs.password }}
|
|
- run: echo "Build .nupkg."
|
|
shell: bash
|
|
- name: "Build .nupkg."
|
|
uses: act/common/dotnet/dotnet-pack@master
|
|
with:
|
|
project: ${{ inputs.project || inputs.name }}
|
|
id: ${{ inputs.name }}
|
|
version: ${{ steps.nuget.outputs.nextVersion }}
|
|
configuration: ${{ inputs.configuration }}
|
|
outputDirectory: ${{ inputs.outputDirectory }}
|
|
keepSymbols: ${{ inputs.keepSymbols }}
|
|
additionalArgs: ${{ inputs.additionalArgs }}
|
|
- run: echo "Generate package outputs."
|
|
shell: bash
|
|
- name: "Generate package outputs."
|
|
id: package
|
|
run: |
|
|
NUPKG_EXT=".nupkg"
|
|
if [ "${{ inputs.keepSymbols }}" == "true" ]; then
|
|
NUPKG_EXT=".symbols$NUPKG_EXT"
|
|
fi
|
|
NUPKG_NAME="${{ inputs.name }}.${{ steps.nuget.outputs.nextVersion }}$NUPKG_EXT"
|
|
NUPKG_PATH="${{ inputs.outputDirectory }}/$NUPKG_NAME"
|
|
echo "nupkg=$NUPKG_PATH" >> "$GITHUB_OUTPUT"
|
|
echo "nupkgName=$NUPKG_NAME" >> "$GITHUB_OUTPUT"
|
|
shell: bash
|
|
- name: "Compare .nupkg to remote .nupkg."
|
|
if: ${{ steps.nuget.outputs.latestVersion }}
|
|
id: compare
|
|
uses: act/common/nuget/nuget-compare-version@master
|
|
with:
|
|
lhs: ${{ steps.package.outputs.nupkg }}
|
|
version: ${{ steps.nuget.outputs.latestVersion }}
|
|
name: ${{ inputs.name }}
|
|
username: ${{ inputs.username }}
|
|
password: ${{ inputs.password }}
|
|
url: ${{ inputs.url }}/_registry/nuget/${{ inputs.organization }}/index.json
|