Files
actions/go-version-detect/action.yml
Ismo Vuorinen 74968d942f chore: update action references for release v2025.10.26 (#312)
This commit updates all internal action references to point to the current
commit SHA in preparation for release v2025.10.26.
2025-10-27 00:00:02 +02:00

76 lines
2.4 KiB
YAML

# yaml-language-server: $schema=https://json.schemastore.org/github-action.json
# permissions:
# - contents: read # Required for reading version files
---
name: Go Version Detect
description: "Detects the Go version from the project's go.mod file or defaults to a specified version."
author: 'Ismo Vuorinen'
branding:
icon: code
color: blue
inputs:
default-version:
description: 'Default Go version to use if go.mod is not found.'
required: false
default: '1.25'
token:
description: 'GitHub token for authentication'
required: false
default: ''
outputs:
go-version:
description: 'Detected or default Go version.'
value: ${{ steps.parse-version.outputs.detected-version }}
runs:
using: composite
steps:
- name: Validate Inputs
id: validate
shell: sh
env:
DEFAULT_VERSION: ${{ inputs.default-version }}
run: |
set -eu
# Validate default-version format
if ! echo "$DEFAULT_VERSION" | grep -Eq '^[0-9]+\.[0-9]+(\.[0-9]+)?$'; then
echo "::error::Invalid default-version format: '$DEFAULT_VERSION'. Expected format: X.Y or X.Y.Z (e.g., 1.22, 1.21.5)"
exit 1
fi
# Check for reasonable version range (prevent malicious inputs)
major_version=$(echo "$DEFAULT_VERSION" | cut -d'.' -f1)
if [ "$major_version" -ne 1 ]; then
echo "::error::Invalid default-version: '$DEFAULT_VERSION'. Go major version should be 1"
exit 1
fi
# Check minor version range
minor_version=$(echo "$DEFAULT_VERSION" | cut -d'.' -f2)
if [ "$minor_version" -lt 16 ] || [ "$minor_version" -gt 30 ]; then
echo "::error::Invalid default-version: '$DEFAULT_VERSION'. Go minor version should be between 16 and 30"
exit 1
fi
echo "Input validation completed successfully"
- name: Checkout Repository
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
token: ${{ inputs.token || github.token }}
- name: Parse Go Version
id: parse-version
uses: ivuorinen/actions/version-file-parser@e2222afff180ee77f330ef4325f60d6e85477c01
with:
language: 'go'
tool-versions-key: 'golang'
dockerfile-image: 'golang'
version-file: '.go-version'
validation-regex: '^[0-9]+\.[0-9]+(\.[0-9]+)?$'
default-version: ${{ inputs.default-version }}