Add the string-case action

This commit is contained in:
tcely 2025-03-27 00:29:13 -04:00 committed by GitHub
parent 83932645af
commit 2a0c59380a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

53
.github/actions/string-case/action.yml vendored Normal file
View File

@ -0,0 +1,53 @@
name: Change String Case
description: Make a string lowercase, uppercase, or capitalized
inputs:
string:
description: The input string
required: true
outputs:
lowercase:
value: ${{ steps.set.outputs.lowercase }}
description: The input string, with any uppercase characters replaced with lowercase ones
uppercase:
value: ${{ steps.set.outputs.uppercase }}
description: The input string, with any lowercase characters replaced with uppercase ones
capitalized:
value: ${{ steps.set.outputs.capitalized }}
description: The input string, with any alphabetical characters lowercase, except for the first character, which is uppercased
runs:
using: 'composite'
steps:
- name: Retrieve releases
id: 'set'
env:
INPUT_STRING: '${{ inputs.string }}'
shell: 'bash'
run: |
set_sl_var() { local f='%s=%s\n' ; printf -- "${f}" "$@" ; } ;
mk_delim() { printf -- '"%s_EOF_%d_"' "$1" "${RANDOM}" ; } ;
open_ml_var() { local f=''\%'s<<'\%'s\n' ; printf -- "${f}" "$2" "$1" ; } ;
close_ml_var() { local f='%s\n' ; printf -- "${f}" "$1" ; } ;
{
var='lowercase' ;
delim="$(mk_delim "${var}")" ;
open_ml_var "${delim}" "${var}" ;
printf -- '%s\n' "${INPUT_STRING,,}" ;
close_ml_var "${delim}" "${var}" ;
var='capitalized' ;
delim="$(mk_delim "${var}")" ;
open_ml_var "${delim}" "${var}" ;
printf -- '%s\n' "${INPUT_STRING^}" ;
close_ml_var "${delim}" "${var}" ;
var='uppercase' ;
delim="$(mk_delim "${var}")" ;
open_ml_var "${delim}" "${var}" ;
printf -- '%s\n' "${INPUT_STRING^^}" ;
close_ml_var "${delim}" "${var}" ;
} >> "${GITHUB_OUTPUT}"