2021-02-23 17:37:48 +08:00
|
|
|
# PROJECT_VERSION defaults to:
|
|
|
|
|
# 1. the version exported by rabbitmq-server-release;
|
|
|
|
|
# 2. the version stored in `git-revisions.txt`, if it exists;
|
|
|
|
|
# 3. a version based on git-describe(1), if it is a Git clone;
|
|
|
|
|
# 4. 0.0.0
|
|
|
|
|
|
|
|
|
|
PROJECT_VERSION := $(RABBITMQ_VERSION)
|
|
|
|
|
|
|
|
|
|
ifeq ($(PROJECT_VERSION),)
|
|
|
|
|
PROJECT_VERSION := $(shell \
|
|
|
|
|
if test -f git-revisions.txt; then \
|
|
|
|
|
head -n1 git-revisions.txt | \
|
|
|
|
|
awk '{print $$$(words $(PROJECT_DESCRIPTION) version);}'; \
|
|
|
|
|
else \
|
|
|
|
|
(git describe --dirty --abbrev=7 --tags --always --first-parent \
|
|
|
|
|
2>/dev/null || echo rabbitmq_v0_0_0) | \
|
|
|
|
|
sed -e 's/^rabbitmq_v//' -e 's/^v//' -e 's/_/./g' -e 's/-/+/' \
|
|
|
|
|
-e 's/-/./g'; \
|
|
|
|
|
fi)
|
|
|
|
|
endif
|
|
|
|
|
|
2021-07-14 19:02:22 +08:00
|
|
|
ifeq ($(filter-out all dist push clean,$(MAKECMDGOALS)),)
|
2021-02-23 17:37:48 +08:00
|
|
|
GENERIC_UNIX_ARCHIVE ?= $(wildcard $(PACKAGES_DIR)/rabbitmq-server-generic-unix-$(PROJECT_VERSION).tar.xz)
|
2021-02-17 16:43:10 +08:00
|
|
|
|
|
|
|
|
ifeq ($(GENERIC_UNIX_ARCHIVE),)
|
|
|
|
|
$(error Cannot find generic-unix archive; please specify GENERIC_UNIX_ARCHIVE)
|
|
|
|
|
endif
|
|
|
|
|
|
|
|
|
|
VERSION ?= $(patsubst rabbitmq-server-generic-unix-%.tar.xz,%,$(notdir $(GENERIC_UNIX_ARCHIVE)))
|
|
|
|
|
ifeq ($(VERSION),)
|
|
|
|
|
$(error Cannot determine version; please specify VERSION)
|
|
|
|
|
endif
|
2021-07-07 18:23:40 +08:00
|
|
|
|
|
|
|
|
IMAGE_TAG_1 ?= $(subst +,-,$(VERSION))
|
2021-02-17 16:43:10 +08:00
|
|
|
endif
|
|
|
|
|
|
2021-04-23 17:30:08 +08:00
|
|
|
REPO ?= pivotalrabbitmq/rabbitmq
|
2021-02-17 16:43:10 +08:00
|
|
|
|
|
|
|
|
all: dist
|
|
|
|
|
|
|
|
|
|
dist:
|
2024-04-20 02:05:24 +08:00
|
|
|
cp -f $(GENERIC_UNIX_ARCHIVE) package-generic-unix.tar.xz
|
2021-02-12 22:18:44 +08:00
|
|
|
docker build --pull \
|
2024-04-20 02:05:24 +08:00
|
|
|
--build-arg RABBITMQ_VERSION=$(VERSION) \
|
2021-06-24 16:04:32 +08:00
|
|
|
--tag $(REPO):$(IMAGE_TAG_1) \
|
2021-02-12 22:18:44 +08:00
|
|
|
.
|
2021-02-23 16:34:25 +08:00
|
|
|
|
Build & push container image on every commit
Before this, someone would need to run the package-generic-unix and
docker-image make targets in order to produce a container image. This
wouldn't always work: more than one archive in the PACKAGES dir, VERSION
& RABBITMQ_VERSION had to be specified, + characters in VERSION. It also
required me to have Docker running, which I am reluctant to leave
running on macOS because it uses CPU even when idle, and starting it
every time that I wanted an ad-hoc container image implied waiting a few
minutes, and then waiting another 15 minutes for the container image to
be produced and published to hub.docker.com.
This commit delegates all the above to GitHub Actions. The best part is
that it happens asynchronously - every commit triggers it - and a
container image for that commit will appear on hub.docker.com within ~15
minutes. In other words, anyone can test any commit in their container
runtime within 20 minutes, without needing to lift a finger. No Docker,
no make targets, just reference the new tag (matches the git sha) and
off you go. It's the beginning of something better, for sure.
Did some cleanup in the Dockerfile part of this. Dropped
RABBITMQ_VERSION build arg, env & commented steps. This is cruft that we
no longer need or even use.
Also fixed VERSION in push target and broken the dependency on dist so
that they can be run independently.
Signed-off-by: Gerhard Lazu <gerhard@lazu.co.uk>
2021-03-30 20:02:13 +08:00
|
|
|
push:
|
2021-06-24 16:04:32 +08:00
|
|
|
docker push $(REPO):$(IMAGE_TAG_1)
|
|
|
|
|
ifdef IMAGE_TAG_2
|
|
|
|
|
docker tag $(REPO):$(IMAGE_TAG_1) $(REPO):$(IMAGE_TAG_2)
|
|
|
|
|
docker push $(REPO):$(IMAGE_TAG_2)
|
2021-04-23 17:30:08 +08:00
|
|
|
endif
|
2021-02-17 16:43:10 +08:00
|
|
|
|
|
|
|
|
clean:
|
2024-04-20 02:05:24 +08:00
|
|
|
rm -f rabbitmq_server-*
|