launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #27519
[Merge] ~cjwatson/rutabaga:charm-publish into rutabaga:master
Colin Watson has proposed merging ~cjwatson/rutabaga:charm-publish into rutabaga:master.
Commit message:
Add charm publishing arrangements
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~cjwatson/rutabaga/+git/rutabaga/+merge/408665
--
Your team Launchpad code reviewers is requested to review the proposed merge of ~cjwatson/rutabaga:charm-publish into rutabaga:master.
diff --git a/charm/Makefile b/charm/Makefile
index bb02854..a316d68 100644
--- a/charm/Makefile
+++ b/charm/Makefile
@@ -14,6 +14,14 @@ CHARMS := \
rutabaga \
rutabaga-auth-helper
+PUBLISH_REPO_PREFIX := lp:~launchpad/rutabaga/+git/charm-build-
+PUBLISHDIR := $(BUILDDIR)/publish
+# We may need to force username and email when publishing, because git may
+# not be able to autodetect this in automatic build environments.
+DOMAIN ?= $(shell hostname -f)
+GIT_USERNAME = $(shell git config --get user.name || echo $(USER))
+GIT_EMAIL = $(shell git config --get user.email || echo $(USER)@$(DOMAIN))
+
all: build lint
$(BUILDDIR) $(TMPDIR):
@@ -81,5 +89,37 @@ lint: build
@echo "Linting python sources..."
@flake8 interface $(CHARMS)
-.PHONY: build-rutabaga
-.PHONY: all build clean deploy lint payload
+publish: build lint | $(PUBLISHDIR)
+ @set -e; for charm in $(CHARMS); do \
+ if [ -d $(PUBLISHDIR)/$$charm ]; then \
+ git -C $(PUBLISHDIR)/$$charm pull; \
+ else \
+ git clone $(PUBLISH_REPO_PREFIX)$$charm \
+ $(PUBLISHDIR)/$$charm; \
+ fi; \
+ rsync -a -m --ignore-times --exclude .git --delete \
+ dist/$$charm/ $(PUBLISHDIR)/$$charm/; \
+ git -C $(PUBLISHDIR)/$$charm add .; \
+ if [ "$$(git -C $(PUBLISHDIR)/$$charm status --porcelain || \
+ echo status failed)" ]; then \
+ git -C $(PUBLISHDIR)/$$charm \
+ -c user.name="$(GIT_USERNAME)" \
+ -c user.email="$(GIT_EMAIL)" \
+ commit -a \
+ -m "Build of $$charm from $(BUILD_LABEL)"; \
+ git -C $(PUBLISHDIR)/$$charm tag build/$(BUILD_LABEL); \
+ fi; \
+ git -C $(PUBLISHDIR)/$$charm push --tags origin master; \
+ done
+
+# Prepare a Jenkins-as-a-service container for charm building.
+setup-jenkaas:
+ sudo systemctl stop snapd.socket
+ sudo systemctl stop snapd
+ echo SNAPPY_STORE_NO_CDN=1 | sudo tee -a /etc/environment >/dev/null
+ echo SNAPPY_TESTING=1 | sudo tee -a /etc/environment >/dev/null
+ sudo systemctl start snapd.socket
+ sudo snap install --classic charm
+
+.PHONY: $(foreach charm,$(CHARMS),build-$(charm))
+.PHONY: all build clean deploy lint payload publish setup-jenkaas