Skip to content

Commit 76c1b7a

Browse files
authored
Add minimal as a possible input for gap-version (#83)
1 parent 667eb41 commit 76c1b7a

3 files changed

Lines changed: 45 additions & 3 deletions

File tree

‎.github/workflows/CI.yml‎

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ jobs:
3232
- os: macos-latest
3333
configflags: '--with-gmp=builtin'
3434
include:
35+
- os: ubuntu-latest
36+
gap-version: minimal
37+
configflags: ''
3538
- os: ubuntu-latest
3639
gap-version: latest
3740
configflags: ''
@@ -49,15 +52,23 @@ jobs:
4952
configflags: ''
5053

5154
steps:
55+
- name: "Clone the Example package"
56+
uses: actions/checkout@v7
57+
if: ${{ matrix.gap-version == 'minimal' }}
58+
with:
59+
repository: gap-packages/example
60+
5261
- name: "Checkout"
5362
uses: actions/checkout@v7
63+
with:
64+
path: this-action/
5465

5566
- name: "Setup Cygwin"
5667
if: ${{ matrix.os == 'windows-latest' }}
5768
uses: gap-actions/setup-cygwin@v2
5869

5970
- name: "Setup GAP"
60-
uses: ./
71+
uses: ./this-action/
6172
with:
6273
gap-version: ${{ matrix.gap-version }}
6374
configflags: ${{ matrix.configflags }}

‎README.md‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ Its behaviour can be customized via the inputs below.
2222
All of the following inputs are optional.
2323

2424
- `gap-version`:
25-
- The gap version or branch to build. You may specify "latest" for the latest release, or "devel" for the development version.
25+
- The gap version or branch to build. You may specify "latest" for the latest release, "devel" for the development version,
26+
or "minimal" for the minimal version supported by the GAP package in the current directory.
2627
See "Changes to inputs" under "What's new in v3" for more details.
2728
- default: `latest`
2829
- `repository`
@@ -40,6 +41,8 @@ you will have to change the inputs accordingly. We also recommend replacing bran
4041
- The `GAPBRANCH` input has been replaced by `gap-version`, which accepts the following input types:
4142
- `latest`: this will use the latest release of GAP. This will **not** point to the latest pre-release if it is more recent
4243
than the latest release.
44+
- `minimal`: this will use oldest version of GAP that is supported by both the GAP package in the current directory, and this
45+
action (which currently means GAP 4.9).
4346
- version numbers: e.g. `v4.14.0`, `v4.15.0-beta1`, etc. The leading `v` is optional, the oldest available release is `v4.10.0`.
4447
- incomplete version numbers: e.g. `v4`, `v4.10`, etc. These will be expanded to the most recent release starting with the incomplete
4548
version number, e.g. `v4.10` is equivalent to `v4.10.2`. This will **not** expand to pre-releases, and again the leading `v` is

‎action.yml‎

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,8 @@ runs:
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

Comments
 (0)