From 4bfdc9fd015b95bf9f3bcd311818de6cee342c9e Mon Sep 17 00:00:00 2001 From: Sebastian Thiel Date: Mon, 23 Mar 2015 12:11:18 +0100 Subject: [PATCH] chore(publish): make publish We will now keep marker files to remember which crates we have published successfully. These files are checked in to make this information persist. NOTE: We still don't explicitly exclude pseudo-changes in json files, which are no real change except for a changed revision number. Fixes #41 --- Makefile | 1 + src/mako/deps.mako | 17 ++++++++++++++--- src/mako/lib/util.mako | 2 +- src/mako/lib/util.py | 4 ++++ 4 files changed, 20 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 0e407ec0b6..3abc74f528 100644 --- a/Makefile +++ b/Makefile @@ -34,6 +34,7 @@ help: $(info github-pages - invoke ghp-import on all documentation) $(info apis - make all APIs) $(info cargo - run cargo on all APIs, use ARGS="args ..." to specify cargo arguments) + $(info publish - run cargo publish on all APIs and remember successful ones with marker files) $(info regen-apis - clear out all generated apis, and regenerate them) $(info clean-apis - delete all generated APIs) $(info help-api - show all api targets to build individually) diff --git a/src/mako/deps.mako b/src/mako/deps.mako index 35155d4436..3179d2d5d4 100644 --- a/src/mako/deps.mako +++ b/src/mako/deps.mako @@ -26,6 +26,8 @@ <% import util import os + import json + api_name = util.library_name(an, version) crate_name = util.library_to_crate_name(api_name) gen_root = directories.output + '/' + api_name @@ -42,11 +44,14 @@ sds = [(directories.mako_src + '/' + i.source + '.mako', gen_root + '/' + i.get('output_dir', '') + '/' + i.source) for i in api.templates] api_json = directories.api_base + '/' + an + '/' + version + '/' + an + '-api.json' - api_json_overrides = os.path.dirname(api_json) + '/' + an + '-api_overrides.json' + api_meta_dir = os.path.dirname(api_json) + api_crate_publish_file = api_meta_dir + '/crates/' + util.crate_version(cargo.build_version, + json.load(open(api_json, 'r'))['revision']) + api_json_overrides = api_meta_dir + '/' + an + '-api_overrides.json' api_json_inputs = api_json + ' $(API_SHARED_INFO)' if os.path.isfile(api_json_overrides): api_json_inputs += ' ' + api_json_overrides - api_info.append((api_name, api_clean, api_cargo, api_doc, gen_root)) + api_info.append((api_name, api_clean, api_cargo, api_doc, api_crate_publish_file, gen_root)) space_join = lambda i: ' '.join(a[i] for a in api_info) %>\ @@ -62,6 +67,11 @@ ${gen_root_stamp}: ${' '.join(i[0] for i in sds)} ${api_json_inputs} $(MAKO_STAN ${api_name}: ${api_common} +${api_crate_publish_file}: + cd ${gen_root} && cargo publish + @mkdir -p ${os.path.dirname(api_crate_publish_file)} + touch $@ + ${api_cargo}: ${api_name} cd ${gen_root} && cargo $(ARGS) @@ -82,6 +92,7 @@ ${api_clean}: clean-apis: ${space_join(1)} docs-clean cargo: ${space_join(2)} +publish: | apis ${space_join(4)} apis: ${space_join(0)} ${doc_index}: ${' '.join(central_api_index(util.library_to_crate_name(a[0])) for a in api_info)} $(MAKO_STANDARD_DEPENDENCIES) @@ -97,7 +108,7 @@ github-pages: | docs-clean docs ## Have to force-push - allows us to start docs fresh, clearing out unused history git push origin +gh-pages -.PHONY = $(.PHONY) update-json github-pages help-api clean-apis cargo apis docs docs-clean ${space_join(0)} ${space_join(1)} ${space_join(2)} ${space_join(3)} +.PHONY = $(.PHONY) update-json github-pages help-api clean-apis cargo publish apis docs docs-clean ${space_join(0)} ${space_join(1)} ${space_join(2)} ${space_join(3)} help-api: $(info apis - make all APIs) diff --git a/src/mako/lib/util.mako b/src/mako/lib/util.mako index b22a29610e..7e8d878726 100644 --- a/src/mako/lib/util.mako +++ b/src/mako/lib/util.mako @@ -28,7 +28,7 @@ ${util.library_to_crate_name(util.library_name(name, version))}\ <%def name="crate_version()" buffered="True">\ -${cargo.build_version}+${revision}\ +${util.crate_version(cargo.build_version, revision)}\ ## All crates and standard `use` declaration, required for all examples diff --git a/src/mako/lib/util.py b/src/mako/lib/util.py index 22c7e20d70..c9190f380b 100644 --- a/src/mako/lib/util.py +++ b/src/mako/lib/util.py @@ -799,6 +799,10 @@ def library_name(name, version): def library_to_crate_name(name): return 'google-' + name +# return version like 0.1.0+2014031421 +def crate_version(build_version, revision): + return '%s+%s' % (build_version, revision) + # return type name of a resource method builder, from a resource name def rb_type(r): return "%sMethods" % singular(canonical_type_name(r))