diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..f158e46 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +pmd-bin-*.zip diff --git a/Dockerfile b/Dockerfile index 4f1c4bf..b3658d2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,13 +1,16 @@ FROM openjdk:13-alpine LABEL author="ian@iamthefij.com" -ENV VERSION=6.12.0 +ARG VERSION=6.12.0 RUN apk add bash curl unzip -RUN curl -L -o pmd.zip https://github.com/pmd/pmd/releases/download/pmd_releases%2F${VERSION}/pmd-bin-${VERSION}.zip && \ - unzip pmd.zip && \ - rm pmd.zip +COPY ./pmd-bin-${VERSION}.zip.sha256 / + +RUN curl -L -o pmd-bin-${VERSION}.zip https://github.com/pmd/pmd/releases/download/pmd_releases%2F${VERSION}/pmd-bin-${VERSION}.zip && \ + sha256sum -c pmd-bin-${VERSION}.zip.sha256 && \ + unzip pmd-bin-${VERSION}.zip && \ + rm pmd-bin-${VERSION}.zip RUN mv /pmd-bin-${VERSION} /pmd WORKDIR /pmd diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..228b9e7 --- /dev/null +++ b/Makefile @@ -0,0 +1,38 @@ +VERSION ?= 6.12.0 +DOCKER_TAG ?= pmd-$(USER) +SHA256SUM := $(shell which sha256sum || which gsha256sum) + +.PHONY: build +build: + docker build --build-arg VERSION=$(VERSION) . -t $(DOCKER_TAG) + +.PHONY: run +run: build + docker run --rm $(DOCKER_TAG) --help + +# Downloads latest pmd zip +pmd-bin-$(VERSION).zip: + curl -L -o pmd-bin-$(VERSION).zip https://github.com/pmd/pmd/releases/download/pmd_releases%2F$(VERSION)/pmd-bin-$(VERSION).zip + +# Generates new sha256 for this version file +pmd-bin-$(VERSION).zip.sha256: pmd-bin-$(VERSION).zip + $(SHA256SUM) pmd-bin-$(VERSION).zip > pmd-bin-$(VERSION).zip.sha256 + +# Checks that the downloaded file matches the sha sum +.PHONY: check +check: + $(SHA256SUM) -c pmd-bin-$(VERSION).zip.sha256 + +# Updates PMD and generates a new sha +.PHONY: update +update: clean pmd-bin-$(VERSION).zip.sha256 check + +# Cleans all zips and shas +.PHONY: clean +clean: + rm -f pmd-bin-*.zip pmd-bin-*.zip.sha256 + +# Creates a git tag for the current pmd version +.PHONY: tag +tag: + git tag -v $(VERSION) diff --git a/pmd-bin-6.12.0.zip.sha256 b/pmd-bin-6.12.0.zip.sha256 new file mode 100644 index 0000000..040bab2 --- /dev/null +++ b/pmd-bin-6.12.0.zip.sha256 @@ -0,0 +1 @@ +e61b3855bd94c1a3875b788cfd252a2d4f1232d47a41479078640da9aa3f7ecb pmd-bin-6.12.0.zip