diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 8613b2c..65f1380 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -55,11 +55,11 @@ jobs: - name: "Check if packages were installed" shell: bash run: | - $GAP -A -q < fail; end;; bool := [ diff --git a/README.md b/README.md index ff38921..781eff6 100644 --- a/README.md +++ b/README.md @@ -20,11 +20,16 @@ notable changes. Packages will **not** be built, this has to be done by a subseq The following input is mandatory: - `packages`: - - Space-separated or newline-separated list of packages to install. Packages are either - given as `package`, as `package@version`, or by an URL pointing to a release archive. - Here, `package` can either be the name of a package in the GAP package distribution or - the name of a GitHub repository (of the form "org/repo"). The optional suffix `version` - is either `latest`, `devel`, or a version number. + - Space-separated or newline-separated list of packages to install. Packages are given by + one of three formats: + - `packagename`: the name of a package in the [GAP package distribution](https://github.com/gap-system/PackageDistro). + - `user/repo`: the name of a GitHub repository containing the package. + - `https://url.to/archive.tar.gz`: an URL leading to a `.tar.gz`, `.tar.bz` or `.zip` + archive. + + The first two formats can be followed by a suffix `@version`, where `version` is either + `latest`, `devel`, or a version number. If no version is given, this defaults to `latest`. + - default: `''` ### Examples diff --git a/action.yml b/action.yml index e0fd7c0..3c23999 100644 --- a/action.yml +++ b/action.yml @@ -44,6 +44,8 @@ runs: echo "::group::Installing ${pkg}" version="latest" + repo="" + distro_ver="" # Split off version, if present if [[ "${pkg}" == *@* ]]; then @@ -57,16 +59,25 @@ runs: if [[ "${pkg}" =~ ^https?://.*\.(tar\.gz|tar\.bz2|zip)$ ]]; then echo "Input is an archive" - download_and_extract "${pkg}" "${pkgdir}" else - # Set the $repo variable + use_repo=true if [[ "${pkg}" =~ .*/.* ]]; then echo "Input is a package repository" repo="${pkg}" else echo "Input is a package name" - get_repo_from_name "${name}" + get_pkg_info_from_name "${name}" + echo "Package distribution contains version ${distro_ver}" + # If the desired version is the one available in the package distribution, + # we use the info there instead of going to the package repository + if [[ "${version}" = "latest" ]] || [[ "${version}" = "${distro_ver}" ]]; then + echo "Using package distribution" + version="${distro_ver}" + use_repo=false + else + echo "Using repository ${repo}" + fi fi if [[ "${version}" = "devel" ]]; then @@ -74,15 +85,18 @@ runs: clear_dest "${pkgdir}" git clone -q --depth=1 --single-branch "https://github.com/${repo}.git" "${pkgdir}" else - # Set the $archive_url variable and update the $version variable - get_archive_url "${repo}" "${version}" + # Update the $archive_url and $version variables + if [[ ${use_repo} = true ]]; then + echo "Getting archive url from repository" + get_archive_url "${repo}" "${version}" + fi # Check if package version is already available if check_pkg_availability "${name}" "${version}"; then echo "Package ${name} ${version} is already available, skipping." continue fi - + download_and_extract "${archive_url}" "${pkgdir}" fi fi diff --git a/install-pkg-functions.sh b/install-pkg-functions.sh index db90cd7..6ebdd5a 100644 --- a/install-pkg-functions.sh +++ b/install-pkg-functions.sh @@ -121,7 +121,7 @@ get_package_distro() { } # Get repository name from package name using PackageDistro -get_repo_from_name() { +get_pkg_info_from_name() { local name="$1" # Create the required file at $PKG_DISTRO @@ -135,13 +135,20 @@ get_repo_from_name() { exit 1 fi - # Don't try to get URL from PackageDistro - latest version not be merged yet! local repo_url - repo_url=$(echo "${pkg}" | jq -r '.SourceRepository.URL') || { - echo "::error::Package ${name} not found in PackageDistro" - exit 1 - } + repo_url=$(echo "${pkg}" | jq -r '.SourceRepository.URL') repo=${repo_url#https://github.com/} + + local formats + formats=$(echo "${pkg}" | jq -r '.ArchiveFormats') + formats=$(echo "${formats}" | tr ' ' '\n') + + local archive_base + archive_base=$(echo "${pkg}" | jq -r '.ArchiveURL') + + combine_url "${archive_base}" "${formats}" + + distro_ver=$(echo "${pkg}" | jq -r '.Version') } # Use GAP to check if package-version combination is already installed