mojo/discovery: Adding a publish target for publishing v23discovery
to Dart's pub repository.

NOTE: published under v23discovery as the name.

https://pub.dartlang.org/packages/v23discovery

Similar to Syncbase, mojom binaries files for both
Android and Desktop are included under /lib/mojo_services
in the package.

Change-Id: I1cff382b3a0945971b9331afc1ff488153d0ffb2
diff --git a/Makefile b/Makefile
index 496ce24..69d23ab 100644
--- a/Makefile
+++ b/Makefile
@@ -61,6 +61,27 @@
 	rm -rf gen
 	rm -rf lib/gen/dart-pkg
 	rm -rf lib/gen/mojom
+	rm -rf $(PACKAGE_MOJO_BIN_DIR)
+
+.PHONY: publish
+# NOTE(aghassemi): This must be inside lib in order to be accessible.
+PACKAGE_MOJO_BIN_DIR := lib/mojo_services
+ifdef DRYRUN
+	PUBLISH_FLAGS := --dry-run
+endif
+# NOTE(aghassemi): Publishing will fail unless you increment the version number
+# in pubspec.yaml. See https://www.dartlang.org/tools/pub/versioning.html for
+# guidelines.
+publish: clean packages
+	$(MAKE) test  # Test
+	$(MAKE) build  # Build for Linux.
+	ANDROID=1 $(MAKE) build  # Cross-compile for Android.
+	mkdir -p $(PACKAGE_MOJO_BIN_DIR)
+	cp -r gen/mojo/* $(PACKAGE_MOJO_BIN_DIR)
+	# Note: The '-' at the beginning of the following command tells make to ignore
+	# failures and always continue to the next command.
+	-pub publish $(PUBLISH_FLAGS)
+	rm -rf $(PACKAGE_MOJO_BIN_DIR)
 
 # Examples.
 run-advertiser: $(DISCOVERY_BUILD_DIR)/advertiser.mojo $(DISCOVERY_BUILD_DIR)/discovery.mojo
diff --git a/pubspec.yaml b/pubspec.yaml
index 7ff04d8..a15c9ed 100644
--- a/pubspec.yaml
+++ b/pubspec.yaml
@@ -1,10 +1,10 @@
 author: Vanadium Authors
 description: Discovery is a discovery system for developers that makes it easy to advertise apps and scan for them. It works over MDNS and BLE.
 homepage: https://github.com/vanadium/mojo.discovery
-name: discovery
+name: v23discovery
 version: 0.0.1
 dependencies:
-  mojo: '>=0.3.0 <0.4.0'
+  mojo: '>=0.4.0 <0.5.0'
 dev_dependencies:
   dart_style: any
   test: any