sign-launcher: make the help text more automatic

Rather than display "3.0" all the time and confuse people, extract
the version from the launcher we're signing and display that.

Also reformat the text to follow our current practice: upload the
versioned launcher by itself first, and then later copy that over
the default.

And while we're here, add tips for rollbacks.

Change-Id: I1654425c88e5c67d78879f2f33ad685c59be14dc
Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/319637
Reviewed-by: Xin Li <delphij@google.com>
Tested-by: Mike Frysinger <vapier@google.com>
This commit is contained in:
Mike Frysinger 2021-09-30 23:13:04 -04:00
parent 669efd0fd7
commit 6a74c91f50

View File

@ -20,6 +20,7 @@ This is intended to be run only by the official Repo release managers.
import argparse import argparse
import os import os
import re
import subprocess import subprocess
import sys import sys
@ -49,18 +50,37 @@ def check(opts):
util.run(opts, ['gpg', '--verify', f'{opts.launcher}.asc']) util.run(opts, ['gpg', '--verify', f'{opts.launcher}.asc'])
def postmsg(opts): def get_version(opts):
"""Get the version from |launcher|."""
# Make sure we don't search $PATH when signing the "repo" file in the cwd.
launcher = os.path.join('.', opts.launcher)
cmd = [launcher, '--version']
ret = util.run(opts, cmd, encoding='utf-8', stdout=subprocess.PIPE)
m = re.search(r'repo launcher version ([0-9.]+)', ret.stdout)
if not m:
sys.exit(f'{opts.launcher}: unable to detect repo version')
return m.group(1)
def postmsg(opts, version):
"""Helpful info to show at the end for release manager.""" """Helpful info to show at the end for release manager."""
print(f""" print(f"""
Repo launcher bucket: Repo launcher bucket:
gs://git-repo-downloads/ gs://git-repo-downloads/
To upload this launcher directly: You should first upload it with a specific version:
gsutil cp -a public-read {opts.launcher} {opts.launcher}.asc gs://git-repo-downloads/ gsutil cp -a public-read {opts.launcher} gs://git-repo-downloads/repo-{version}
gsutil cp -a public-read {opts.launcher}.asc gs://git-repo-downloads/repo-{version}.asc
NB: You probably want to upload it with a specific version first, e.g.: Then to make it the public default:
gsutil cp -a public-read {opts.launcher} gs://git-repo-downloads/repo-3.0 gsutil cp -a public-read gs://git-repo-downloads/repo-{version} gs://git-repo-downloads/repo
gsutil cp -a public-read {opts.launcher}.asc gs://git-repo-downloads/repo-3.0.asc gsutil cp -a public-read gs://git-repo-downloads/repo-{version}.asc gs://git-repo-downloads/repo.asc
NB: If a rollback is necessary, the GS bucket archives old versions, and may be
accessed by specifying their unique id number.
gsutil ls -la gs://git-repo-downloads/repo gs://git-repo-downloads/repo.asc
gsutil cp -a public-read gs://git-repo-downloads/repo#<unique id> gs://git-repo-downloads/repo
gsutil cp -a public-read gs://git-repo-downloads/repo.asc#<unique id> gs://git-repo-downloads/repo.asc
""") """)
@ -103,9 +123,10 @@ def main(argv):
opts.keys = [util.KEYID_DSA, util.KEYID_RSA, util.KEYID_ECC] opts.keys = [util.KEYID_DSA, util.KEYID_RSA, util.KEYID_ECC]
util.import_release_key(opts) util.import_release_key(opts)
version = get_version(opts)
sign(opts) sign(opts)
check(opts) check(opts)
postmsg(opts) postmsg(opts, version)
return 0 return 0