Skip to content

[Issues/87] the composer version cannot be defined more precisely than the "major" version #88

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Nov 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ This action runs on a custom base image, available at https://github.com/php-act
Use the following inputs to run a specific PHP/Composer version combination:

+ `php_version` Available versions: `7.1`, `7.2`, `7.3`, `7.4`, `8.0`, `8.1` (default: `latest` aka: `8.1`)
+ `version` Available versions: `1.x`, `2.x`, `2.2.x` (default: `latest` aka: `2.x`)
+ `version` Available versions: `latest`, `preview`, `snapshot`, `1.x`, `2.x`, `2.2.x` or the exact version (default: `latest`)

Make sure to put the PHP version number in quotes, otherwise YAML will interpret e.g. `8.0` as `8` which means latest 8.x, not 8.0.

Expand Down
37 changes: 33 additions & 4 deletions composer-action.bash
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,41 @@ github_action_path=$(dirname "$0")
docker_tag=$(cat ./docker_tag)
echo "Docker tag: $docker_tag" >> output.log 2>&1

phar_url="https://getcomposer.org/download/latest-"
if [ "$ACTION_VERSION" == "latest" ]
phar_url="https://getcomposer.org/"
# check if $ACTION_VERSION is not set or empty or set to latest
if [ -z "$ACTION_VERSION" ] || [ "$ACTION_VERSION" == "latest" ];
then
phar_url="${phar_url}stable/composer.phar"
# if a version is not set, use latest composer version
phar_url="${phar_url}download/latest-stable/composer.phar"
else
phar_url="${phar_url}${ACTION_VERSION}/composer.phar"
# if a version is set, choose the correct download
case "$ACTION_VERSION" in
# get the latest preview
Preview | preview)
phar_url="${phar_url}download/latest-preview/composer.phar"
;;
# get the latest snapshot
Snapshot | snapshot)
phar_url="${phar_url}composer.phar"
;;
# get the latest version of the v1 tree
1 | 1.x)
phar_url="${phar_url}download/latest-1.x/composer.phar"
;;
# get the latest version of the v2 tree
2 | 2.x)
phar_url="${phar_url}download/latest-2.x/composer.phar"
;;
# get the latest version of the v2.2 tree
2.2 | 2.2.x)
phar_url="${phar_url}download/latest-2.2.x/composer.phar"
;;
# if the version is not one of the above, assume that it is a exact
# naming, possibly with additions (RC, beta1, ...)
*)
phar_url="${phar_url}download/${ACTION_VERSION}/composer.phar"
;;
esac
fi
curl --silent -H "User-agent: cURL (https://github.com/php-actions)" -L "$phar_url" > "${github_action_path}/composer.phar"
chmod +x "${github_action_path}/composer.phar"
Expand Down