Commit and push the results.

Signed-off-by: Tim 'mithro' Ansell <me@mith.ro>
diff --git a/open_pdks/build-info.py b/open_pdks/build-info.py
index d64971d..5365cad 100755
--- a/open_pdks/build-info.py
+++ b/open_pdks/build-info.py
@@ -15,8 +15,9 @@
 #
 # SPDX-License-Identifier: Apache-2.0
 
-import subprocess
 import json
+import os
+import subprocess
 
 GIT_FETCH_TAGS="git fetch --tags"
 GIT_DESCRIBE_CMD="git describe --long --always"
@@ -98,7 +99,14 @@
   SkyWater PDK: {skywater_pdk}
      Open-PDKs: {open_pdks}
          Magic: {magic}
-""".format(**version_strings)
+
+Build results @ https://source.cloud.google.com/results/invocations/{KOKORO_BUILD_ID}
+Build artifacts @ https://console.cloud.google.com/storage/browser/open_pdks/skywater-pdk/artifacts/{KOKORO_BUILD_ARTIFACTS_SUBDIR}
+
+""".format(
+    KOKORO_BUILD_ID=os.environ['KOKORO_BUILD_ID'],
+    KOKORO_BUILD_ARTIFACTS_SUBDIR=os.environ['KOKORO_BUILD_ARTIFACTS_SUBDIR'],
+    **version_strings)
 
 print(info)
 
@@ -107,3 +115,13 @@
 
 with open('out/build.json', 'w') as f:
     json.dump(versions, f, sort_keys=True, indent=2)
+
+with open('out/build.sh', 'w') as f:
+    for k, v in version_strings.items():
+        k = k.upper()
+        f.write("VERSION_{}='{}'\n".format(k, v))
+        f.write("export VERSION_{}\n".format(k))
+
+with open('out/build.msg', 'w') as f:
+    f.write("Build {}\n\n".format(version_strings['final']))
+    f.write(info)
diff --git a/open_pdks/output-build.sh b/open_pdks/output-build.sh
new file mode 100755
index 0000000..b738b5c
--- /dev/null
+++ b/open_pdks/output-build.sh
@@ -0,0 +1,36 @@
+#!/usr/bin/env bash
+# Copyright 2021 SkyWater PDK Authors
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# SPDX-License-Identifier: Apache-2.0
+
+set -e
+
+cd /tmpfs/src/git/output
+# Copy into the output git repositories
+tar -Jxvf /tmpfs/src/out/pdk-SKY130A.tar.xz .
+cp /tmpfs/src/out/build.info .
+cp /tmpfs/src/out/build.json .
+git checkout HEAD README.md
+git checkout HEAD LICENSE
+
+# Update the repository
+git add -A
+git status
+git commit -F /tmpfs/src/out/build.msg
+
+git format-patch -1 --output-directory /tmpfs/src/out/
+
+# Push the result
+git push origin
diff --git a/open_pdks/output-cleanup.sh b/open_pdks/output-cleanup.sh
new file mode 100755
index 0000000..e0afb77
--- /dev/null
+++ b/open_pdks/output-cleanup.sh
@@ -0,0 +1,24 @@
+#!/usr/bin/env bash
+# Copyright 2021 SkyWater PDK Authors
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# SPDX-License-Identifier: Apache-2.0
+
+set -e
+
+cd /tmpfs/src/git/output
+
+for B in $(git ls-remote --heads origin | grep building | sed -e's/[a-f0-9]*[\s\t]*//' -e's@.*/@@'); do
+	git push origin :$B
+done
diff --git a/open_pdks/output-start.sh b/open_pdks/output-start.sh
new file mode 100755
index 0000000..689efc5
--- /dev/null
+++ b/open_pdks/output-start.sh
@@ -0,0 +1,21 @@
+#!/usr/bin/env bash
+# Copyright 2021 SkyWater PDK Authors
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# SPDX-License-Identifier: Apache-2.0
+
+set -e
+
+cd /tmpfs/src/git/output
+git push origin main:building-$VERSION_FINAL
diff --git a/open_pdks/run.sh b/open_pdks/run.sh
index 32b76cc..359144f 100755
--- a/open_pdks/run.sh
+++ b/open_pdks/run.sh
@@ -24,6 +24,7 @@
 SCRIPT_DIR_REL="$(realpath $SCRIPT_DIR --relative-to=$PWD)"
 
 TOP_DIR=$PWD
+export TOP_DIR
 
 set -e
 
@@ -39,12 +40,18 @@
 
 $SCRIPT_DIR/build-info.py
 
+cat out/build.sh
+source out/build.sh
+
 echo
 
 find $PWD -type d | sort
 
 set -xe
 
+$SCRIPT_DIR/output-cleanup.sh
+$SCRIPT_DIR/output-start.sh
+
 # This script tries to follows the instructions in the README @
 # https://github.com/RTimothyEdwards/open_pdks/tree/master/sky130 with a couple
 # of differences;
@@ -109,3 +116,8 @@
 
 # Fix `rsync: send_files failed to open ... Permission denied (13)`
 sudo chown -R $UID /tmpfs/src
+
+# Copy into the output git repositories
+$SCRIPT_DIR/output-build.sh
+
+$SCRIPT_DIR/output-cleanup.sh
diff --git a/open_pdks/system-setup.sh b/open_pdks/system-setup.sh
index 6826446..2425dbc 100755
--- a/open_pdks/system-setup.sh
+++ b/open_pdks/system-setup.sh
@@ -18,7 +18,7 @@
 set -e
 
 echo
-echo "Setting up Kokoro system"
+echo "Setting up Git-on-Borg authentication"
 echo "====================================================="
 echo
 
@@ -29,6 +29,9 @@
 
 curl -b ~/.git-credential-cache/cookie https://foss-eda-tools.googlesource.com/?format=TEXT
 
+git config --global user.name "SkyWater PDK Robot"
+git config --global user.email robot@skywater.tools
+
 echo "====================================================="
 
 echo