fix(build): Revert 3ec009e6 + Travis deployment condition + extract Travis script

Travis deploy steps have to be a script file (not a list of steps).

Revert 3ec009e6 because “npm install git+file” actually reads from the local master branch, which
- doesn’t work on Travis since Travis checks out a detached head
- doesn’t work as expected locally, since you might have local changes or might be working from a different branch

For the time being it’s easier to simplify the Docker script and release a known published version.
pull/121/head
Romain 6 years ago
parent 3ec009e6c8
commit 4c64251bf5

@ -22,7 +22,7 @@ jobs:
api_key: $NPM_TOKEN
on:
tags: true
condition: $TRAVIS_TAG =~ ^\d+\.\d+\.\d+$
condition: $TRAVIS_TAG =~ ^v[0-9]+\.[0-9]+\.[0-9]+
# If this is a tagged commit, publish a new Docker image
@ -30,13 +30,7 @@ jobs:
script: echo "Deploying to DockerHub"
deploy:
provider: script
script:
- DOCKER_IMAGE="thumbsupgallery/thumbsup"
- docker login -u "${DOCKER_USERNAME}" -p "${DOCKER_PASSWORD}"
- docker build -f Dockerfile.release -t "${DOCKER_IMAGE}:${TRAVIS_TAG}" .
- docker tag "${DOCKER_IMAGE}:${TRAVIS_TAG}" "${DOCKER_IMAGE}:latest"
- docker push "${DOCKER_IMAGE}:${TRAVIS_TAG}"
- docker push "${DOCKER_IMAGE}:latest"
script: scripts/travis-release-docker
on:
tags: true
condition: $TRAVIS_TAG =~ ^\d+\.\d+\.\d+$
condition: $TRAVIS_TAG =~ ^v[0-9]+\.[0-9]+\.[0-9]+

@ -6,8 +6,13 @@ FROM thumbsupgallery/build:alpine as build
# Install thumbsup locally
WORKDIR /thumbsup
COPY . /thumbsup_repo
RUN npm install --production "git+file:///thumbsup_repo" && rm -rf /thumbsup_repo
ARG PACKAGE_VERSION
RUN if [ -z "${PACKAGE_VERSION}" ]; then \
echo "Please specify --build-arg PACKAGE_VERSION=<2.4.1>"; \
exit 1; \
fi;
RUN echo '{"name": "installer", "version": "1.0.0"}' > package.json
RUN npm install thumbsup@${PACKAGE_VERSION}
# ------------------------------------------------
# Runtime image

@ -0,0 +1,20 @@
#!/bin/bash -e
if [ -z "${TRAVIS_TAG}" ]; then
echo "This script releases a Docker image corresponding to the npm package version"
echo "It should only be run on Travis CI for tagged commits"
exit 1
fi
# Build the image
DOCKER_IMAGE="thumbsupgallery/thumbsup"
PACKAGE_VERSION="${TRAVIS_TAG//v}"
docker build -f Dockerfile.release -t "${DOCKER_IMAGE}:${PACKAGE_VERSION}" --build-arg "PACKAGE_VERSION=${PACKAGE_VERSION}" .
# Pushes both <thumbsup:x.y.z> and <thumbsup:latest>
docker login -u "${DOCKER_USERNAME}" -p "${DOCKER_PASSWORD}"
docker tag "${DOCKER_IMAGE}:${PACKAGE_VERSION}" "${DOCKER_IMAGE}:latest"
docker push "${DOCKER_IMAGE}:${PACKAGE_VERSION}"
docker push "${DOCKER_IMAGE}:latest"
Loading…
Cancel
Save