added the rest of the actions
This commit is contained in:
130
.gdunit4_action/versioning/action.yml
Normal file
130
.gdunit4_action/versioning/action.yml
Normal file
@@ -0,0 +1,130 @@
|
||||
name: 'Determine GdUnit4 Version'
|
||||
description: 'Determines the actual GdUnit4 version that will be used'
|
||||
|
||||
inputs:
|
||||
version:
|
||||
description: 'The version of GdUnit4 to use (e.g., "v4.2.0", "latest", "master", "installed")'
|
||||
required: true
|
||||
project_dir:
|
||||
description: 'The project directory'
|
||||
required: true
|
||||
default: './'
|
||||
|
||||
outputs:
|
||||
gdunit-version:
|
||||
description: 'The determined GdUnit4 version'
|
||||
value: ${{ steps.determine.outputs.version }}
|
||||
|
||||
runs:
|
||||
using: 'composite'
|
||||
steps:
|
||||
- name: 'Determine Version'
|
||||
id: determine
|
||||
shell: bash
|
||||
run: |
|
||||
echo ""
|
||||
echo -e "\e[34mRun Determine GdUnit4 Version\e[0m"
|
||||
|
||||
echo -e "\e[33mVersion Input: \e[0m ${{ inputs.version }}"
|
||||
echo -e "\e[33mProject Directory: \e[0m ${{ inputs.project_dir }}"
|
||||
echo ""
|
||||
|
||||
cd "${{ inputs.project_dir }}"
|
||||
|
||||
# Function to extract version from plugin.cfg
|
||||
extract_version_from_plugin() {
|
||||
local plugin_file=$1
|
||||
if [[ -f "${plugin_file}" ]]; then
|
||||
version=$(grep -oP '^version="\K[^"]+' "${plugin_file}")
|
||||
if [[ -n "${version}" ]]; then
|
||||
# Add 'v' prefix if not present
|
||||
if [[ ! "${version}" =~ ^v ]]; then
|
||||
version="v${version}"
|
||||
fi
|
||||
echo "${version}"
|
||||
return 0
|
||||
fi
|
||||
fi
|
||||
return 1
|
||||
}
|
||||
|
||||
# Determine GdUnit4 version based on input
|
||||
if [[ "${{ inputs.version }}" == "installed" ]]; then
|
||||
echo -e "\e[33mChecking installed GdUnit4 plugin version... \e[0m"
|
||||
|
||||
if [[ -f ./addons/gdUnit4/plugin.cfg ]]; then
|
||||
gdunit_version=$(extract_version_from_plugin "./addons/gdUnit4/plugin.cfg")
|
||||
|
||||
if [[ -n "${gdunit_version}" ]]; then
|
||||
echo -e "\e[92m✓ Found installed GdUnit4 version: ${gdunit_version} \e[0m"
|
||||
echo "version=${gdunit_version}" >> $GITHUB_OUTPUT
|
||||
echo "GDUNIT_VERSION=${gdunit_version}" >> $GITHUB_ENV
|
||||
exit 0
|
||||
else
|
||||
echo -e "\e[31m✗ Error: Could not extract version from ./addons/gdUnit4/plugin.cfg \e[0m"
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
echo -e "\e[31m✗ Error: GdUnit4 plugin not found at ./addons/gdUnit4/plugin.cfg \e[0m"
|
||||
echo -e "\e[31m Make sure the plugin is installed before using version='installed' \e[0m"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
elif [[ "${{ inputs.version }}" == "latest" ]]; then
|
||||
echo -e "\e[33mResolving 'latest' GdUnit4 version from GitHub... \e[0m"
|
||||
|
||||
gdunit_version=$(git ls-remote --refs --tags https://github.com/godot-gdunit-labs/gdUnit4 v* | sort -t '/' -k 3 -V | tail -n 1 | cut -d '/' -f 3)
|
||||
|
||||
if [[ -n "${gdunit_version}" ]]; then
|
||||
echo -e "\e[92m✓ Resolved latest version: ${gdunit_version} \e[0m"
|
||||
echo "version=${gdunit_version}" >> $GITHUB_OUTPUT
|
||||
echo "GDUNIT_VERSION=${gdunit_version}" >> $GITHUB_ENV
|
||||
exit 0
|
||||
else
|
||||
echo -e "\e[31m✗ Error: Could not resolve latest version from GitHub \e[0m"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
else
|
||||
# Custom branch/tag specified
|
||||
echo -e "\e[33mFetching GdUnit4 version from branch/tag '${{ inputs.version }}'... \e[0m"
|
||||
|
||||
# Check if it's a tag
|
||||
if git ls-remote --tags https://github.com/godot-gdunit-labs/gdUnit4 | grep -q "refs/tags/${{ inputs.version }}$"; then
|
||||
echo -e "\e[92m✓ Tag '${{ inputs.version }}' found \e[0m"
|
||||
# Check if it's a branch
|
||||
elif git ls-remote --heads https://github.com/godot-gdunit-labs/gdUnit4 | grep -q "refs/heads/${{ inputs.version }}$"; then
|
||||
echo -e "\e[92m✓ Branch '${{ inputs.version }}' found \e[0m"
|
||||
else
|
||||
echo -e "\e[31m✗ Error: Branch/tag '${{ inputs.version }}' does not exist on GitHub \e[0m"
|
||||
echo -e "\e[31m Please verify that the branch/tag exists at: https://github.com/godot-gdunit-labs/gdUnit4 \e[0m"
|
||||
echo ""
|
||||
echo "Available recent tags:" >&2
|
||||
git ls-remote --tags https://github.com/godot-gdunit-labs/gdUnit4 | grep -oP 'refs/tags/\K.*' | grep -v '\^{}' | sort -V | tail -n 10 >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Clone the specific branch to get the plugin.cfg
|
||||
CLONE_DIR="./.gdunit4-version-${{ inputs.version }}"
|
||||
|
||||
if git clone --quiet --depth 1 --branch "${{ inputs.version }}" --single-branch https://github.com/godot-gdunit-labs/gdUnit4 "${CLONE_DIR}" 2>/dev/null; then
|
||||
|
||||
gdunit_version=$(extract_version_from_plugin "${CLONE_DIR}/addons/gdUnit4/plugin.cfg")
|
||||
|
||||
if [[ -n "${gdunit_version}" ]]; then
|
||||
echo -e "\e[92m✓ Found GdUnit4 version from branch '${{ inputs.version }}': ${gdunit_version} \e[0m"
|
||||
echo "version=${gdunit_version}" >> $GITHUB_OUTPUT
|
||||
echo "GDUNIT_VERSION=${gdunit_version}" >> $GITHUB_ENV
|
||||
exit 0
|
||||
else
|
||||
echo -e "\e[31m✗ Error: Could not extract version from plugin.cfg in branch '${{ inputs.version }}' \e[0m"
|
||||
rm -rf "${CLONE_DIR}"
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
echo -e "\e[31m✗ Error: Could not clone branch/tag '${{ inputs.version }}' from GitHub \e[0m"
|
||||
echo -e "\e[31m Please verify that the branch/tag exists at: https://github.com/godot-gdunit-labs/gdUnit4 \e[0m"
|
||||
rm -rf "${CLONE_DIR}" 2>/dev/null
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
114
.gdunit4_action/versioning/check/action.yml
Normal file
114
.gdunit4_action/versioning/check/action.yml
Normal file
@@ -0,0 +1,114 @@
|
||||
name: 'Verify GdUnit4 Version Compatibility'
|
||||
description: 'Verifies that the Godot and GdUnit4 version combination is compatible'
|
||||
|
||||
inputs:
|
||||
godot-version:
|
||||
description: 'The Godot version'
|
||||
required: true
|
||||
gdunit-version:
|
||||
description: 'The GdUnit4 version'
|
||||
required: true
|
||||
|
||||
outputs:
|
||||
exit_code:
|
||||
description: 'Exit code from compatibility check'
|
||||
value: ${{ steps.check-compatibility.outputs.exit_code }}
|
||||
|
||||
runs:
|
||||
using: 'composite'
|
||||
steps:
|
||||
- name: 'Check Compatibility'
|
||||
id: check-compatibility
|
||||
shell: bash
|
||||
run: |
|
||||
echo ""
|
||||
echo -e "\e[34mRun Version Compatibility Check\e[0m"
|
||||
|
||||
GODOT_VERSION="${{ inputs.godot-version }}"
|
||||
GDUNIT_VERSION="${{ inputs.gdunit-version }}"
|
||||
|
||||
echo -e "\e[33mConfigured Godot Version:\e[0m ${GODOT_VERSION}"
|
||||
echo -e "\e[33mConfigured GdUnit4 Version:\e[0m ${GDUNIT_VERSION}"
|
||||
echo ""
|
||||
|
||||
# Load compatibility matrix
|
||||
COMPATIBILITY_FILE="./.gdunit4_action/versioning/check/compatibility_matrix.json"
|
||||
|
||||
if [[ ! -f "${COMPATIBILITY_FILE}" ]]; then
|
||||
echo -e "\e[31m✗ Error: Compatibility matrix file not found\e[0m"
|
||||
echo "exit_code=1" >> "$GITHUB_OUTPUT"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Normalize versions - remove 'v' prefix
|
||||
GODOT_VER=${GODOT_VERSION#v}
|
||||
GDUNIT_VER=${GDUNIT_VERSION#v}
|
||||
|
||||
# Function to compare version numbers (returns 0 if $1 >= $2)
|
||||
version_ge() {
|
||||
printf '%s\n%s\n' "$2" "$1" | sort -V -C
|
||||
return $?
|
||||
}
|
||||
|
||||
# Function to compare version numbers (returns 0 if $1 <= $2)
|
||||
version_le() {
|
||||
printf '%s\n%s\n' "$1" "$2" | sort -V -C
|
||||
return $?
|
||||
}
|
||||
|
||||
# Find matching GdUnit4 version in matrix
|
||||
ALL_VERSIONS=$(grep -oP '^\s*"\K[0-9]+\.[0-9]+\.[0-9]+(?=":)' "${COMPATIBILITY_FILE}" | sort -V -r)
|
||||
|
||||
# Find the closest version that is <= GDUNIT_VER
|
||||
for ver in $ALL_VERSIONS; do
|
||||
if version_le "$ver" "$GDUNIT_VER"; then
|
||||
echo -e "\e[92m✓ Using compatibility rules for GdUnit4 v${ver}\e[0m"
|
||||
GODOT_MIN=$(grep -A 1 "\"${ver}\":" "${COMPATIBILITY_FILE}" | grep "godot_min" | cut -d'"' -f4)
|
||||
GODOT_MAX=$(grep -A 2 "\"${ver}\":" "${COMPATIBILITY_FILE}" | grep "godot_max" | cut -d'"' -f4)
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
# If still no match found, use default
|
||||
if [[ -z "$GODOT_MIN" ]]; then
|
||||
echo -e "\e[33m⚠️ No specific version found, using default compatibility rules\e[0m"
|
||||
GODOT_MIN=$(grep -A 1 "\"default\":" "${COMPATIBILITY_FILE}" | grep "godot_min" | cut -d'"' -f4)
|
||||
fi
|
||||
|
||||
# Check if Godot version meets the minimum requirement
|
||||
if ! version_ge "$GODOT_VER" "$GODOT_MIN"; then
|
||||
echo -e "\e[31m✗ Incompatible version combination detected!\e[0m"
|
||||
echo -e "\e[31m GdUnit4 v${GDUNIT_VER} requires at least Godot v${GODOT_MIN}, but you are using Godot v${GODOT_VER}\e[0m"
|
||||
echo ""
|
||||
REFERENCE=$(grep -oP '"reference":\s*"\K[^"]+' "${COMPATIBILITY_FILE}")
|
||||
echo -e "\e[33mPlease check the compatibility matrix at:\e[0m"
|
||||
echo -e "\e[34m${REFERENCE}\e[0m"
|
||||
echo -e "\e[34m========================================\e[0m"
|
||||
echo "exit_code=78" >> "$GITHUB_OUTPUT"
|
||||
exit 78
|
||||
fi
|
||||
|
||||
# Check if Godot version exceeds maximum (if max is defined)
|
||||
if [[ -n "$GODOT_MAX" ]] && ! version_le "$GODOT_VER" "$GODOT_MAX"; then
|
||||
echo -e "\e[31m✗ Incompatible version combination detected!\e[0m"
|
||||
echo -e "\e[31m GdUnit4 v${GDUNIT_VER} supports Godot v${GODOT_MIN} to v${GODOT_MAX}, but you are using Godot v${GODOT_VER}\e[0m"
|
||||
echo ""
|
||||
REFERENCE=$(grep -oP '"reference":\s*"\K[^"]+' "${COMPATIBILITY_FILE}")
|
||||
echo -e "\e[33mPlease check the compatibility matrix at:\e[0m"
|
||||
echo -e "\e[34m${REFERENCE}\e[0m"
|
||||
echo -e "\e[34m========================================\e[0m"
|
||||
echo "exit_code=78" >> "$GITHUB_OUTPUT"
|
||||
exit 78
|
||||
fi
|
||||
|
||||
# All checks passed
|
||||
echo -e "\e[92m✓ Configured GdUnit4 version is compatible!\e[0m"
|
||||
if [[ -n "$GODOT_MAX" ]]; then
|
||||
echo -e "\e[92m Godot v${GODOT_MIN} <= v${GODOT_VER} <= v${GODOT_MAX} ✓\e[0m"
|
||||
else
|
||||
echo -e "\e[92m Godot v${GODOT_VER} >= v${GODOT_MIN} ✓\e[0m"
|
||||
fi
|
||||
|
||||
echo -e "\e[34m========================================\e[0m"
|
||||
echo "exit_code=0" >> "$GITHUB_OUTPUT"
|
||||
exit 0
|
||||
33
.gdunit4_action/versioning/check/compatibility_matrix.json
Normal file
33
.gdunit4_action/versioning/check/compatibility_matrix.json
Normal file
@@ -0,0 +1,33 @@
|
||||
{
|
||||
"reference": "https://github.com/godot-gdunit-labs/gdUnit4#compatibility-overview",
|
||||
"default": {
|
||||
"godot_min": "4.5",
|
||||
"godot_max": "5.0"
|
||||
},
|
||||
"versions": {
|
||||
"6.0.0": {
|
||||
"godot_min": "4.5",
|
||||
"godot_max": "5.0"
|
||||
},
|
||||
"5.0.0": {
|
||||
"godot_min": "4.3",
|
||||
"godot_max": "4.4.999"
|
||||
},
|
||||
"4.4.0": {
|
||||
"godot_min": "4.2",
|
||||
"godot_max": "4.4.999"
|
||||
},
|
||||
"4.3.0": {
|
||||
"godot_min": "4.2",
|
||||
"godot_max": "4.3.999"
|
||||
},
|
||||
"4.2.1": {
|
||||
"godot_min": "4.1",
|
||||
"godot_max": "4.2.999"
|
||||
},
|
||||
"4.2.0": {
|
||||
"godot_min": "4.0",
|
||||
"godot_max": "4.1.999"
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user