Merge ~cjwatson/rutabaga:charm-publish into rutabaga:master

Proposed by Colin Watson
Status: Merged
Approved by: Colin Watson
Approved revision: 9a17ca3622cc3675b10438f3db597ba3e9827656
Merge reported by: Otto Co-Pilot
Merged at revision: not available
Proposed branch: ~cjwatson/rutabaga:charm-publish
Merge into: rutabaga:master
Diff against target: 59 lines (+42/-2)
1 file modified
charm/Makefile (+42/-2)
Reviewer Review Type Date Requested Status
Cristian Gonzalez (community) Approve
Review via email: mp+408665@code.launchpad.net

Commit message

Add charm publishing arrangements

To post a comment you must log in.
Revision history for this message
Cristian Gonzalez (cristiangsp) wrote :

Looks good!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/charm/Makefile b/charm/Makefile
2index bb02854..a316d68 100644
3--- a/charm/Makefile
4+++ b/charm/Makefile
5@@ -14,6 +14,14 @@ CHARMS := \
6 rutabaga \
7 rutabaga-auth-helper
8
9+PUBLISH_REPO_PREFIX := lp:~launchpad/rutabaga/+git/charm-build-
10+PUBLISHDIR := $(BUILDDIR)/publish
11+# We may need to force username and email when publishing, because git may
12+# not be able to autodetect this in automatic build environments.
13+DOMAIN ?= $(shell hostname -f)
14+GIT_USERNAME = $(shell git config --get user.name || echo $(USER))
15+GIT_EMAIL = $(shell git config --get user.email || echo $(USER)@$(DOMAIN))
16+
17 all: build lint
18
19 $(BUILDDIR) $(TMPDIR):
20@@ -81,5 +89,37 @@ lint: build
21 @echo "Linting python sources..."
22 @flake8 interface $(CHARMS)
23
24-.PHONY: build-rutabaga
25-.PHONY: all build clean deploy lint payload
26+publish: build lint | $(PUBLISHDIR)
27+ @set -e; for charm in $(CHARMS); do \
28+ if [ -d $(PUBLISHDIR)/$$charm ]; then \
29+ git -C $(PUBLISHDIR)/$$charm pull; \
30+ else \
31+ git clone $(PUBLISH_REPO_PREFIX)$$charm \
32+ $(PUBLISHDIR)/$$charm; \
33+ fi; \
34+ rsync -a -m --ignore-times --exclude .git --delete \
35+ dist/$$charm/ $(PUBLISHDIR)/$$charm/; \
36+ git -C $(PUBLISHDIR)/$$charm add .; \
37+ if [ "$$(git -C $(PUBLISHDIR)/$$charm status --porcelain || \
38+ echo status failed)" ]; then \
39+ git -C $(PUBLISHDIR)/$$charm \
40+ -c user.name="$(GIT_USERNAME)" \
41+ -c user.email="$(GIT_EMAIL)" \
42+ commit -a \
43+ -m "Build of $$charm from $(BUILD_LABEL)"; \
44+ git -C $(PUBLISHDIR)/$$charm tag build/$(BUILD_LABEL); \
45+ fi; \
46+ git -C $(PUBLISHDIR)/$$charm push --tags origin master; \
47+ done
48+
49+# Prepare a Jenkins-as-a-service container for charm building.
50+setup-jenkaas:
51+ sudo systemctl stop snapd.socket
52+ sudo systemctl stop snapd
53+ echo SNAPPY_STORE_NO_CDN=1 | sudo tee -a /etc/environment >/dev/null
54+ echo SNAPPY_TESTING=1 | sudo tee -a /etc/environment >/dev/null
55+ sudo systemctl start snapd.socket
56+ sudo snap install --classic charm
57+
58+.PHONY: $(foreach charm,$(CHARMS),build-$(charm))
59+.PHONY: all build clean deploy lint payload publish setup-jenkaas

Subscribers

People subscribed via source and target branches