This repository has been archived by the owner on Mar 13, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 48
/
Copy pathupdate.sh
executable file
·61 lines (52 loc) · 1.6 KB
/
update.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/bin/bash
#
# Usage: ./update.sh x.y.z
#
# This script runs to create a Dockerfile for a new Composer version.
# If you specify a partial version, like '1' or '1.0', it will determine the most recent sub version like 1.0.1.
set -eo pipefail
cd "$(dirname "$(readlink -f "$BASH_SOURCE")")"
versions=( "$@" )
if [ ${#versions[@]} -eq 0 ]; then
echo "Usage: bash update.sh [version ...]"
exit 1
fi
versions=( "${versions[@]%/}" )
function writeFiles {
local fullVersion=$1
local variant=$2
shortVersion=$(echo $fullVersion | sed -r -e 's/^([0-9]+.[0-9]+).*/\1/')
if [[ -z $variant ]]; then
targetDir="$shortVersion"
template=Dockerfile.template
else
targetDir="$shortVersion/$variant"
template=Dockerfile-$variant.template
fi
mkdir -p "$targetDir"
cp $template "$targetDir/Dockerfile"
if [[ -f docker-entrypoint.sh ]]; then
cp -r docker-entrypoint.sh "$targetDir"
fi
sed -r -i -e 's/^(ENV COMPOSER_VERSION) .*/\1 '"$fullVersion"'/' "$targetDir/Dockerfile"
}
tags="$(git ls-remote --tags https://github.com/composer/composer.git | cut -d/ -f3 | cut -d^ -f1 | cut -dv -f2 | sort -rV)"
for version in "${versions[@]}"; do
possibleVersions="$(echo "$tags" | grep "^$version" )"
if releaseVersions="$(echo "$possibleVersions" | grep -ivEm1 'milestone|-alpha|-beta|-rc')"; then
fullVersion="$releaseVersions"
else
fullVersion="$(echo "$possibleVersions" | head -n1)"
fi
if [[ -z $fullVersion ]]; then
echo "Cannot find version: $version"
exit 1
fi
(
set -x
writeFiles $fullVersion
writeFiles $fullVersion 'alpine'
writeFiles $fullVersion 'php5'
writeFiles $fullVersion 'php5-alpine'
)
done