git-secret/Makefile

159 lines
3.9 KiB
Makefile
Raw Normal View History

2016-03-12 21:35:05 +00:00
SHELL:=/usr/bin/env bash
2016-03-13 09:14:28 +00:00
PREFIX?="/usr"
DESTDIR?=
2016-03-12 21:35:05 +00:00
2016-03-12 19:21:04 +00:00
#
# Building:
#
git-secret: src/version.sh src/_utils/*.sh src/commands/*.sh src/main.sh
@cat $^ > "$@"
@chmod +x git-secret; sync
.PHONY: all
2016-02-21 13:26:17 +00:00
all: build
.PHONY: clean
2016-02-21 13:26:17 +00:00
clean:
@rm -f git-secret
2016-02-21 13:26:17 +00:00
.PHONY: build
2016-02-21 13:26:17 +00:00
build: git-secret
.PHONY: install
install:
2021-05-04 09:26:39 +00:00
${SHELL} ./utils/install.sh "${DESTDIR}${PREFIX}"
.PHONY: uninstall
uninstall:
2021-05-04 09:26:39 +00:00
${SHELL} ./utils/uninstall.sh "${DESTDIR}${PREFIX}"
2016-03-12 19:21:04 +00:00
#
2021-05-03 16:21:33 +00:00
# Testing and linting:
2016-03-12 19:21:04 +00:00
#
# The $(shell echo $${PWD}) construct is to access *nix paths under windows
# Under git for windows '$PATH' is set to windows paths, e.g. C:\Something
# Using a sub-shell we get the raw *nix paths, e.g. /c/Something
.PHONY: test
test: clean build
export SECRETS_PROJECT_ROOT="$(shell echo $${PWD})"; \
export PATH="$(shell echo $${PWD})/vendor/bats-core/bin:$(shell echo $${PWD}):$(shell echo $${PATH})"; \
2021-05-04 09:26:39 +00:00
${SHELL} ./utils/tests.sh
2016-02-21 13:26:17 +00:00
2021-05-03 10:56:51 +00:00
# We use this script in CI and you can do this too!
# What happens here?
# 1. We pass `SECRETS_DOCKER_ENV` variable into this job
2021-05-03 10:56:51 +00:00
# 2. Based on it, we select a proper `docker` image to run test on
# 3. We execute `make test` inside the `docker` container
2021-05-03 14:23:54 +00:00
.PHONY: docker-ci
docker-ci: clean
@[ -z "${SECRETS_DOCKER_ENV}" ] \
&& echo 'SECRETS_DOCKER_ENV is unset' && exit 1 || true
2021-05-03 13:18:15 +00:00
docker build \
-f ".ci/docker-ci/$${SECRETS_DOCKER_ENV}/Dockerfile" \
-t "gitsecret-$${SECRETS_DOCKER_ENV}:latest" .
2021-05-03 13:18:15 +00:00
docker run --rm \
--volume="$${PWD}:/code" \
-w /code \
"gitsecret-$${SECRETS_DOCKER_ENV}" \
2021-05-03 13:18:15 +00:00
make test
2021-05-03 10:56:51 +00:00
2021-05-03 16:21:33 +00:00
.PHONY: lint-shell
lint-shell:
docker pull koalaman/shellcheck:latest
docker run \
--volume="$${PWD}:/code" \
-w /code \
-e SHELLCHECK_OPTS='-s bash -S warning -a' \
--rm koalaman/shellcheck \
2021-05-04 09:26:39 +00:00
$$(find src .ci utils tests docs -type f \
2021-05-03 16:21:33 +00:00
-name '*.sh' -o -name '*.bash' -o -name '*.bats')
.PHONY: lint-docker
lint-docker:
docker pull hadolint/hadolint:latest-alpine
docker run \
--volume="$${PWD}:/code" \
-w /code \
--rm hadolint/hadolint \
hadolint \
--ignore=DL3008 --ignore=DL3018 --ignore=DL3041 --ignore=DL3028 \
.ci/*/**/Dockerfile
2021-05-03 16:21:33 +00:00
2021-05-03 12:43:04 +00:00
.PHONY: lint
2021-05-03 16:21:33 +00:00
lint: lint-shell lint-docker
2021-05-03 12:43:04 +00:00
2016-03-12 19:21:04 +00:00
#
2021-05-04 09:26:39 +00:00
# Manuals and docs:
2016-03-12 19:21:04 +00:00
#
.PHONY: clean-man
clean-man:
@find "man/" -type f ! -name "*.md" -delete
.PHONY: build-man
2021-05-04 09:26:39 +00:00
build-man: git-secret
2021-05-03 13:18:15 +00:00
docker pull msoap/ruby-ronn
2021-05-04 09:26:39 +00:00
export GITSECRET_VERSION="$$(./git-secret --version)" && docker run \
2021-05-03 13:18:15 +00:00
--volume="$${PWD}:/code" \
-w /code \
--rm msoap/ruby-ronn \
ronn --roff \
--organization=sobolevn \
--manual="git-secret $${GITSECRET_VERSION}" \
2021-05-04 09:26:39 +00:00
man/*/*.md
.PHONY: build-docs
build-docs: build-man
${SHELL} docs/create_posts.sh
.PHONY: docs
docs: build-docs
docker pull jekyll/jekyll
docker run \
--volume="$${PWD}/docs:/code" \
-w /code \
-p 4000:4000 \
--rm jekyll/jekyll \
jekyll serve --safe --strict_front_matter
2016-02-21 13:26:17 +00:00
2016-03-12 19:21:04 +00:00
#
# Packaging:
#
.PHONY: build-release
build-release: clean build
@[ -z "${SECRETS_RELEASE_TYPE}" ] \
&& echo 'SECRETS_RELEASE_TYPE is unset' && exit 1 || true
docker build \
-f ".ci/releaser/alpine/Dockerfile" \
-t "gitsecret-releaser:latest" .
docker run \
--volume="$${PWD}:/code" \
--rm gitsecret-releaser \
bash "./utils/$${SECRETS_RELEASE_TYPE}/build.sh"
.PHONY: release
release: build-release
docker run \
--volume="$${PWD}:/code" \
-e SECRETS_ARTIFACTORY_CREDENTIALS \
--rm gitsecret-releaser \
bash "./utils/$${SECRETS_RELEASE_TYPE}/deploy.sh"
.PHONY: release-ci
release-ci:
@[ -z "${SECRETS_RELEASE_ENV}" ] \
&& echo 'SECRETS_RELEASE_ENV is unset' && exit 1 || true
@[ -z "${SECRETS_RELEASE_TYPE}" ] \
&& echo 'SECRETS_RELEASE_TYPE is unset' && exit 1 || true
docker build \
-f ".ci/release-ci/$${SECRETS_RELEASE_ENV}/Dockerfile" \
-t "gitsecret-release-$${SECRETS_RELEASE_ENV}:latest" .
docker run --rm \
--volume="$${PWD}:/code" \
-w /code \
"gitsecret-release-$${SECRETS_RELEASE_ENV}" \
bash -c "set -e; bash "./utils/$${SECRETS_RELEASE_TYPE}/install.sh""