Example #1
0
    def run(self):
        proc = Popen(
            ('git', 'diff-index', '--quiet', '--ignore-submodules', 'HEAD'))
        if proc.wait() != 0:
            raise RuntimeError('Repo is dirty')

        proc = Popen(('git', 'log', '-1', '--pretty=format:%h'), stdout=PIPE)
        rev = proc.communicate()[0].decode().rstrip('\n')

        proc = Popen(('git', 'rev-parse', '--abbrev-ref', 'HEAD'), stdout=PIPE)
        branch = proc.communicate()[0].decode().rstrip('\n')

        client = Session().create_client('lambda', region_name=self.region)
        ret = client.publish_version(FunctionName=self.name,
                                     Description='%s (%s)' % (rev, branch))
        print('\nVersion %r published (Description=%s)' %
              (ret['Version'], ret['Description']))