94 lines
3.0 KiB
YAML
94 lines
3.0 KiB
YAML
# Reference: https://learn.microsoft.com/en-us/dotnet/core/tools/dotnet-pack
|
|
name: dotnet-pack
|
|
description: "Pack a .sln or .csproj file into a .nupkg."
|
|
inputs:
|
|
project:
|
|
description: "The .sln or .csproj project to pack."
|
|
required: true
|
|
default: .
|
|
id:
|
|
description: "The id of the package. Defaults to the AssemblyName."
|
|
required: false
|
|
default: ""
|
|
version:
|
|
description: "Version of the .nupkg file."
|
|
required: false
|
|
default: ""
|
|
outputDirectory:
|
|
description: "Directory for the output file."
|
|
required: true
|
|
repositoryBranch:
|
|
description: "The repository branch of the package."
|
|
required: false
|
|
default: ${{ github.ref_name }}
|
|
deterministic:
|
|
description: "Whether or not the build should be deterministic. Default: true"
|
|
required: false
|
|
default: "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"
|
|
runs:
|
|
using: "composite"
|
|
steps:
|
|
- name: "Parse the version."
|
|
id: version
|
|
uses: act/common/utils/version-parse@master
|
|
with:
|
|
version: ${{ inputs.version }}
|
|
- name: "Build the pack command."
|
|
id: command
|
|
run: |
|
|
NAME="Dotnet Pack"
|
|
echo "::group::$NAME - Inputs"
|
|
echo "${{ toJSON(inputs) }}"
|
|
echo "::endgroup::"
|
|
|
|
#https://learn.microsoft.com/en-us/dotnet/standard/library-guidance/versioning
|
|
MMP_VERSION="${{ steps.version.outputs.major || 0 }}.${{ steps.version.outputs.minor || 0 }}"
|
|
|
|
COMMAND="pack \"${{ inputs.project }}\" --output \"${{ inputs.outputDirectory }}\""
|
|
CONFIG="${{ inputs.configuration }}"
|
|
if [[ -n "$CONFIG" ]]; then
|
|
COMMAND="$COMMAND --configuration \"$CONFIG\""
|
|
fi
|
|
ID="${{ inputs.id }}"
|
|
if [[ -n "$ID" ]]; then
|
|
COMMAND="$COMMAND -p:PackageId=$ID"
|
|
fi
|
|
VERSION="${{ inputs.version }}"
|
|
if [[ -n "$VERSION" ]]; then
|
|
COMMAND="$COMMAND -p:Version=$VERSION -p:AssemblyVersion=$MM_VERSION"
|
|
fi
|
|
BRANCH="${{ inputs.repositoryBranch }}"
|
|
if [[ -n "$BRANCH" ]]; then
|
|
COMMAND="$COMMAND -p:RepositoryBranch=$BRANCH"
|
|
fi
|
|
DETERMINISTIC="${{ inputs.deterministic }}"
|
|
if [[ "$DETERMINISTIC" == "true" ]]; then
|
|
COMMAND="$COMMAND -p:ContinuousIntegrationBuild=$DETERMINISTIC"
|
|
fi
|
|
echo "command=$COMMAND ${{ inputs.additionalArgs }}" >> "$GITHUB_OUTPUT"
|
|
shell: bash
|
|
- name: "Build the .nupkg file."
|
|
uses: act/common/dotnet/dotnet@master
|
|
with:
|
|
command: ${{ steps.command.outputs.command }}
|
|
- name: "Own artifacts."
|
|
uses: act/common/utils/chown@master
|
|
with:
|
|
file: ${{ inputs.outputDirectory }}
|
|
- name: "Remove symbols."
|
|
if: ${{ inputs.keepSymbols == 'false' }}
|
|
run: |
|
|
rm -rf "${{ inputs.outputDirectory }}"/*.symbols.nupkg
|
|
shell: bash
|