Added many, many more actions.
This commit is contained in:
32
tpl/tpl-env/action.yaml
Normal file
32
tpl/tpl-env/action.yaml
Normal file
@@ -0,0 +1,32 @@
|
||||
name: tpl-env
|
||||
description: "Format a Go template file given yaml input. The input has yaml file environment variables replaced first."
|
||||
inputs:
|
||||
template:
|
||||
description: "Template or local path of the template file."
|
||||
required: true
|
||||
decoder:
|
||||
description: "Decoder format. Supported values: json, yaml, toml"
|
||||
required: true
|
||||
default: yaml
|
||||
input:
|
||||
description: "Input or local path of the input data file."
|
||||
required: true
|
||||
outputs:
|
||||
result:
|
||||
description: "Local path of the output file."
|
||||
value: ${{ steps.template.outputs.result }}
|
||||
runs:
|
||||
using: "composite"
|
||||
steps:
|
||||
- name: "Substitute Environment Variables"
|
||||
id: envsubst
|
||||
uses: act/common/utils/envsubst@master
|
||||
with:
|
||||
input: ${{ inputs.input }}
|
||||
- name: "Build Template"
|
||||
id: template
|
||||
uses: act/common/tpl/tpl-file@master
|
||||
with:
|
||||
template: ${{ inputs.template }}
|
||||
decoder: ${{ inputs.decoder }}
|
||||
input: ${{ steps.envsubst.outputs.result }}
|
||||
45
tpl/tpl-file/action.yaml
Normal file
45
tpl/tpl-file/action.yaml
Normal file
@@ -0,0 +1,45 @@
|
||||
name: tpl-file
|
||||
description: "Format a Go template file given a yaml input file."
|
||||
inputs:
|
||||
template:
|
||||
description: "Template or local path of the template file."
|
||||
required: true
|
||||
decoder:
|
||||
description: "Decoder format. Supported values: json, yaml, toml"
|
||||
required: true
|
||||
default: yaml
|
||||
input:
|
||||
description: "Input or local path of the input data file."
|
||||
required: true
|
||||
tmpDir:
|
||||
description: "Temporary directory. Default: _tmp"
|
||||
required: true
|
||||
default: _tmp
|
||||
outputs:
|
||||
result:
|
||||
description: "Local path of the output file."
|
||||
value: ${{ steps.template.outputs.console }}
|
||||
runs:
|
||||
using: "composite"
|
||||
steps:
|
||||
- name: "Make temporary file of template."
|
||||
id: mktmp-template
|
||||
uses: act/common/utils/mktemp@master
|
||||
with:
|
||||
input: ${{ inputs.template }}
|
||||
tmpDir: ${{ inputs.tmpDir }}
|
||||
- name: "Make temporary file of input."
|
||||
id: mktmp-input
|
||||
uses: act/common/utils/mktemp@master
|
||||
with:
|
||||
input: ${{ inputs.input }}
|
||||
tmpDir: ${{ inputs.tmpDir }}
|
||||
- name: "Generate template."
|
||||
id: template
|
||||
uses: act/common/tpl/tpl@master
|
||||
with:
|
||||
command: --file "${{ steps.mktmp-template.outputs.tmp }}" --decoder ${{ inputs.decoder }} < "${{ steps.mktmp-input.outputs.tmp }}"
|
||||
- name: "Remove temporary files."
|
||||
run: rm -rf "${{ inputs.tmpDir }}"
|
||||
shell: bash
|
||||
|
||||
38
tpl/tpl-to-dir/action.yaml
Normal file
38
tpl/tpl-to-dir/action.yaml
Normal file
@@ -0,0 +1,38 @@
|
||||
name: tpl-to-dir
|
||||
description: "Format a Go template file given a yaml input file to a file of the same name in the specified output directory. The input yaml file environment variables replaced first."
|
||||
inputs:
|
||||
templateFile:
|
||||
description: "Local path to the template file."
|
||||
required: true
|
||||
inputFilename:
|
||||
description: "Name of the input file without directories or extensions."
|
||||
required: true
|
||||
inputExtension:
|
||||
description: "Extension for the input file."
|
||||
required: false
|
||||
default: .yaml
|
||||
outputExtension:
|
||||
description: "Extension for the output file."
|
||||
required: false
|
||||
inputDirectory:
|
||||
description: "Directory for the input files."
|
||||
required: false
|
||||
outputDirectory:
|
||||
description: "Directory for the output files."
|
||||
required: false
|
||||
outputs:
|
||||
outputFile:
|
||||
description: "The generated output file."
|
||||
value: ${{ inputs.outputDirectory }}/${{ inputs.inputFilename }}${{ inputs.outputExtension }}
|
||||
runs:
|
||||
using: "composite"
|
||||
steps:
|
||||
- name: "Create Output Directory"
|
||||
run: mkdir ${{ inputs.outputDirectory }} -p
|
||||
shell: bash
|
||||
- name: "Generate Template"
|
||||
uses: act/common/tpl/tpl-env@master
|
||||
with:
|
||||
templateFile: ${{ inputs.inputDirectory }}/${{ inputs.templateFile }}
|
||||
inputFile: ${{ inputs.inputDirectory }}/${{ inputs.inputFilename }}${{ inputs.inputExtension }}
|
||||
outputFile: ${{ inputs.outputDirectory }}/${{ inputs.inputFilename }}${{ inputs.outputExtension }}
|
||||
50
tpl/tpl-to-nupkg/action.yaml
Normal file
50
tpl/tpl-to-nupkg/action.yaml
Normal file
@@ -0,0 +1,50 @@
|
||||
name: tpl-to-nupkg
|
||||
description: "Pack a .nupkg given a .nuspec Go template file and a yaml input file. The input yaml file environment variables replaced first."
|
||||
inputs:
|
||||
template:
|
||||
description: "Template or local path of the template file to use. Defaults to the template file in the action's directory."
|
||||
required: false
|
||||
input:
|
||||
description: "Input or local path of the yaml input data file."
|
||||
required: true
|
||||
version:
|
||||
description: "Version of the .nupkg file."
|
||||
required: true
|
||||
outputDirectory:
|
||||
description: "Directory for the output file."
|
||||
required: true
|
||||
default: '.'
|
||||
nuspecExtension:
|
||||
description: "Extension for the output file."
|
||||
required: false
|
||||
default: .nuspec
|
||||
tmpDir:
|
||||
description: "Temporary directory. Default: _tmp"
|
||||
required: true
|
||||
default: _tmp
|
||||
outputs:
|
||||
nuspec:
|
||||
description: "The generated output .nuspec file."
|
||||
value: ${{ steps.template.outputs.result }}
|
||||
nupkg:
|
||||
description: "The generated output .nupkg file."
|
||||
value: ${{ inputs.outputDirectory }}/${{ steps.nuspec.outputs.packageName }}.${{ inputs.version }}.nupkg
|
||||
nupkgName:
|
||||
description: "The generated output .nupkg file's name."
|
||||
value: ${{ steps.nuspec.outputs.packageName }}.${{ inputs.version }}.nupkg
|
||||
runs:
|
||||
using: "composite"
|
||||
steps:
|
||||
- name: "Generate Nuspec From Template"
|
||||
id: nuspec
|
||||
uses: act/common/tpl/tpl-to-nuspec@master
|
||||
with:
|
||||
template: ${{ inputs.template }}
|
||||
input: ${{ inputs.input }}
|
||||
- name: "Build the .nupkg file."
|
||||
uses: act/common/nuget/nuget-pack@master
|
||||
with:
|
||||
nuspec: ${{ steps.nuspec.outputs.nuspec }}
|
||||
version: ${{ inputs.version }}
|
||||
outputDirectory: ${{ inputs.outputDirectory }}
|
||||
|
||||
67
tpl/tpl-to-nuspec/action.yaml
Normal file
67
tpl/tpl-to-nuspec/action.yaml
Normal file
@@ -0,0 +1,67 @@
|
||||
name: tpl-to-nuspec
|
||||
description: "Pack a .nupkg given a .nuspec Go template file and a yaml input file. The input yaml file environment variables replaced first."
|
||||
inputs:
|
||||
template:
|
||||
description: "Template or local path of the template file to use. Defaults to the template file in the action's directory."
|
||||
required: false
|
||||
input:
|
||||
description: "Input or local path of the yaml input data file."
|
||||
required: true
|
||||
outputs:
|
||||
nuspec:
|
||||
description: "The generated output .nuspec file."
|
||||
value: ${{ steps.xml.outputs.result }}
|
||||
packageName:
|
||||
description: "The 'name' property of the generated .nuspec file."
|
||||
value: ${{ steps.name.outputs.result }}
|
||||
runs:
|
||||
using: "composite"
|
||||
steps:
|
||||
- name: "Set template variable."
|
||||
id: get-template
|
||||
run: |
|
||||
TEMPLATE=$(cat << EOF
|
||||
${{ inputs.template }}
|
||||
EOF
|
||||
)
|
||||
if [[ -z "$TEMPLATE" ]]; then
|
||||
TEMPLATE="${{ github.action_path }}/nuspec.yaml.tpl"
|
||||
fi
|
||||
|
||||
echo "template<<EOF" >> "$GITHUB_OUTPUT"
|
||||
echo "$TEMPLATE" >> "$GITHUB_OUTPUT"
|
||||
echo "EOF" >> "$GITHUB_OUTPUT"
|
||||
shell: bash
|
||||
- name: "Merge Input"
|
||||
id: merge
|
||||
uses: act/common/yq/yq-merge@master
|
||||
with:
|
||||
lhs: ${{ github.action_path }}/defaults.yaml
|
||||
rhs: ${{ inputs.input }}
|
||||
- name: "Generate Nuspec Yaml from Template"
|
||||
id: template
|
||||
uses: act/common/tpl/tpl-env@master
|
||||
with:
|
||||
template: ${{ steps.get-template.outputs.template }}
|
||||
decoder: yaml
|
||||
input: ${{ steps.merge.outputs.result }}
|
||||
- name: "Convert the Nuspec Yaml to XML"
|
||||
id: trim
|
||||
uses: act/common/yq/yq-trim@master
|
||||
with:
|
||||
input: ${{ steps.template.outputs.result }}
|
||||
recursive: true
|
||||
- name: "Convert the Nuspec Yaml to XML"
|
||||
id: xml
|
||||
uses: act/common/yq/yq-convert@master
|
||||
with:
|
||||
input: ${{ steps.trim.outputs.result }}
|
||||
from: yaml
|
||||
to: xml
|
||||
- name: "Get id from input."
|
||||
id: name
|
||||
uses: act/common/yq/yq-expression@master
|
||||
with:
|
||||
input: ${{ steps.merge.outputs.result }}
|
||||
expression: .id
|
||||
|
||||
16
tpl/tpl-to-nuspec/defaults.yaml
Normal file
16
tpl/tpl-to-nuspec/defaults.yaml
Normal file
@@ -0,0 +1,16 @@
|
||||
authors:
|
||||
- lewdorg Inc
|
||||
name: ${GITHUB_REPOSITORY}
|
||||
version: 0.0.0-dev
|
||||
projectUrl: https://lewdorg.com
|
||||
iconUrl: https://lewdorg.com/wp-content/uploads/2022/03/cropped-lewdorg-Profile-Circle-Light-1-1-270x270.png
|
||||
copyright: '© Copyright {{ now | date "2006" }} lewdorg Inc, Patents Issued.'
|
||||
repository:
|
||||
type: git
|
||||
url: git@github.lewdorg.com:${GITHUB_REPOSITORY}.git
|
||||
branch: ${GITHUB_REF_NAME}
|
||||
commit: ${GITHUB_SHA}
|
||||
tags:
|
||||
- lewdorg
|
||||
requireLicenseAcceptance: false
|
||||
language: en-US
|
||||
67
tpl/tpl-to-nuspec/example.yaml
Normal file
67
tpl/tpl-to-nuspec/example.yaml
Normal file
@@ -0,0 +1,67 @@
|
||||
# This file provides an example for the desired Yaml format for a .nuspec file.
|
||||
# Required Metadata
|
||||
id: Example.Package
|
||||
version: 1.0.0
|
||||
description: This is an example package.
|
||||
authors:
|
||||
- John Doe
|
||||
|
||||
# Optional Metadata
|
||||
title: Example Package
|
||||
license:
|
||||
content: MIT
|
||||
type: expression
|
||||
projectUrl: https://example.com
|
||||
iconUrl: icon.png
|
||||
icon:
|
||||
src: icon.png
|
||||
target: icon.png
|
||||
requireLicenseAcceptance: false
|
||||
developmentDependency: true
|
||||
summary: This is a summary of the example package.
|
||||
releaseNotes: This is the first release of the example package.
|
||||
language: en-US
|
||||
tags:
|
||||
- example
|
||||
- tag1
|
||||
- tag2
|
||||
repository:
|
||||
type: git
|
||||
url: https://github.com/example/example.package
|
||||
branch: master
|
||||
commit: 0a1b2c3d
|
||||
|
||||
path: /root
|
||||
# Content
|
||||
content:
|
||||
path: /content
|
||||
files:
|
||||
- include: any/any/config.json
|
||||
buildAction: Content
|
||||
copyToOutput: "true"
|
||||
flatten: "true"
|
||||
|
||||
# Source Files
|
||||
source:
|
||||
path: /source
|
||||
groups:
|
||||
- framework: .NETStandard2.0
|
||||
references:
|
||||
- name: System.Data
|
||||
dependencies:
|
||||
- id: Example.Dependency
|
||||
version: 1.0.0
|
||||
exclude:
|
||||
- Build
|
||||
- Analyzers
|
||||
files:
|
||||
- name: Example.Package.dll
|
||||
- name: Example.Package.pdb
|
||||
dlls:
|
||||
- name: Unity.Package
|
||||
- files:
|
||||
- name: icon.png
|
||||
target: content
|
||||
- framework: net40
|
||||
assemblies:
|
||||
- name: System.IO
|
||||
133
tpl/tpl-to-nuspec/nuspec.yaml.tpl
Normal file
133
tpl/tpl-to-nuspec/nuspec.yaml.tpl
Normal file
@@ -0,0 +1,133 @@
|
||||
+p_xml: version="1.0" encoding="utf-8"
|
||||
package:
|
||||
+@xmlns: http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd
|
||||
metadata:
|
||||
id: {{ .id | default "" }}
|
||||
version: {{ .version | default "" }}
|
||||
description: {{ .description | default "" }}
|
||||
authors: "{{ join ", " .authors | default "" }}"
|
||||
|
||||
title: {{ .title | default "" }}
|
||||
projectUrl: {{ .projectUrl | default "" }}
|
||||
licenseUrl: {{ .licenseUrl | default "" }}
|
||||
{{- with .license }}
|
||||
license:
|
||||
{{- if .content }}
|
||||
+content: {{ .content }}
|
||||
{{- end }}
|
||||
{{- if .type }}
|
||||
+@type: {{ .type }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
icon: {{ .icon | default "" }}
|
||||
iconUrl: {{ .iconUrl | default "" }}
|
||||
requireLicenseAcceptance: {{ .requireLicenseAcceptance | default "" }}
|
||||
developmentDependency: {{ .developmentDependency | default "" }}
|
||||
{{- if .copyright }}
|
||||
copyright: {{ tpl (toYaml .copyright) $ }}
|
||||
{{- end }}
|
||||
summary: {{ .summary | default "" }}
|
||||
releaseNotes: {{ .releaseNotes | default "" }}
|
||||
language: {{ .language | default "" }}
|
||||
tags: "{{ join ", " .tags | default "" }}"
|
||||
{{- with .repository }}
|
||||
repository:
|
||||
{{- if .type }}
|
||||
+@type: {{ .type }}
|
||||
{{- end }}
|
||||
{{- if .url }}
|
||||
+@url: {{ .url }}
|
||||
{{- end }}
|
||||
{{- if .branch }}
|
||||
+@branch: {{ .branch }}
|
||||
{{- end }}
|
||||
{{- if .commit }}
|
||||
+@commit: {{ .commit }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
||||
{{- with $.source }}
|
||||
{{- $path := print (default "." $.path) "/" (default "." .path) | clean }}
|
||||
dependencies:
|
||||
group:
|
||||
{{- range $item := .groups }}
|
||||
{{- if and $item.framework }}
|
||||
- +@targetFramework: {{ $item.framework }}
|
||||
dependency:
|
||||
{{- range $dep := $item.dependencies }}
|
||||
- +@id: {{ $dep.id }}
|
||||
+@version: {{ $dep.version }}
|
||||
+@exclude: "{{ join ", " $dep.exclude }}"
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
references:
|
||||
group:
|
||||
{{- range $item := .groups }}
|
||||
{{- if and $item.framework $item.references }}
|
||||
- +@targetFramework: {{ $item.framework }}
|
||||
{{- range $ref := $item.references }}
|
||||
- reference:
|
||||
+@file: {{ print $path "/" $ref.name | clean }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
frameworkAssemblies:
|
||||
frameworkAssembly:
|
||||
{{- range $item := .groups }}
|
||||
{{- range $ref := $item.assemblies }}
|
||||
- +@assemblyName: {{ $ref.name }}
|
||||
{{- if $item.framework }}
|
||||
+@targetFramework: {{ $item.framework }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- with $.content }}
|
||||
{{- $path := print (default "." $.path) "/" (default "." .path) | clean }}
|
||||
contentFiles:
|
||||
files:
|
||||
{{- range $file := .files }}
|
||||
- +@include: {{ print $path "/" $file.include | clean }}
|
||||
{{- if $file.exclude }}
|
||||
+@exclude: {{ print $path "/" $file.exclude | clean }}
|
||||
{{- end }}
|
||||
{{- if $file.buildAction }}
|
||||
+@buildAction: {{ $file.buildAction }}
|
||||
{{- end }}
|
||||
{{- if $file.copyToOutput }}
|
||||
+@copyToOutput: {{ $file.copyToOutput }}
|
||||
{{- end }}
|
||||
{{- if $file.flatten }}
|
||||
+@flatten: {{ $file.flatten }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- with $.source }}
|
||||
{{- $path := print (default "." $.path) "/" (default "." .path) | clean }}
|
||||
files:
|
||||
file:
|
||||
{{- range $item := .groups }}
|
||||
{{- range $file := $item.files }}
|
||||
- +@src: {{ print $path "/" $file.name | clean }}
|
||||
{{- if $item.framework }}
|
||||
+@target: {{ print "lib/" $item.framework "/" (default $file.target ".") | clean }}
|
||||
{{- else if $file.target }}
|
||||
+@target: {{ $file.target }}
|
||||
{{- end }}
|
||||
{{- if $file.exclude }}
|
||||
+@exclude: {{ print $path "/" $file.exclude | clean }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- if $item.framework }}
|
||||
{{- range $dll := $item.dlls }}
|
||||
- +@src: {{ print $path "/" $dll.name ".dll" | clean }}
|
||||
+@target: {{ print "lib/" $item.framework "/" (default $item.target ".") | clean }}
|
||||
{{- if ($dll.hasPdb | default true) }}
|
||||
- +@src: {{ print $path "/" $dll.name ".pdb" | clean }}
|
||||
+@target: {{ print "lib/" $item.framework "/" (default $item.target ".") | clean }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
12
tpl/tpl/Dockerfile
Normal file
12
tpl/tpl/Dockerfile
Normal file
@@ -0,0 +1,12 @@
|
||||
FROM debian:stable-slim
|
||||
|
||||
ENV VERSION=v0.2.0
|
||||
|
||||
RUN apt-get update
|
||||
RUN apt-get install wget -y
|
||||
RUN wget https://github.com/bluebrown/go-template-cli/releases/download/$VERSION/tpl-linux-amd64 -O /usr/bin/tpl
|
||||
RUN chmod +x /usr/bin/tpl
|
||||
|
||||
COPY entrypoint.sh /entrypoint.sh
|
||||
RUN chmod +x /entrypoint.sh
|
||||
ENTRYPOINT ["/entrypoint.sh"]
|
||||
21
tpl/tpl/action.yaml
Normal file
21
tpl/tpl/action.yaml
Normal file
@@ -0,0 +1,21 @@
|
||||
name: tpl
|
||||
description: "Format a Go template file given yaml file."
|
||||
inputs:
|
||||
command:
|
||||
description: "Arguments to pass into tpl."
|
||||
required: false
|
||||
catchErrors:
|
||||
description: "Whether or not errors should be handled."
|
||||
required: false
|
||||
outputs:
|
||||
console:
|
||||
description: "The console output of the tpl command."
|
||||
exitCode:
|
||||
description: "How the program exited."
|
||||
runs:
|
||||
using: 'docker'
|
||||
image: 'Dockerfile'
|
||||
env:
|
||||
CATCH_ERRORS: ${{ inputs.catchErrors }}
|
||||
args:
|
||||
- ${{ inputs.command }}
|
||||
20
tpl/tpl/entrypoint.sh
Normal file
20
tpl/tpl/entrypoint.sh
Normal file
@@ -0,0 +1,20 @@
|
||||
#!/bin/bash
|
||||
#See https://github.com/bluebrown/go-template-cli
|
||||
ARGS="$@"
|
||||
|
||||
OUTPUT=$(sh -c "tpl $ARGS")
|
||||
RESULT=$?
|
||||
|
||||
#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
|
||||
|
||||
echo "exitCode=$RESULT" >> "$GITHUB_OUTPUT"
|
||||
|
||||
if [[ "$CATCH_ERRORS" != "true" ]]; then
|
||||
exit $RESULT
|
||||
fi
|
||||
Reference in New Issue
Block a user