Skip to content

Commit

Permalink
feat(spinnaker_release): Add orchestration script for Spinnaker relea…
Browse files Browse the repository at this point in the history
…se. (#1609)
  • Loading branch information
jtk54 committed Apr 28, 2017
1 parent 09b20a9 commit 749fff5
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 7 deletions.
8 changes: 4 additions & 4 deletions dev/publish_bom.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import argparse
import datetime
import os
import socket
import sys
import yaml

Expand Down Expand Up @@ -122,13 +121,14 @@ def publish_changelog_gist(self):
# Also add some identifying information.
raw_content_lines[0] = spinnaker_version
timestamp = '{:%Y-%m-%d %H:%M:%S}'.format(datetime.datetime.now())
signature = '\n\nGenerated by {0} at {1}'.format(socket.gethostname(), timestamp)
signature = '\n\nGenerated by {0} at {1}'.format(self.__github_publisher, timestamp)
raw_content_lines.append(signature)
content = InputFileContent(''.join(raw_content_lines))
filename = os.path.basename(self.__changelog_file)
gist = self.__github.get_user().create_gist(True, {filename: content}, description=description)
print ('Wrote changelog to Gist at https://gist.github.com/{user}/{id}'
.format(user=self.__gist_user, id=gist.id))
gist_uri = 'https://gist.github.com/{user}/{id}'.format(user=self.__gist_user, id=gist.id)
print ('Wrote changelog to Gist at {0}.'.format(gist_uri))
return gist_uri

def push_branch_and_tags(self):
"""Creates a release branch and pushes tags to the microservice repos owned by --github_publisher.
Expand Down
11 changes: 8 additions & 3 deletions dev/publish_changelog.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@

class ChangelogPublisher():

def __init__(self, options):
def __init__(self, options, changelog_gist_uri=None):
self.__version = options.version
self.__githubio_repo_uri = options.githubio_repo_uri
self.__changelog_gist_uri = options.changelog_gist_uri
self.__changelog_gist_uri = changelog_gist_uri or options.changelog_gist_uri

def __checkout_githubio_repo(self):
"""Clones the spinnaker.github.io git repo.
Expand All @@ -64,6 +64,11 @@ def __format_changelog_post(self):
''
]

# Since we include the changelog gist as a script, make sure we're
# referring to the gist javascript file.
if self.__changelog_gist_uri and not self.__changelog_gist_uri.endswith('.js'):
self.__changelog_gist_uri = self.__changelog_gist_uri + '.js'

post_lines.append('<script src="{uri}"></script>'.format(uri=self.__changelog_gist_uri))
post = '\n'.join(post_lines)
return post
Expand Down Expand Up @@ -100,7 +105,7 @@ def init_argument_parser(cls, parser):
'commit the changelog post to, e.g. git@github.com:spinnaker/spinnaker.github.io.')
parser.add_argument('--version', default='', required=True,
help='The version of Spinnaker that corresponds to the changelog.')
parser.add_argument('--changelog_gist_uri', default='', required=True,
parser.add_argument('--changelog_gist_uri', default='',
help='A uri that points to a gist containing the changelog.')

@classmethod
Expand Down
47 changes: 47 additions & 0 deletions dev/publish_spinnaker_release.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#!/usr/bin/python
#
# Copyright 2017 Google Inc. All Rights Reserved.
#
# 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.

import argparse
import os
import sys

from publish_bom import BomPublisher
from publish_changelog import ChangelogPublisher


def init_argument_parser(parser):
BomPublisher.init_argument_parser(parser)
ChangelogPublisher.init_argument_parser(parser)

def main():
"""Publish a validated Spinnaker release.
"""
parser = argparse.ArgumentParser()
init_argument_parser(parser)
options = parser.parse_args()

bom_publisher = BomPublisher(options)
bom_publisher.unpack_bom()
gist_uri = bom_publisher.publish_changelog_gist()
bom_publisher.push_branch_and_tags()
bom_publisher.publish_release_bom()

result_publisher = ChangelogPublisher(options, changelog_gist_uri=gist_uri)
result_publisher.publish_changelog()


if __name__ == '__main__':
sys.exit(main())

0 comments on commit 749fff5

Please sign in to comment.