File: Makefile

package info (click to toggle)
git-secret 0.5.0-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 2,724 kB
  • sloc: sh: 4,580; makefile: 162; xml: 31; python: 22
file content (177 lines) | stat: -rw-r--r-- 4,586 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
SHELL:=bash
PREFIX?="/usr"
DESTDIR?=

#
# Building:
#

.PHONY: all
all: build

.PHONY: clean
clean:
	@rm -f git-secret

.PHONY: build
build:
	@cat src/version.sh > git-secret
	@cat src/_utils/*.sh src/commands/*.sh >> git-secret
	@cat src/main.sh >> git-secret
	@chmod +x git-secret; sync

.PHONY: install
install:
	"${SHELL}" ./utils/install.sh "${DESTDIR}${PREFIX}"

.PHONY: uninstall
uninstall:
	"${SHELL}" ./utils/uninstall.sh "${DESTDIR}${PREFIX}"

#
# Testing and linting:
#

# 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})"; \
	"${SHELL}" ./utils/tests.sh

# 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
# 2. Based on it, we select a proper `docker` image to run test on
# 3. We execute `make test` inside the `docker` container
.PHONY: docker-ci
docker-ci: clean
	@[ -z "${SECRETS_DOCKER_ENV}" ] \
		&& echo 'SECRETS_DOCKER_ENV is unset' && exit 1 || true
	docker build \
		-f ".ci/docker-ci/$${SECRETS_DOCKER_ENV}/Dockerfile" \
		-t "gitsecret-$${SECRETS_DOCKER_ENV}:latest" .
	docker run --rm \
		--volume="$${PWD}:/code" \
		-w /code \
		"gitsecret-$${SECRETS_DOCKER_ENV}" \
		make test

.PHONY: lint-shell
lint-shell:
	docker pull koalaman/shellcheck:latest
	docker run \
		--volume="$${PWD}:/code" \
		-w /code \
		-e SHELLCHECK_OPTS='-s bash -S style -a' \
		--rm koalaman/shellcheck \
		$$(find src .ci utils tests docs -type f \
			-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

.PHONY: lint
lint: lint-shell lint-docker

#
# Manuals and docs:
#

.PHONY: clean-man
clean-man:
	@find "man/" -type f ! -name "*.md" -delete

.PHONY: build-man
build-man: build
	docker pull msoap/ruby-ronn
	export GITSECRET_VERSION="$$(./git-secret --version)" && docker run \
		--volume="$${PWD}:/code" \
		-w /code \
		--rm msoap/ruby-ronn \
		ronn --roff \
			--organization=sobolevn \
			--manual="git-secret $${GITSECRET_VERSION}" \
			man/*/*.md

.PHONY: build-docs
build-docs: build-man
	 "${SHELL}" docs/build.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

.PHONY: changelog
changelog:
	@[ -z "${GITHUB_REPOSITORY}" ] \
		&& echo 'GITHUB_REPOSITORY is unset' && exit 1 || true
	@[ -z "${GITHUB_TOKEN}" ] \
		&& echo 'GITHUB_TOKEN is unset' && exit 1 || true
	docker pull githubchangeloggenerator/github-changelog-generator
	docker run \
		--volume="$${PWD}:/code" \
		-w /code \
		--entrypoint='' \
		-e GITHUB_REPOSITORY \
		-e GITHUB_TOKEN \
		--rm githubchangeloggenerator/github-changelog-generator \
		sh ".ci/github_release_script.sh"

#
# Packaging:
#

.PHONY: build-release
build-release: clean build-man
	@[ -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
	@[ -z "${SECRETS_ARTIFACTORY_CREDENTIALS}" ] \
		&& echo 'SECRETS_ARTIFACTORY_CREDENTIALS is unset' && exit 1 || true
	docker run \
		--volume="$${PWD}:/code" \
		-e SECRETS_ARTIFACTORY_CREDENTIALS \
		-e SECRETS_DEPLOY_DRY_RUN \
		--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""