forked from cloudposse/packages
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
139 lines (114 loc) · 4.04 KB
/
Makefile
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
export DOCKER_ORG ?= cloudposse
export DOCKER_IMAGE ?= $(DOCKER_ORG)/packages
export DOCKER_TAG ?= latest
export DOCKER_IMAGE_NAME ?= $(DOCKER_IMAGE):$(DOCKER_TAG)
export DOCKER_BUILD_FLAGS =
export DEFAULT_HELP_TARGET := help/vendor
export README_DEPS ?= .github/auto-label.yml docs/badges.md docs/targets.md workflows
export DIST_CMD ?= cp -a
export DIST_PATH ?= /dist
export ALPINE_VERSION ?= alpine
SHELL := /bin/bash
-include $(shell curl -sSL -o .build-harness "https://git.io/build-harness"; echo .build-harness)
all: init deps build install run workflows
deps:
@exit 0
workflows:
$(SELF) --no-print-directory --quiet --silent -C .github/ workflows
## Create a distribution by coping $PACKAGES from $INSTALL_PATH to $DIST_PATH
dist: INSTALL_PATH=/usr/local/bin
dist:
mkdir -p $(DIST_PATH)
[ -z "$(PACKAGES)" ] || \
( cd $(INSTALL_PATH) && $(DIST_CMD) $(PACKAGES) $(DIST_PATH) )
build:
@make --no-print-directory docker:build
push:
docker push $(DOCKER_IMAGE)
run:
docker run -it ${DOCKER_IMAGE_NAME} sh
.github/auto-label.yml:: PACKAGES=$(sort $(dir $(wildcard vendor/*/Makefile)))
.github/auto-label.yml::
cp .github/auto-label-default.yml $@
for vendor in $(PACKAGES); do \
printf "$${vendor%/}:\n- any: [\"$${vendor}**\"]\n all: [\"!bin/**\", \"!tasks/**\"]\n"; \
done >> $@
.PHONY : docs/badges.md
## Update `docs/badges.md` from `make help`
docs/badges.md: docs/deps
@( \
echo "## Package Build Status"; \
echo "| Build Status | Version | Description |"; \
echo "| ------------ | ------- | ----------- |"; \
$(SELF) --no-print-directory --quiet --silent help/md | sed $$'s,\x1b\\[[0-9;]*[a-zA-Z],,g'; \
) > $@
## Build alpine packages for testing
docker/build/apk:
docker build -t cloudposse/apkbuild:$(ALPINE_VERSION) -f apk/Dockerfile-$(ALPINE_VERSION) .
docker run \
--name apkbuild \
--rm \
-e APK_PACKAGES_PATH=/packages/artifacts/$(ALPINE_VERSION) \
-v $$(pwd):/packages cloudposse/apkbuild:$(ALPINE_VERSION) \
sh -c "make -C /packages/vendor build"
docker/build/apk/all:
docker build -t cloudposse/apkbuild:$(ALPINE_VERSION) -f apk/Dockerfile-$(ALPINE_VERSION) .
docker run \
--name apkbuild \
--rm \
-e APK_PACKAGES_PATH=/packages/artifacts/$(ALPINE_VERSION) \
-v $$(pwd):/packages cloudposse/apkbuild:$(ALPINE_VERSION) \
sh -c "make -C /packages/vendor build"
## Build alpine packages for testing
docker/build/apk/shell:
rm -rf tmp/*
[ -n "$(ls tmp/)" ] && sudo rm -rf tmp/* || true
docker build -t cloudposse/apkbuild:$(ALPINE_VERSION) -f apk/Dockerfile-$(ALPINE_VERSION) .
docker run \
--name apkbuild \
--rm \
-it \
-e AWS_SECRET_ACCESS_KEY \
-e AWS_ACCESS_KEY_ID \
-e AWS_SESSION_TOKEN \
-e AWS_SECURITY_TOKEN \
-e TMP=/packages/tmp/apk \
-e APK_PACKAGES_PATH=/packages/artifacts/$(ALPINE_VERSION) \
--privileged \
-w /packages \
-v $$(pwd):/packages cloudposse/apkbuild:$(ALPINE_VERSION)
# MATRIX BUILD
docker/build/deb/shell docker/build/deb/test : BUILDER_VERSION=stable-slim
docker/build/rpm/shell docker/build/rpm/test : BUILDER_VERSION=centos8
## Build package as a test
docker/build/%/test:
docker build -t cloudposse/packages-$*build:$(BUILDER_VERSION) -f $*/Dockerfile.$(BUILDER_VERSION) .
docker run \
--name $*build \
--rm \
-e TMP=/packages/tmp/$* \
-e PACKAGES_PATH=/packages/artifacts/$*/$(BUILDER_VERSION) \
-v $$(pwd):/packages cloudposse/packages-$*build:$(BUILDER_VERSION) \
sh -c "make -C /packages/vendor/github-commenter $*"
## Build package builder shell
docker/build/%/shell:
rm -rf tmp/*
[ -n "$(ls tmp/)" ] && sudo rm -rf tmp/* || true
mkdir -p tmp/$*
docker build -t cloudposse/packages-$*build:$(BUILDER_VERSION) -f $*/Dockerfile.$(BUILDER_VERSION) .
docker run \
-it \
--name $*build \
--rm \
-e TMP=/packages/tmp/$* \
-e PACKAGES_PATH=/packages/artifacts/$*/$(BUILDER_VERSION) \
-v $$(pwd):/packages cloudposse/packages-$*build:$(BUILDER_VERSION) \
bash
help/vendor:
@$(MAKE) --no-print-directory -s -C vendor help
help/md:
@$(MAKE) --no-print-directory -s -C vendor help/md
update/%:
rm -f vendor/$*/VERSION
make -C vendor/$* update
make readme