Skip to content

Commit 6ee04b4

Browse files
committed
[Issues/87] fix the download link for special version
and add some more options
1 parent 07d9028 commit 6ee04b4

File tree

1 file changed

+33
-4
lines changed

1 file changed

+33
-4
lines changed

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-2.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)