@@ -4,12 +4,41 @@ github_action_path=$(dirname "$0")
44docker_tag=$( cat ./docker_tag)
55echo " 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" ];
910then
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"
1113else
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
1342fi
1443curl --silent -H " User-agent: cURL (https://github.com/php-actions)" -L " $phar_url " > " ${github_action_path} /composer.phar"
1544chmod +x " ${github_action_path} /composer.phar"
0 commit comments