From e0e81c3a2c39742c6f8d88d92c43ff0ca36b53fa Mon Sep 17 00:00:00 2001 From: tcely Date: Fri, 16 May 2025 04:59:55 -0400 Subject: [PATCH] Create get-tag/action.yml --- .github/actions/get-tag/action.yml | 41 ++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 .github/actions/get-tag/action.yml diff --git a/.github/actions/get-tag/action.yml b/.github/actions/get-tag/action.yml new file mode 100644 index 00000000..59ab43f3 --- /dev/null +++ b/.github/actions/get-tag/action.yml @@ -0,0 +1,41 @@ +name: Get tag +description: Get tag name from GITHUB_REF environment variable +inputs: + strip_v: + required: false + default: false + description: Whether to strip "v" from the tag or not +outputs: + tag: + value: ${{ steps.set.outputs.tag }} + description: Git tag name + +runs: + using: 'composite' + steps: + - name: Set outputs + id: 'set' + env: + INPUT_STRIP_V '${{ inputs.strip_v }}' + shell: 'bash' + run: | + tag="${GITHUB_REF}" + printf -- 'Manipulating string: %s\n' "${tag}" + test -n "${tag}" || exit 1 + + case "${tag}" in + (refs/tags/*) tag="${tag#refs/tags/}" ;; + (*) printf -- 'Not a tag ref\n' ; exit 2 ;; + esac + + if [ 'true' = "${INPUT_STRIP_V,,}" ] + then + tag="${tag#[Vv]}" + fi + + set_sl_var() { local f='%s=%s\n' ; printf -- "${f}" "$@" ; } ; + + set_sl_var tag "${tag}" >> "${GITHUB_OUTPUT}" + + set_sl_var 'tag ' " ${tag}" +