Added many, many more actions.

This commit is contained in:
2025-06-24 15:24:16 -07:00
parent 62fbe4dead
commit 57ef232d2b
108 changed files with 4212 additions and 7 deletions

View File

@@ -0,0 +1,79 @@
name: nuget-build-and-compare
description: "Pack a .nuspec file into a .nupkg."
inputs:
name:
description: "The name of the package."
required: true
input:
description: "The json input which will be converted into yaml."
required: true
defaultVersion:
description: "Version of the .nupkg file."
required: true
default: 1.0.0
outputDirectory:
description: "Directory for the output .nupkg."
required: true
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: "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: "Get yaml from json."
id: convert
uses: act/common/yq/yq-convert@master
with:
from: json
to: yaml
input: ${{ inputs.input }}
- name: "Build .nupkg."
id: package
uses: act/common/tpl/tpl-to-nupkg@master
with:
input: ${{ steps.convert.outputs.result }}
version: ${{ steps.nuget.outputs.nextVersion }}
outputDirectory: ${{ inputs.outputDirectory }}
- 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,69 @@
name: nuget-compare-version
description: "Download the desired .nupkg file and compare it to an existing .nupkg file."
inputs:
lhs:
description: "Path to the existing .nupkg file."
required: true
name:
description: "Name of the .nupkg file."
required: true
version:
description: "Version of the .nupkg file."
required: false
default: ""
prerelease:
description: "Install prerelease packages. Values: true, false."
required: false
default: "${{ github.event_name == 'pull_request' }}"
url:
description: "Url of the NuGet repository."
required: true
default: ${{ github.server_url }}/_registry/nuget/${{ github.repository_owner }}/index.json
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 }}
tmpDir:
description: "Temporary directory. Default: _tmp"
required: true
default: _tmp
outputs:
success:
description: "Whether or not the .nupkg files match."
value: ${{ steps.compare.outputs.success }}
runs:
using: "composite"
steps:
- name: "Make temporary folder if we are using .nupkg only."
id: mktmp
uses: act/common/utils/mktemp@master
with:
tmpDir: ${{ inputs.tmpDir }}
outputType: dir
- name: "Get the desired version of the package."
id: install
uses: act/common/nuget/nuget-install@master
with:
name: ${{ inputs.name }}
version: ${{ inputs.version }}
prerelease: ${{ inputs.prerelease }}
url: ${{ inputs.url }}
username: ${{ inputs.username }}
password: ${{ inputs.password }}
outputDirectory: ${{ steps.mktmp.outputs.tmp }}
nupkgOnly: true
directDownload: true
cleanTmp: false
- name: "Compare the two .nupkg files."
id: compare
uses: act/common/utils/compare-nupkg@master
with:
lhs: ${{ inputs.lhs }}
rhs: ${{ steps.install.outputs.nupkg }}
- name: "Remove temporary files."
run: rm -rf "${{ inputs.tmpDir }}"
shell: bash

View File

@@ -0,0 +1,66 @@
name: nuget-get-next-branched-version
description: "Get the next version of a NuGet package based on the current branch status."
inputs:
name:
description: "The name of the package."
required: true
defaultVersion:
description: "Default version to use."
required: true
default: 1.0.0
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 }}
apiToken:
description: "Api Token for GitHub."
required: true
default: ${{ github.token }}
prerelease:
description: "Query prerelease packages. Values: true, false."
required: false
default: "${{ github.event_name == 'pull_request' }}"
outputs:
latestVersion:
description: "The current latest version for the .nupkg."
value: ${{ steps.nuget.outputs.version || steps.nugetFallback.outputs.version }}
nextVersion:
description: "The next version for the .nupkg file."
value: ${{ steps.version.outputs.nextVersion }}
runs:
using: "composite"
steps:
- name: "Get the base version for the package."
uses: act/common/utils/version-increment-branch@master
id: base
with:
version: ${{ inputs.defaultVersion }}
- uses: act/common/github/github-query-nuget-versions-latest@master
id: nuget
with:
name: ${{ inputs.name }}
url: ${{ inputs.url }}
organization: ${{ inputs.organization }}
apiToken: ${{ inputs.apiToken }}
filter: ^${{ steps.base.outputs.baseVersion }}
prerelease: ${{ inputs.prerelease }}
- name: "If no version is found, get the latest version for the package if we didn't already look for it."
uses: act/common/github/github-query-nuget-versions-latest@master
id: nugetFallback
if: ${{ steps.nuget.outputs.version == '' && inputs.prerelease != 'false' }}
with:
name: ${{ inputs.name }}
url: ${{ inputs.url }}
organization: ${{ inputs.organization }}
apiToken: ${{ inputs.apiToken }}
filter: ^${{ steps.base.outputs.majorMinorPatchVersion }}
prerelease: false
- name: "Get the next version for the package."
uses: act/common/utils/version-increment-branch@master
id: version
with:
version: ${{ steps.nuget.outputs.version || steps.nugetFallback.outputs.version || inputs.defaultVersion }}

View File

@@ -0,0 +1,135 @@
name: nuget-install
description: "Download the desired .nupkg file."
inputs:
name:
description: "Name of the .nupkg file."
required: true
version:
description: "Version of the .nupkg file."
required: false
default: ""
prerelease:
description: "Install prerelease packages. Values: true, false."
required: false
default: "false"
outputDirectory:
description: "Directory for the output file."
required: true
default: "."
directDownload:
description: "Download the .nupkg file directly from the source."
required: true
default: "true"
excludeVersion:
description: "Exclude the version when downloading the .nuget package."
required: true
default: "false"
nupkgOnly:
description: "Only output the .nupkg file directly to the output directory."
required: true
default: "false"
additionalArgs:
description: "Additional arguments to use when dowloading the .nupkg file."
required: false
source:
description: "Name of the source to use."
required: true
default: lewdorg
url:
description: "Url of the NuGet repository."
required: true
default: ${{ github.server_url }}/_registry/nuget/${{ github.repository_owner }}/index.json
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 }}
tmpDir:
description: "Temporary directory. Default: _tmp"
required: true
default: _tmp
cleanTmp:
description: "Remove the temporary directory after use. Default: true"
required: true
default: "true"
outputs:
nupkg:
description: "The path to the .nupkg file."
value: ${{ steps.move.outputs.nupkg }}
runs:
using: "composite"
steps:
- name: "Make temporary folder if we are using .nupkg only."
id: mktmp
uses: act/common/utils/mktemp@master
with:
tmpDir: ${{ inputs.tmpDir }}
outputType: dir
- name: "Create Output Directory"
run: |
OUTPUT_DIR="${{ inputs.outputDirectory }}"
mkdir "$OUTPUT_DIR" -p
shell: bash
- name: "Build nuget command."
id: command
run: |
COMMAND="install ${{ inputs.name }} -OutputDirectory \"${{ steps.mktmp.outputs.tmp }}\" ${{ inputs.additionalArgs }}"
VERSION="${{ inputs.version }}"
PRERELEASE="${{ inputs.prerelease }}"
DIRECT="${{ inputs.directDownload }}"
if [ "$DIRECT" == "true" ]; then
COMMAND="$COMMAND -DirectDownload"
fi
if [ -n "$VERSION" ]; then
COMMAND="$COMMAND -Version $VERSION"
fi
if [ "$PRERELEASE" == "true" ]; then
COMMAND="$COMMAND -Prerelease"
fi
echo "command=$COMMAND" >> "$GITHUB_OUTPUT"
shell: bash
- name: "Download the .nupkg file."
uses: act/common/nuget/nuget@master
with:
command: ${{ steps.command.outputs.command }}
username: ${{ inputs.username }}
password: ${{ inputs.password }}
source: ${{ inputs.source }}
url: ${{ inputs.url }}
- name: "Take ownership of the artifacts."
uses: act/common/utils/chown@master
with:
file: ${{ steps.mktmp.outputs.tmp }}
- name: "Copy contents to output folder."
id: move
run: |
OUTPUT_DIR="${{ inputs.outputDirectory }}"
TMP_DIR="${{ steps.mktmp.outputs.tmp }}"
EXCLUDE_VERSION="${{ inputs.excludeVersion }}"
NUPKG_ONLY="${{ inputs.nupkgOnly }}"
if [ "$EXCLUDE_VERSION" == "true" ]; then
NUPKG_NAME="${{ inputs.name }}.nupkg"
else
# Get the subdirectory name
OUTDIR=($TMP_DIR/*)
BASE_NAME=$(basename "$OUTDIR")
NUPKG_NAME="${BASE_NAME}.nupkg"
fi
if [ "$NUPKG_ONLY" == "true" ]; then
mv "$OUTDIR/$NUPKG_NAME" "$OUTPUT_DIR"
echo "nupkg=$OUTPUT_DIR/$NUPKG_NAME" >> "$GITHUB_OUTPUT"
else
mv "$TMP_DIR"/* "$OUTPUT_DIR"
echo "nupkg=$OUTPUT_DIR/$OUTDIR/$NUPKG_NAME" >> "$GITHUB_OUTPUT"
fi
shell: bash
- name: "Remove temporary files."
if: ${{ inputs.cleanTmp == 'true' }}
run: rm -rf "${{ inputs.tmpDir }}"
shell: bash

View File

@@ -0,0 +1,37 @@
name: nuget-pack
description: "Pack a .nuspec file into a .nupkg."
inputs:
nuspec:
description: "The .nuspec file or configuration to pack."
required: true
version:
description: "Version of the .nupkg file."
required: true
outputDirectory:
description: "Directory for the output file."
required: true
additionalArgs:
description: "Additional arguments to use when packing the .nuspec file."
required: false
runs:
using: "composite"
steps:
- name: "Make temporary file of nuspec."
id: tmp
uses: act/common/utils/mktemp@master
with:
input: ${{ inputs.nuspec }}
tmpDir: .
additionalArgs: --suffix=.nuspec
- name: "Create Output Directory"
run: |
OUTPUT_DIR="${{ inputs.outputDirectory }}"
mkdir "$OUTPUT_DIR" -p
shell: bash
- name: "Build the .nupkg file."
uses: act/common/nuget/nuget@master
with:
command: pack "${{ steps.tmp.outputs.tmp }}" -OutputDirectory "${{ inputs.outputDirectory }}" -Version "${{ inputs.version }}" ${{ inputs.additionalArgs }}
- name: "Remove temporary files."
run: rm -rf "${{ steps.tmp.outputs.tmp }}"
shell: bash

View File

@@ -0,0 +1,37 @@
name: nuget-upload-nupkg
description: "Upload a nupkg to a NuGet repository."
inputs:
package:
description: "Name of the package to search for."
required: true
source:
description: "Name of the source to use."
required: true
default: lewdorg
url:
description: "Url of the NuGet repository."
required: true
default: ${{ github.server_url }}/_registry/nuget/${{ github.repository_owner }}/index.json
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 }}
options:
description: "Additional options when uploading."
required: false
runs:
using: "composite"
steps:
- name: "Run nuget push."
id: nuget
uses: act/common/nuget/nuget@master
with:
command: push ${{ inputs.package }} -Source ${{ inputs.source }} ${{ inputs.options }}
username: ${{ inputs.username }}
password: ${{ inputs.password }}
source: ${{ inputs.source }}
url: ${{ inputs.url }}

20
nuget/nuget/Dockerfile Normal file
View File

@@ -0,0 +1,20 @@
FROM debian:stable-slim
ENV VERSION=v6.5.0
RUN apt-get update
RUN apt-get install -y --no-install-recommends \
bash \
wget \
mono-complete \
tzdata
RUN apt-get clean
RUN rm -rf /var/lib/apt/lists/*
RUN wget https://dist.nuget.org/win-x86-commandline/$VERSION/nuget.exe -O /usr/bin/nuget.exe
RUN chmod +x /usr/bin/nuget.exe
COPY entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]

39
nuget/nuget/action.yaml Normal file
View File

@@ -0,0 +1,39 @@
name: nuget
description: "Run a nuget command."
inputs:
command:
description: "Nuget command to run."
required: false
catchErrors:
description: "Whether or not errors should be handled."
required: false
source:
description: "Name of the source to use."
required: false
default: origin
url:
description: "Url of the NuGet repository."
required: false
default: ${{ github.server_url }}/_registry/nuget/${{ github.repository_owner }}/index.json
username:
description: "Username for the nuget repository to search."
required: false
default: ${{ github.actor }}
password:
description: "Password or ApiKey of the nuget repository to search."
required: false
default: ${{ github.token }}
outputs:
console:
description: "The console output of the command."
runs:
using: 'docker'
image: 'Dockerfile'
env:
NUGET_SOURCE_NAME: ${{ inputs.source }}
NUGET_SOURCE_URL: ${{ inputs.url }}
NUGET_SOURCE_USERNAME: ${{ inputs.username }}
NUGET_SOURCE_PASSWORD: ${{ inputs.password }}
CATCH_ERRORS: ${{ inputs.catchErrors }}
args:
- ${{ inputs.command }}

32
nuget/nuget/entrypoint.sh Normal file
View File

@@ -0,0 +1,32 @@
#!/bin/bash
#TODO: Reweite this action to make use of act/common/mono/mono
function nuget
{
mono /usr/bin/nuget.exe $@
}
if [[ -n "$NUGET_SOURCE_NAME" && -n "$NUGET_SOURCE_URL" && -n "$NUGET_SOURCE_USERNAME" && -n "$NUGET_SOURCE_PASSWORD" ]]; then
nuget source remove -Name "$NUGET_SOURCE_NAME"
nuget source add -Name "$NUGET_SOURCE_NAME" -Source "$NUGET_SOURCE_URL" -Username "$NUGET_SOURCE_USERNAME" -Password "$NUGET_SOURCE_PASSWORD"
SET_SOURCE=true
fi
OUTPUT=$(bash -c "mono /usr/bin/nuget.exe $@")
RESULT=$?
echo "$OUTPUT"
#Output multiline strings.
#https://trstringer.com/github-actions-multiline-strings/
if [[ -n "$OUTPUT" ]]; then
echo "console<<EOF" >> "$GITHUB_OUTPUT"
echo "$OUTPUT" >> "$GITHUB_OUTPUT"
echo "EOF" >> "$GITHUB_OUTPUT"
fi
if [[ -n "$SET_SOURCE" ]]; then
nuget source remove -Name "$NUGET_SOURCE_NAME"
fi
if [[ "$CATCH_ERRORS" != "true" ]]; then
exit $RESULT
fi