diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..e7cd918 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,6 @@ +sudo: required + +services: + - docker + +script: make diff --git a/Dockerfile b/Dockerfile index a22123a..31842ef 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,12 +2,15 @@ FROM alpine LABEL maintainer Bill Wang -RUN apk --update add git openssh && \ +RUN apk --update add git openssh bash && \ rm -rf /var/lib/apt/lists/* && \ rm /var/cache/apk/* +COPY docker-entrypoint.sh /bin/docker-entrypoint.sh +RUN chmod +x /bin/docker-entrypoint.sh + VOLUME /git WORKDIR /git -ENTRYPOINT ["git"] +ENTRYPOINT ["/bin/docker-entrypoint.sh"] CMD ["--help"] diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..53e2276 --- /dev/null +++ b/Makefile @@ -0,0 +1,27 @@ +RELEASE_TYPE ?= patch +SEMVER_IMAGE ?= alpine/semver + +CURRENT_VERSION := $(shell git tag -l -n [0-9]* | sort --version-sort -r | awk 'NR==1{print $$1}' ) + +ifndef CURRENT_VERSION + CURRENT_VERSION := 0.0.0 +endif + +NEXT_VERSION := $(shell docker run --rm $(SEMVER_IMAGE) semver -c -i $(RELEASE_TYPE) $(CURRENT_VERSION)) + +BRANCH = $(shell git rev-parse --abbrev-ref HEAD) + +.PHONY: all current-version next-version release +all: release + +current-version: + @echo $(CURRENT_VERSION) + +next-version: + @echo $(NEXT_VERSION) + +release: + if [ "$(BRANCH)" = "master" ];then \ + git tag $(NEXT_VERSION) ;\ + git push --tags ;\ + fi diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh new file mode 100755 index 0000000..a5a6767 --- /dev/null +++ b/docker-entrypoint.sh @@ -0,0 +1,15 @@ +#!/bin/sh + +# A beginning user should be able to docker run image bash (or sh) without +# needing to learn about --entrypoint +# https://github.com/docker-library/official-images#consistency + +set -e + +# allow to run "sh" or "bash" +if [ "$1" = 'sh' ] || [ "$1" = 'bash' ]; then + exec "$@" +else + # else default to run command with git + exec git "$@" +fi