Skip to content

Commit 20dfbf4

Browse files
author
Greg Bowler
authored
Merge pull request #88 from Un1matr1x/issues/87
[Issues/87] the composer version cannot be defined more precisely than the "major" version
2 parents 85b803d + 3128867 commit 20dfbf4

File tree

2 files changed

+34
-5
lines changed

2 files changed

+34
-5
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ This action runs on a custom base image, available at https://github.com/php-act
9595
Use the following inputs to run a specific PHP/Composer version combination:
9696

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

100100
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.
101101

composer-action.bash

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,41 @@ github_action_path=$(dirname "$0")
44
docker_tag=$(cat ./docker_tag)
55
echo "Docker tag: $docker_tag" >> output.log 2>&1
66

7-
phar_url="https://getcomposer.org/download/latest-"
8-
if [ "$ACTION_VERSION" == "latest" ]
7+
phar_url="https://getcomposer.org/"
8+
# check if $ACTION_VERSION is not set or empty or set to latest
9+
if [ -z "$ACTION_VERSION" ] || [ "$ACTION_VERSION" == "latest" ];
910
then
10-
phar_url="${phar_url}stable/composer.phar"
11+
# if a version is not set, use latest composer version
12+
phar_url="${phar_url}download/latest-stable/composer.phar"
1113
else
12-
phar_url="${phar_url}${ACTION_VERSION}/composer.phar"
14+
# if a version is set, choose the correct download
15+
case "$ACTION_VERSION" in
16+
# get the latest preview
17+
Preview | preview)
18+
phar_url="${phar_url}download/latest-preview/composer.phar"
19+
;;
20+
# get the latest snapshot
21+
Snapshot | snapshot)
22+
phar_url="${phar_url}composer.phar"
23+
;;
24+
# get the latest version of the v1 tree
25+
1 | 1.x)
26+
phar_url="${phar_url}download/latest-1.x/composer.phar"
27+
;;
28+
# get the latest version of the v2 tree
29+
2 | 2.x)
30+
phar_url="${phar_url}download/latest-2.x/composer.phar"
31+
;;
32+
# get the latest version of the v2.2 tree
33+
2.2 | 2.2.x)
34+
phar_url="${phar_url}download/latest-2.2.x/composer.phar"
35+
;;
36+
# if the version is not one of the above, assume that it is a exact
37+
# naming, possibly with additions (RC, beta1, ...)
38+
*)
39+
phar_url="${phar_url}download/${ACTION_VERSION}/composer.phar"
40+
;;
41+
esac
1342
fi
1443
curl --silent -H "User-agent: cURL (https://github.com/php-actions)" -L "$phar_url" > "${github_action_path}/composer.phar"
1544
chmod +x "${github_action_path}/composer.phar"

0 commit comments

Comments
 (0)