From f39b860650068f625c91ef94979a1f6257f32039 Mon Sep 17 00:00:00 2001 From: Trevor Bramwell Date: Fri, 27 Apr 2018 14:00:16 -0700 Subject: Verify and Create Tags from Release File Updates the releases verify and merge jobs to check release files for the following: - commits exist - commits are on stable-branch If both of these criteria are met and the patch is merged, the repos will be tagged at the specified commits and pushed. If a repo has already been tagged but not on stable-branch the job will not exit, but will warn that the commit doesn't exist on the correct branch. This is because tags should never be removed. This adds an additional script 'repos.py' that provides an quick interface for pulling out information from release files, along with the script 'release-status.sh' for checking the status of tags. NOTE: The branch creation script has been disabled until it can be reworked. Change-Id: I498bc74f20aa50d2bd321771f20a77905b246399 Signed-off-by: Trevor Bramwell --- releases/scripts/release-status.sh | 25 ++++++++++++++++ releases/scripts/repos.py | 60 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 85 insertions(+) create mode 100644 releases/scripts/release-status.sh create mode 100644 releases/scripts/repos.py (limited to 'releases/scripts') diff --git a/releases/scripts/release-status.sh b/releases/scripts/release-status.sh new file mode 100644 index 000000000..da66bc936 --- /dev/null +++ b/releases/scripts/release-status.sh @@ -0,0 +1,25 @@ +#!/bin/bash +# SPDX-License-Identifier: Apache-2.0 +############################################################################## +# Copyright (c) 2018 The Linux Foundation and others. +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## +set -o pipefail + +TAG="${TAG:-opnfv-6.0.0}" +RELEASE="${RELEASE:-fraser}" + +for project in releases/$RELEASE/*; do + python releases/scripts/repos.py -n -f $project >> repos.txt +done + +while read -r repo +do + tag="$(git ls-remote "https://gerrit.opnfv.org/gerrit/$repo.git" "refs/tags/$TAG")" + echo "$repo $tag" +done < repos.txt + +# rm repos.txt diff --git a/releases/scripts/repos.py b/releases/scripts/repos.py new file mode 100644 index 000000000..0ded0207b --- /dev/null +++ b/releases/scripts/repos.py @@ -0,0 +1,60 @@ +#!/usr/bin/env python2 +# SPDX-License-Identifier: Apache-2.0 +############################################################################## +# Copyright (c) 2018 The Linux Foundation and others. +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## +""" +List Release Repos +""" + +import argparse +import yaml + + +def main(): + """Given a release yamlfile list the repos it contains""" + + parser = argparse.ArgumentParser() + parser.add_argument('--file', '-f', + type=argparse.FileType('r'), + required=True) + parser.add_argument('--names', '-n', + action='store_true', + default=False, + help="Only print the names of repos, " + "not their SHAs") + parser.add_argument('--release', '-r', + type=str, + help="Only print" + "SHAs for the specified release") + args = parser.parse_args() + + project = yaml.safe_load(args.file) + + list_repos(project, args) + + +def list_repos(project, args): + """List repositories in the project file""" + + lookup = project.get('releases', []) + if 'releases' not in project: + exit(0) + + for item in lookup: + repo, ref = next(iter(item['location'].items())) + if args.names: + print(repo) + elif args.release and item['version'] == args.release: + print("%s %s" % (repo, ref)) + elif not args.release: + # Print all releases + print("%s %s %s" % (repo, item['version'], ref)) + + +if __name__ == "__main__": + main() -- cgit 1.2.3-korg