|
| 1 | +#!/usr/bin/env python |
| 2 | +# Script to make a new AWS Lambda Layer release on Github |
| 3 | +# Requires the Github CLI to be installed and configured: https://github.com/cli/cli |
| 4 | + |
| 5 | +import sys |
| 6 | +import json |
| 7 | +import distutils.spawn |
| 8 | +from subprocess import check_output |
| 9 | + |
| 10 | +if len(sys.argv) != 2: |
| 11 | + raise ValueError('Please specify the layer version to release. e.g. "11"') |
| 12 | + |
| 13 | +# Check requirements first |
| 14 | +for cmd in ["gh"]: |
| 15 | + if distutils.spawn.find_executable(cmd) is None: |
| 16 | + print("Can't find required tool: %s" % cmd) |
| 17 | + sys.exit(1) |
| 18 | + |
| 19 | +regions = ['ap-northeast-1', 'ap-northeast-2', 'ap-south-1', 'ap-southeast-1', 'ap-southeast-2', 'ca-central-1', |
| 20 | + 'eu-central-1', 'eu-north-1', 'eu-west-1', 'eu-west-2', 'eu-west-3', 'sa-east-1', 'us-east-1', |
| 21 | + 'us-east-2', 'us-west-1', 'us-west-2'] |
| 22 | + |
| 23 | +version = sys.argv[1] |
| 24 | +semantic_version = 'v' + version |
| 25 | +title = "AWS Lambda Version %s" % semantic_version |
| 26 | + |
| 27 | +body = '| AWS Region | ARN |\n' |
| 28 | +body += '| :-- | :-- |\n' |
| 29 | +for region in regions: |
| 30 | + body += "| %s | arn:aws:lambda:%s:410797082306:layer:instana-python:%s |\n" % (region, region, version) |
| 31 | + |
| 32 | +response = check_output(["gh", "api", "repos/:owner/:repo/releases", "--method=POST", |
| 33 | + "-F", ("tag_name=%s" % semantic_version), |
| 34 | + "-F", "name=%s" % title, |
| 35 | + "-F", "body=%s" % body]) |
| 36 | + |
| 37 | +json_data = json.loads(response) |
| 38 | + |
| 39 | +print("If there weren't any failures, the release is available at:") |
| 40 | +print(json_data["html_url"]) |
0 commit comments