2
0
mirror of https://github.com/frappe/frappe_docker.git synced 2024-12-23 18:48:58 +00:00

add versioning support to travis.sh

This commit is contained in:
chabad360 2020-03-03 05:27:18 +00:00
parent 84d53bfcba
commit ca715e3e5c
2 changed files with 56 additions and 120 deletions

View File

@ -48,140 +48,60 @@ matrix:
- name: "Build Frappe python environment (v12)" - name: "Build Frappe python environment (v12)"
if: branch = master AND type != pull_request if: branch = master AND type != pull_request
script: script:
- git clone https://github.com/frappe/frappe --branch version-12 - ./travis.sh --worker --git-branch 12 --name frappe
- cd frappe - ./travis.sh --worker --tag v12 --name frappe --tag-only
- git fetch --tags - ./travis.sh --worker --tag version-12 --name frappe --tag-only
- export VERSION=$(git tag --list --sort=-version:refname "v12*" | sed -n 1p | sed -e 's#.*@\(\)#\1#')
- cd ..
- docker build -t frappe/frappe-worker:$VERSION -f build/frappe-worker/v12.Dockerfile .
- docker tag frappe/frappe-worker:$VERSION frappe/frappe-worker:version-12
- docker tag frappe/frappe-worker:$VERSION frappe/frappe-worker:v12
- docker push frappe/frappe-worker:$VERSION
- docker push frappe/frappe-worker:version-12
- docker push frappe/frappe-worker:v12
- name: "Build Frappe nginx + static assets (v12)" - name: "Build Frappe nginx + static assets (v12)"
if: branch = master AND type != pull_request if: branch = master AND type != pull_request
script: script:
- git clone https://github.com/frappe/frappe --branch version-12 - ./travis.sh --assets --git-branch 12 --name frappe
- cd frappe - ./travis.sh --assets --tag v12 --name frappe --tag-only
- git fetch --tags - ./travis.sh --assets --tag version-12 --name frappe --tag-only
- export VERSION=$(git tag --list --sort=-version:refname "v12*" | sed -n 1p | sed -e 's#.*@\(\)#\1#')
- cd ..
- docker build -t frappe/frappe-assets:$VERSION -f build/frappe-assets/v12.Dockerfile .
- docker tag frappe/frappe-assets:$VERSION frappe/frappe-assets:version-12
- docker tag frappe/frappe-assets:$VERSION frappe/frappe-assets:v12
- docker push frappe/frappe-assets:$VERSION
- docker push frappe/frappe-assets:version-12
- docker push frappe/frappe-assets:v12
- name: "Build ERPNext python environment (v12)" - name: "Build ERPNext python environment (v12)"
if: branch = master AND type != pull_request if: branch = master AND type != pull_request
script: script:
- git clone https://github.com/frappe/erpnext --branch version-12 - ./travis.sh --worker --git-branch 12 --name erpnext
- cd erpnext - ./travis.sh --worker --tag v12 --name erpnext --tag-only
- git fetch --tags - ./travis.sh --worker --tag version-12 --name erpnext --tag-only
- export VERSION=$(git tag --list --sort=-version:refname "v12*" | sed -n 1p | sed -e 's#.*@\(\)#\1#')
- cd ..
- docker build -t frappe/erpnext-worker:$VERSION -f build/erpnext-worker/v12.Dockerfile .
- docker tag frappe/erpnext-worker:$VERSION frappe/erpnext-worker:version-12
- docker tag frappe/erpnext-worker:$VERSION frappe/erpnext-worker:v12
- docker push frappe/erpnext-worker:$VERSION
- docker push frappe/erpnext-worker:version-12
- docker push frappe/erpnext-worker:v12
- name: "Build ERPNext nginx + static assets (v12)" - name: "Build ERPNext nginx + static assets (v12)"
if: branch = master AND type != pull_request if: branch = master AND type != pull_request
script: script:
- git clone https://github.com/frappe/erpnext --branch version-12 - ./travis.sh --assets --git-branch 12 --name erpnext
- cd erpnext - ./travis.sh --assets --tag v12 --name erpnext --tag-only
- git fetch --tags - ./travis.sh --assets --tag version-12 --name erpnext --tag-only
- export VERSION=$(git tag --list --sort=-version:refname "v12*" | sed -n 1p | sed -e 's#.*@\(\)#\1#')
- cd ..
- docker build -t frappe/erpnext-assets:$VERSION -f build/erpnext-assets/v12.Dockerfile .
- docker tag frappe/erpnext-assets:$VERSION frappe/erpnext-assets:version-12
- docker tag frappe/erpnext-assets:$VERSION frappe/erpnext-assets:v12
- docker push frappe/erpnext-assets:$VERSION
- docker push frappe/erpnext-assets:version-12
- docker push frappe/erpnext-assets:v12
- name: "Build Frappe socketio service (v12)" - name: "Build Frappe socketio service (v12)"
if: branch = master AND type != pull_request if: branch = master AND type != pull_request
script: script:
- git clone https://github.com/frappe/frappe --branch version-12 - ./travis.sh --socketio --git-branch 12 --name frappe
- cd frappe - ./travis.sh --socketio --tag v12 --name frappe --tag-only
- git fetch --tags - ./travis.sh --socketio --tag version-12 --name frappe --tag-only
- export VERSION=$(git tag --list --sort=-version:refname "v12*" | sed -n 1p | sed -e 's#.*@\(\)#\1#')
- cd ..
- docker build -t frappe/frappe-socketio:$VERSION -f build/frappe-socketio/v12.Dockerfile .
- docker tag frappe/frappe-socketio:$VERSION frappe/frappe-socketio:version-12
- docker tag frappe/frappe-socketio:$VERSION frappe/frappe-socketio:v12
- docker push frappe/frappe-socketio:$VERSION
- docker push frappe/frappe-socketio:version-12
- docker push frappe/frappe-socketio:v12
- name: "Build Frappe python environment (v11)" - name: "Build Frappe python environment (v11)"
if: branch = master AND type != pull_request if: branch = master AND type != pull_request
script: script:
- git clone https://github.com/frappe/frappe --branch version-11 - ./travis.sh --worker --git-branch 11 --name frappe
- cd frappe - ./travis.sh --worker --tag v11 --name frappe --tag-only
- git fetch --tags - ./travis.sh --worker --tag version-11 --name frappe --tag-only
- export VERSION=$(git tag --list --sort=-version:refname "v11*" | sed -n 1p | sed -e 's#.*@\(\)#\1#')
- cd ..
- docker build -t frappe/frappe-worker:$VERSION -f build/frappe-worker/v11.Dockerfile .
- docker tag frappe/frappe-worker:$VERSION frappe/frappe-worker:version-11
- docker tag frappe/frappe-worker:$VERSION frappe/frappe-worker:v11
- docker push frappe/frappe-worker:$VERSION
- docker push frappe/frappe-worker:version-11
- docker push frappe/frappe-worker:v11
- name: "Build Frappe nginx + static assets (v11)" - name: "Build Frappe nginx + static assets (v11)"
if: branch = master AND type != pull_request if: branch = master AND type != pull_request
script: script:
- git clone https://github.com/frappe/frappe --branch version-11 - ./travis.sh --assets --git-branch 11 --name frappe
- cd frappe - ./travis.sh --assets --tag v11 --name frappe --tag-only
- git fetch --tags - ./travis.sh --assets --tag version-11 --name frappe --tag-only
- export VERSION=$(git tag --list --sort=-version:refname "v11*" | sed -n 1p | sed -e 's#.*@\(\)#\1#')
- cd ..
- docker build -t frappe/frappe-assets:$VERSION -f build/frappe-assets/v11.Dockerfile .
- docker tag frappe/frappe-assets:$VERSION frappe/frappe-assets:version-11
- docker tag frappe/frappe-assets:$VERSION frappe/frappe-assets:v11
- docker push frappe/frappe-assets:$VERSION
- docker push frappe/frappe-assets:version-11
- docker push frappe/frappe-assets:v11
- name: "Build ERPNext python environment (v11)" - name: "Build ERPNext python environment (v11)"
if: branch = master AND type != pull_request if: branch = master AND type != pull_request
script: script:
- git clone https://github.com/frappe/erpnext --branch version-11 - ./travis.sh --worker --git-branch 11 --name erpnext
- cd erpnext - ./travis.sh --worker --tag v11 --name erpnext --tag-only
- git fetch --tags - ./travis.sh --worker --tag version-11 --name erpnext --tag-only
- export VERSION=$(git tag --list --sort=-version:refname "v11*" | sed -n 1p | sed -e 's#.*@\(\)#\1#')
- cd ..
- docker build -t frappe/erpnext-worker:$VERSION -f build/erpnext-worker/v11.Dockerfile .
- docker tag frappe/erpnext-worker:$VERSION frappe/erpnext-worker:version-11
- docker tag frappe/erpnext-worker:$VERSION frappe/erpnext-worker:v11
- docker push frappe/erpnext-worker:$VERSION
- docker push frappe/erpnext-worker:version-11
- docker push frappe/erpnext-worker:v11
- name: "Build ERPNext nginx + static assets (v11)" - name: "Build ERPNext nginx + static assets (v11)"
if: branch = master AND type != pull_request if: branch = master AND type != pull_request
script: script:
- git clone https://github.com/frappe/erpnext --branch version-11 - ./travis.sh --assets --git-branch 11 --name erpnext
- cd erpnext - ./travis.sh --assets --tag v11 --name erpnext --tag-only
- git fetch --tags - ./travis.sh --assets --tag version-11 --name erpnext --tag-only
- export VERSION=$(git tag --list --sort=-version:refname "v11*" | sed -n 1p | sed -e 's#.*@\(\)#\1#')
- cd ..
- docker build -t frappe/erpnext-assets:$VERSION -f build/erpnext-assets/v11.Dockerfile .
- docker tag frappe/erpnext-assets:$VERSION frappe/erpnext-assets:version-11
- docker tag frappe/erpnext-assets:$VERSION frappe/erpnext-assets:v11
- docker push frappe/erpnext-assets:$VERSION
- docker push frappe/erpnext-assets:version-11
- docker push frappe/erpnext-assets:v11
- name: "Build Frappe socketio service (v11)" - name: "Build Frappe socketio service (v11)"
if: branch = master AND type != pull_request if: branch = master AND type != pull_request
script: script:
- git clone https://github.com/frappe/frappe --branch version-11 - ./travis.sh --socketio --git-branch 11 --name erpnext
- cd frappe - ./travis.sh --socketio --tag v11 --name erpnext --tag-only
- git fetch --tags - ./travis.sh --socketio --tag version-11 --name erpnext --tag-only
- export VERSION=$(git tag --list --sort=-version:refname "v11*" | sed -n 1p | sed -e 's#.*@\(\)#\1#')
- cd ..
- docker build -t frappe/frappe-socketio:$VERSION -f build/frappe-socketio/v11.Dockerfile .
- docker tag frappe/frappe-socketio:$VERSION frappe/frappe-socketio:version-11
- docker tag frappe/frappe-socketio:$VERSION frappe/frappe-socketio:v11
- docker push frappe/frappe-socketio:$VERSION
- docker push frappe/frappe-socketio:version-11
- docker push frappe/frappe-socketio:v11

View File

@ -4,7 +4,6 @@
# This script takes care of the common steps # This script takes care of the common steps
# found in the Travis CI builds. # found in the Travis CI builds.
POSITIONAL=()
while [[ $# -gt 0 ]]; do while [[ $# -gt 0 ]]; do
key="$1" key="$1"
@ -35,13 +34,24 @@ while [[ $# -gt 0 ]]; do
TAGONLY=1 TAGONLY=1
shift shift
;; ;;
*) # unknown option -g|--git-branch)
POSITIONAL+=("$1") # save it in an array for later BRANCH="$2"
shift # past argument shift
shift
;; ;;
esac esac
done done
function gitVersion() {
echo "Pulling ${1} v${2}"
git clone https://github.com/frappe/${1} --branch version-${2}
cd ${1}
git fetch --tags
TAG=$(git tag --list --sort=-version:refname "v${2}*" | sed -n 1p | sed -e 's#.*@\(\)#\1#')
cd ..
DOCKERFILE="v${2}.Dockerfile"
}
function tagAndPush() { function tagAndPush() {
echo "Tagging ${1} as \"${2}\" and pushing" echo "Tagging ${1} as \"${2}\" and pushing"
docker tag ${1} frappe/${1}:${2} docker tag ${1} frappe/${1}:${2}
@ -49,27 +59,33 @@ function tagAndPush() {
} }
function build () { function build () {
echo "Building ${1} ${3} image" echo "Building ${1} ${3} image using ${4}"
docker build -t ${1}-${3} -f build/${1}-worker/Dockerfile . docker build -t ${1}-${3} -f build/${1}-${3}/${4:-Dockerfile} .
tagAndPush "${1}-${3}" ${2} tagAndPush "${1}-${3}" ${2}
} }
if [[ $BRANCH ]]; then
gitVersion $NAME $BRANCH
fi
DOCKERFILE=${DOCKERFILE:-Dockerfile}
if [[ $WORKER ]]; then if [[ $WORKER ]]; then
if [[ $TAGONLY ]]; then if [[ $TAGONLY ]]; then
tagAndPush "${NAME}-worker" ${TAG} tagAndPush "${NAME}-worker" ${TAG}
else else
build $NAME $TAG worker build $NAME $TAG worker ${DOCKERFILE}
fi fi
elif [[ $ASSETS ]]; then elif [[ $ASSETS ]]; then
if [[ $TAGONLY ]]; then if [[ $TAGONLY ]]; then
tagAndPush "${NAME}-assets" ${TAG} tagAndPush "${NAME}-assets" ${TAG}
else else
build $NAME $TAG assets build $NAME $TAG assets ${DOCKERFILE}
fi fi
elif [[ $SOCKETIO ]]; then elif [[ $SOCKETIO ]]; then
if [[ $TAGONLY ]]; then if [[ $TAGONLY ]]; then
tagAndPush "${NAME}-socketio" ${TAG} tagAndPush "${NAME}-socketio" ${TAG}
else else
build $NAME $TAG socketio build $NAME $TAG socketio ${DOCKERFILE}
fi fi
fi fi