-
Notifications
You must be signed in to change notification settings - Fork 119
/
release_tag.py
executable file
·61 lines (49 loc) · 1.67 KB
/
release_tag.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/usr/bin/env python3
import os
import pathlib
import sys
import boto3
import requests
tag_name = os.environ.get("TAG_NAME")
dcos_version = os.environ.get("DCOS_VERSION")
if not tag_name:
print("Missing TAG_NAME.", file=sys.stderr)
sys.exit(1)
if not dcos_version:
print("Missing DCOS_VERSION.", file=sys.stderr)
sys.exit(1)
s3_client = boto3.resource('s3', region_name='us-west-2').meta.client
bucket = "downloads.dcos.io"
artifacts = [
"binaries/cli/linux/x86-64/{}/dcos",
"binaries/cli/darwin/x86-64/{}/dcos",
"binaries/cli/windows/x86-64/{}/dcos.exe"
]
for artifact in artifacts:
src = {'Bucket': bucket, 'Key': artifact.format(tag_name)}
dst = artifact.format("dcos-" + dcos_version)
s3_client.copy(src, bucket, dst)
slack_token = os.environ.get("SLACK_API_TOKEN")
if not slack_token:
sys.exit(0)
attachment_text = tag_name + " has been released!"
s3_urls = ["https://{}/{}".format(bucket, a.format("dcos-" + dcos_version)) for a in artifacts]
try:
resp = requests.post(
"https://mesosphere.slack.com/services/hooks/jenkins-ci?token=" + slack_token,
json={
"channel": "#dcos-cli-ci",
"color": "good",
"attachments": [
{
"color": "good",
"title": "dcos-core-cli",
"text": "\n".join([attachment_text + " :tada:"] + s3_urls),
"fallback": "[dcos-core-cli] " + attachment_text
}
]
}, timeout=30)
if resp.status_code != 200:
raise Exception("received {} status response: {}".format(resp.status_code, resp.text))
except Exception as e:
print("Couldn't post Slack notification:\n {}".format(e))