Uploaded many more actions.

This commit is contained in:
2025-07-01 13:17:09 -07:00
parent d49aadb058
commit 3148d266f2
10 changed files with 318 additions and 32 deletions

View File

@@ -4,6 +4,9 @@ set -o pipefail
# Add root tools to Path.
export PATH="$PATH:/root/.dotnet/tools/"
# Define a local application data folder.
export XDG_DATA_HOME="$HOME/.local/share"
mkdir -p "$XDG_DATA_HOME"
PROGRAM=${PROGRAM:-"dotnet"}
exec 5>&1
@@ -22,4 +25,4 @@ echo "exitCode=$RESULT" >> "$GITHUB_OUTPUT"
if [[ "$CATCH_ERRORS" != "true" ]]; then
exit $RESULT
fi
fi

View File

@@ -1,7 +1,7 @@
name: dotnet-nugetforunity-restore
description: "Restore NugetForUnity packages."
inputs:
projectPath:
projectPath:
description: "Path to the Unity project."
required: true
default: "."

View File

@@ -0,0 +1,101 @@
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:
- name: "Own workspace."
uses: act/common/utils/chown@master
- 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 }}
- 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 }}
- 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

View File

@@ -0,0 +1,88 @@
# 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: |
#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-6@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

View File

@@ -7,7 +7,10 @@ inputs:
url:
description: "URL of the nuget repository to push to."
required: true
default: ${{ github.server_url }}/_registry/nuget/${{ github.repository_owner }}/index.json
# This is for GitHub.
#default: ${{ github.server_url }}/_registry/nuget/${{ github.repository_owner }}/index.json
# This is for Gitea.
default: ${{ github.server_url }}/api/packages/${{ github.repository_owner }}/nuget/index.json
apiKey:
description: "ApiKey of the nuget repository to push to."
required: true
@@ -21,4 +24,4 @@ runs:
- name: "Push the NuGet package."
uses: act/common/dotnet/dotnet@master
with:
command: nuget push ${{ inputs.nupkg }} -s ${{ inputs.url }} -k ${{ inputs.apiKey }} ${{ inputs.options }}
command: nuget push ${{ inputs.nupkg }} -s ${{ inputs.url }} -k ${{ inputs.apiKey }} ${{ inputs.options }}

View File

@@ -0,0 +1,106 @@
# Reference: https://learn.microsoft.com/en-us/dotnet/core/tools/dotnet-test
name: dotnet-test
description: "Test a .csproj, .sln file, or .dll."
inputs:
project:
description: "The .csproj or .sln project to pack."
required: true
default: .
collect:
description: "Enable the data collector. Options: 'Code Coverage', 'XPlat Code Coverage' (for Coverlet)"
required: false
default: "XPlat Code Coverage"
resultsDirectory:
description: "Directory for the test results."
required: true
default: "TestResults"
logger:
description: "Logger to use. Default: trx"
required: false
default: "trx"
configuration:
description: "The build configuration to use. Default: Release"
required: false
default: "Release"
filter:
description: "Test filter expression."
required: false
default: ""
additionalArgs:
description: "Additional arguments to use when packing project."
required: false
testFormat:
description: "Test format to use when running tests. Default: opencover"
required: false
default: "opencover"
runSettings:
description: "Additional runs settings to use when testing the project."
required: false
default: ""
uploadArtifacts:
description: "Upload the test output as artifacts. Default: true"
required: false
default: "true"
artifactName:
description: "Name of the artifact to upload. Default: TestResults"
required: false
default: "TestResults"
retention-days:
description: "Default number of retention days."
required: false
default: "7"
runs:
using: "composite"
steps:
- name: "Build the test command."
id: command
run: |
COMMAND="test \"${{ inputs.project }}\" --nologo --results-directory \"${{ inputs.resultsDirectory }}\""
CONFIG="${{ inputs.configuration }}"
if [[ -n "$CONFIG" ]]; then
COMMAND="$COMMAND --configuration \"$CONFIG\""
fi
COLLECT="${{ inputs.collect }}"
if [[ -n "$COLLECT" ]]; then
COMMAND="$COMMAND --collect \"$COLLECT\""
fi
LOGGER="${{ inputs.logger }}"
if [[ -n "$LOGGER" ]]; then
COMMAND="$COMMAND --logger \"$LOGGER\""
fi
FILTER="${{ inputs.filter }}"
if [[ -n "$FILTER" ]]; then
COMMAND="$COMMAND $FILTER --filter \"$FILTER\""
fi
ADDITIONAL_ARGS="${{ inputs.additionalArgs }}"
if [[ -n "$ADDITIONAL_ARGS" ]]; then
COMMAND="$COMMAND $ADDITIONAL_ARGS"
fi
# For run settings.
COMMAND="$COMMAND --"
TEST_FORMAT="${{ inputs.testFormat }}"
if [[ -n "$TEST_FORMAT" ]]; then
COMMAND="$COMMAND DataCollectionRunSettings.DataCollectors.DataCollector.Configuration.Format=\"$TEST_FORMAT\""
fi
RUN_SETTINGS="${{ inputs.runSettings }}"
if [[ -n "$RUN_SETTINGS" ]]; then
COMMAND="$COMMAND $RUN_SETTINGS"
fi
echo "command=$COMMAND" >> "$GITHUB_OUTPUT"
shell: bash
- name: "Run the Unit Tests."
uses: act/common/dotnet/dotnet-6@master
with:
command: ${{ steps.command.outputs.command }}
- name: "Own artifacts."
uses: act/common/utils/chown@master
with:
file: ${{ inputs.resultsDirectory }}
- name: "Upload artifacts."
if: ${{ !env.ACT && ( inputs.uploadArtifacts == 'true' ) }}
uses: https://github.com/actions/upload-artifact@v3
with:
name: ${{ inputs.artifactName }}
path: ${{ inputs.resultsDirectory }}
if-no-files-found: error
retention-days: ${{ inputs.retention-days }}

View File

@@ -1,4 +1,4 @@
ARG VERSION=7.0
ARG VERSION=9.0
FROM mcr.microsoft.com/dotnet/sdk:$VERSION
RUN apt update
@@ -7,7 +7,8 @@ RUN apt install curl -y
# Add tools to Path.
RUN echo 'export PATH="$PATH:$HOME/.dotnet/tools/"' | tee -a "$HOME/.bashrc" > /dev/null
# Install NugetForUnity tool: https://github.com/GlitchEnzo/NuGetForUnity
RUN dotnet tool install --global NuGetForUnity.Cli
ENV NUGETFORUNITY_VERSION=3.1.3
RUN dotnet tool install --global NuGetForUnity.Cli --version ${NUGETFORUNITY_VERSION}
COPY entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh

View File

@@ -4,6 +4,9 @@ set -o pipefail
# Add root tools to Path.
export PATH="$PATH:/root/.dotnet/tools/"
# Define a local application data folder.
export XDG_DATA_HOME="$HOME/.local/share"
mkdir -p "$XDG_DATA_HOME"
PROGRAM=${PROGRAM:-"dotnet"}
exec 5>&1
@@ -22,4 +25,4 @@ echo "exitCode=$RESULT" >> "$GITHUB_OUTPUT"
if [[ "$CATCH_ERRORS" != "true" ]]; then
exit $RESULT
fi
fi