-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
151 lines (126 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
140
141
142
143
144
145
146
147
148
149
150
151
# Makefile for ansible-molecule-images
# name: ansible-molecule-images
# file: Makefile
# --- Python virtual environment -----------------------------------------------
DEPS := requirements.yml
REQS := requirements.txt
VENV := .venv
PIP := $(VENV)/bin/pip
# --- Ansible ------------------------------------------------------------------
GALAXY := $(VENV)/bin/ansible-galaxy
INVENTORY := $(VENV)/bin/ansible-inventory --list --limit
PLAYBOOK := $(VENV)/bin/ansible-playbook
# --- Makefile -----------------------------------------------------------------
LIMIT ?= fedora
# no autocomplete for dynamic targets ... :(
#distributions := $(shell $(INVENTORY) | jq -r 'keys[] | \
# select(. != "_meta" and . != "all") | @sh' | tr -d "'" | tr '\n' ' ')
# list of all supported distributions
distributions := \
almalinux \
alpine \
amazonlinux \
archlinux \
debian \
fedora \
opensuse \
oraclelinux \
ubuntu
# --- Python virtual environment and general make targets ----------------------
# default target
.PHONY: help
help:
@echo "Usage: make [target] [LIMIT=<hostname or group>]"
@echo
@echo "Targets:"
@echo " install - create virtual environment"
@echo " upgrade - update requirements in virtual environment"
@echo " all - build all distributions"
@echo " <distro> - build specific distribution"
@echo " clean - remove virtual environment"
@echo " commit - commit changes to the current branch"
@echo " dist-clean - remove virtual environment and build artifacts"
@echo " docker - build docker images"
@echo " limit - build artifacts limited to LIMIT parameter"
@echo " prepare-release - prepare a release and merge dev to main"
@echo " version - bump the version number and update the changelog"
@echo " publish - create a new Git tag and build the distribution files"
@echo " checkout-dev - checkout the dev branch"
@echo " start-feature - start a new feature branch"
@echo " merge-feature-to-dev - merge a feature branch to dev"
@echo
@echo "Supported distributions:"
@echo " $(distributions)"
$(DEPS):
@echo "---" > $@
@echo "collections:" >> $@
@echo " - containers.podman" >> $@
@echo "" >> $@
$(REQS):
@echo "ansible" > $@
@echo "commitizen" >> $@
@echo "pre-commit" >> $@
@echo "python-semantic-release" >> $@
$(VENV): $(REQS) $(DEPS)
@python3 -m venv $(VENV)
@$(PIP) install --upgrade pip
@$(PIP) install -r requirements.txt
@$(GALAXY) install -r $(DEPS)
@pre-commit install --hook-type commit-msg
.PHONY: install upgrade clean dist-clean
install: $(VENV)
upgrade: $(REQS)
@$(PIP) install --upgrade pip
@$(PIP) install --upgrade -r $(REQS)
@$(GALAXY) install --force -r $(DEPS)
clean:
@rm -rf $(VENV) $(REQS)
dist-clean: clean
@rm -rf build/ dist/
# --- Ansible/Build targets ----------------------------------------------------
.PHONY: $(distributions) all docker limit
$(distributions): | $(VENV)
@$(PLAYBOOK) playbooks/build.yml --limit=$@
all: $(distributions)
docker: $(VENV)
@$(PLAYBOOK) playbooks/docker.yml
limit: $(VENV)
@$(PLAYBOOK) playbooks/build.yml --limit=$(LIMIT)
# --- git targets --------------------------------------------------------------
.PHONY: checkout-dev commit start-feature merge-feature-to-dev prepare-release
# checkout the dev branch
checkout-dev:
@git checkout dev
# commit changes to the current branch
commit:
@git add .
@git commit
# start a new feature branch
start-feature:
@git checkout -b $(FEATURE) dev
# merge a feature branch to dev
merge-feature-to-dev:
@git checkout dev
@git merge $(FEATURE)
@git branch -d $(FEATURE)
# prepare a release and merge dev to main
prepare-release:
@git push origin dev
@git checkout main
@git merge dev
@git push origin main
@git checkout dev
# bump the version number and update the changelog
version:
@git checkout main
@semantic-release version
@git push origin main
@git checkout dev
@git merge main
@git push origin dev
# create a new Git tag and build the distribution files
publish:
@git checkout main
@semantic-release publish
@git push origin main --tags
@git checkout dev