UI: move build artifacts into /v1.2.3/

This CL moves all the build artifacts into a
subdirectory named after the version number.
This is done for two reasons:
1. Cache-busting, to avoid pulling subresources
   at different versions.
2. Prepare for multiple channels (see
   go/perfetto-ui-channels).

This CL also changes the service worker logic
as follows (See go/perfetto-offline for full
details):
- Network-first fetch of the / index, to
  guarantee that the index is always current.
- The subresource map with hashes is not bundled
  in the service_worker.js script but is fetched
  separately from /v.1.2.3/manifest.json.

Bug: 179864115
Change-Id: Iece22b770f7e2bd958cdcfe30df046832f070641
diff --git a/tools/write_version_header.py b/tools/write_version_header.py
index 88dcb30..028ad2a 100755
--- a/tools/write_version_header.py
+++ b/tools/write_version_header.py
@@ -101,6 +101,7 @@
       help='Skips running git rev-parse, emits only the version from CHANGELOG')
   parser.add_argument('--cpp_out', help='Path of the generated .h file.')
   parser.add_argument('--ts_out', help='Path of the generated .ts file.')
+  parser.add_argument('--stdout', help='Write to stdout', action='store_true')
   parser.add_argument('--changelog', help='Path to CHANGELOG.')
   args = parser.parse_args()
 
@@ -142,6 +143,9 @@
     content = '\n'.join(lines)
     write_if_unchanged(args.ts_out, content)
 
+  if args.stdout:
+    print(version)
+
 
 if __name__ == '__main__':
   sys.exit(main())