8989 - name : " Determine GAP version"
9090 id : version
9191 shell : bash
92+ env :
93+ OLDEST_VER : " 4.9"
9294 run : |
9395 VERSION=""
9496 IS_RELEASE=true
@@ -104,8 +106,34 @@ runs:
104106 GIT_RELS=$(cat $RUNNER_TEMP/gap_releases.json | jq -r '.[].tagName' | sort -V)
105107 GIT_NPRS=$(cat $RUNNER_TEMP/gap_releases.json | jq -r '.[] | select(.isPrerelease == false) | .tagName' | sort -V)
106108
107- # Add "v" in front if missing
108109 REL=${{ inputs.gap-version }}
110+ if [[ "$REL" == "minimal" ]]; then
111+ # Attempt to extract the minimal support GAP version from
112+ # PackageInfo.g via a regex (while in theory this can not always
113+ # work, in practice it does work quite well)
114+ REGEX="GAP[[:space:]]*:=[[:space:]]*\"([^\"]*)\""
115+
116+ if [[ ! -f "PackageInfo.g" ]]; then
117+ echo "::error::Could not find PackageInfo.g."
118+ exit 1
119+ elif [[ $(cat PackageInfo.g) =~ ${REGEX} ]]; then
120+ # Get from capture group in regex
121+ PKG_VER="${BASH_REMATCH[1]}"
122+ echo "Version: PackageInfo.g contains \"${PKG_VER}\""
123+
124+ # Remove leading stuff if present
125+ PKG_VER=${PKG_VER##*[>= ]}
126+
127+ # Ensure the extracted version is not below the oldest GAP version supported by this GAP acttion
128+ REL=$(printf '%s\n' "${PKG_VER}" "${OLDEST_VER}" | sort -V | tail -n1)
129+ echo "Version: turned \"${PKG_VER}\" into \"${REL}\""
130+ else
131+ echo "::error::Could not extract minimal supported version from PackageInfo.g."
132+ exit 1
133+ fi
134+ fi
135+
136+ # Ensure a "v" is in front
109137 REL=v${REL#v}
110138
111139 if echo "$GIT_RELS" | grep -qx "$REL" ; then
0 commit comments