From 418aef017e394f877e8d402429951540a976ed2f Mon Sep 17 00:00:00 2001 From: Andrew Brandt Date: Wed, 27 May 2026 15:16:18 -0400 Subject: [PATCH 1/4] feat: add gomplate version input field **Description**: Allow the user to specify a version of gomplate by using the `gomplate-version` field in inputs. **Related Issue(s)**: Implements #66 Signed-off-by: Andrew Brandt --- README.md | 7 ++++--- action.yml | 8 ++++++-- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 093c79c..b2fd06b 100644 --- a/README.md +++ b/README.md @@ -127,9 +127,10 @@ Common steps for initializing a job for GitHub actions. This composite action co **Gomplate** -| Input | Description | Required | Default | -|----------------|---------------------------|----------|---------| -| setup-gomplate | Whether to setup gomplate | No | false | +| Input | Description | Required | Default | +|------------------|---------------------------------------|----------|---------| +| setup-gomplate | Whether to setup gomplate | No | false | +| gomplate-version | Gomplate version to use (e.g. v5.0.0) | No | v5.0.0 | > [!NOTE] > `setup-gomplate` currently installs the Linux AMD64 gomplate release artifact. diff --git a/action.yml b/action.yml index e0016ba..45d1185 100644 --- a/action.yml +++ b/action.yml @@ -143,6 +143,10 @@ inputs: description: 'Whether to setup gomplate' required: false default: 'false' + gomplate-version: + description: 'Gomplate version to use (e.g. v5.0.0)' + required: false + default: 'v5.0.0' task-version: description: 'Task version to use' required: false @@ -440,7 +444,7 @@ runs: shell: bash run: | echo "::group::Setting up gomplate" - echo "Version: v5.0.0" + echo "Version: ${{ inputs.gomplate-version }}" echo "::endgroup::" - name: Install Gomplate @@ -448,7 +452,7 @@ runs: if: ${{ inputs.setup-gomplate == 'true' }} shell: bash run: | - GOMPLATE_VERSION="v5.0.0" + GOMPLATE_VERSION="${{ inputs.gomplate-version }}" GOMPLATE_RELEASE_URL="https://github.com/hairyhenderson/gomplate/releases/download/${GOMPLATE_VERSION}" curl -sSfL "${GOMPLATE_RELEASE_URL}/gomplate_linux-amd64" \ From 9b0a086d503a003e8a1046a5e5fdd87f4873adec Mon Sep 17 00:00:00 2001 From: Andrew Brandt Date: Wed, 27 May 2026 15:23:13 -0400 Subject: [PATCH 2/4] Fix how the input from user is handled Signed-off-by: Andrew Brandt --- action.yml | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/action.yml b/action.yml index 45d1185..3ff1904 100644 --- a/action.yml +++ b/action.yml @@ -442,17 +442,24 @@ runs: id: setup-gomplate-params if: ${{ inputs.setup-gomplate == 'true' }} shell: bash + env: + GOMPLATE_VERSION: ${{ inputs.gomplate-version }} run: | echo "::group::Setting up gomplate" - echo "Version: ${{ inputs.gomplate-version }}" + echo "Version: ${GOMPLATE_VERSION}" echo "::endgroup::" - name: Install Gomplate id: setup-gomplate if: ${{ inputs.setup-gomplate == 'true' }} shell: bash + env: + GOMPLATE_VERSION: ${{ inputs.gomplate-version }} run: | - GOMPLATE_VERSION="${{ inputs.gomplate-version }}" + if [[ ! "${GOMPLATE_VERSION}" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then + echo "Invalid gomplate-version: '${GOMPLATE_VERSION}' (expected format vMAJOR.MINOR.PATCH, e.g. v5.0.0)" + exit 1 + fi GOMPLATE_RELEASE_URL="https://github.com/hairyhenderson/gomplate/releases/download/${GOMPLATE_VERSION}" curl -sSfL "${GOMPLATE_RELEASE_URL}/gomplate_linux-amd64" \ From 81853c6bea080ffce98e7a77604a30f6797967d6 Mon Sep 17 00:00:00 2001 From: Andrew Brandt Date: Wed, 27 May 2026 15:30:01 -0400 Subject: [PATCH 3/4] Update test workflow to verify the version number for gomplate is input correctly Signed-off-by: Andrew Brandt --- .github/workflows/test.yml | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 25cb32e..5387c74 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -432,3 +432,33 @@ jobs: - name: Verify Gomplate Installation run: | gomplate --version + + test-setup-gomplate-custom-version: + name: Test Setup Gomplate (custom version) + runs-on: ubuntu-latest + steps: + - name: Harden Runner + id: harden-runner + uses: step-security/harden-runner@ab7a9404c0f3da075243ca237b5fac12c98deaa5 # v2.19.3 + with: + egress-policy: audit + + - name: Checkout Repository + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + + - name: Run Setup Gomplate Action (non-default version) + uses: ./ + with: + setup-gomplate: true + gomplate-version: v4.3.3 + + - name: Verify Gomplate Version Matches Input + env: + EXPECTED_VERSION: 4.3.3 + run: | + ACTUAL="$(gomplate --version)" + echo "gomplate reported: ${ACTUAL}" + if ! echo "${ACTUAL}" | grep -qE "(^|[^0-9.])${EXPECTED_VERSION}([^0-9.]|$)"; then + echo "Expected gomplate version ${EXPECTED_VERSION}, got: ${ACTUAL}" + exit 1 + fi From ac8e4ef097256319d7506f6154130789d23a2671 Mon Sep 17 00:00:00 2001 From: Andrew Brandt Date: Wed, 27 May 2026 15:41:38 -0400 Subject: [PATCH 4/4] Add checking for . in version number Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> Signed-off-by: Andrew Brandt --- .github/workflows/test.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 5387c74..034b93b 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -457,8 +457,9 @@ jobs: EXPECTED_VERSION: 4.3.3 run: | ACTUAL="$(gomplate --version)" + ESCAPED_EXPECTED_VERSION="$(printf '%s\n' "${EXPECTED_VERSION}" | sed 's/[][(){}.^$*+?|\\]/\\&/g')" echo "gomplate reported: ${ACTUAL}" - if ! echo "${ACTUAL}" | grep -qE "(^|[^0-9.])${EXPECTED_VERSION}([^0-9.]|$)"; then + if ! echo "${ACTUAL}" | grep -qE "(^|[^0-9.])${ESCAPED_EXPECTED_VERSION}([^0-9.]|$)"; then echo "Expected gomplate version ${EXPECTED_VERSION}, got: ${ACTUAL}" exit 1 fi