Skip to content

Commit 53b1ebd

Browse files
authored
Add automation for release (#82)
* wip * Update module minor version to 22 * add publish script * remove us gov cloud and remove aws-vault * cr feedback * make sure we use the minor version for tagging * small NIT * Update module version to 2.22.0 * make last changes
1 parent f2d78b3 commit 53b1ebd

File tree

1 file changed

+102
-0
lines changed

1 file changed

+102
-0
lines changed

scripts/publish_prod.sh

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
#!/bin/bash
2+
3+
# Use with `aws-vault exec <PROFILE> -- ./publish_prod.sh <DESIRED_NEW_VERSION>
4+
5+
set -e
6+
7+
BRANCH=$(git rev-parse --abbrev-ref HEAD)
8+
echo $BRANCH
9+
10+
if [ $BRANCH != "master" ]; then
11+
echo "Not on master, aborting"
12+
exit 1
13+
fi
14+
15+
if [ -z "$AWS_ACCESS_KEY_ID" ]; then
16+
echo 'AWS_ACCESS_KEY_ID not set. Are you using aws-vault?'
17+
exit 1
18+
fi
19+
20+
if [ -z "$AWS_SECRET_ACCESS_KEY" ]; then
21+
echo 'AWS_SECRET_ACCESS_KEY not set. Are you using aws-vault?'
22+
exit 1
23+
fi
24+
25+
if [ -z "$AWS_SESSION_TOKEN" ]; then
26+
echo 'AWS_SESSION_TOKEN not set. Are you using aws-vault?'
27+
exit 1
28+
fi
29+
30+
if [ -z "$1" ]; then
31+
echo "Must specify a desired version number"
32+
exit 1
33+
elif [[ ! $1 =~ [0-9]+\.[0-9]+\.[0-9]+ ]]; then
34+
echo "Must use a semantic version, e.g., 3.1.4"
35+
exit 1
36+
else
37+
NEW_VERSION=$1
38+
fi
39+
40+
echo 'Checking AWS Regions'
41+
./scripts/list_layers.sh
42+
43+
read -p "Do the list look good? (y/n) " -n 1 -r
44+
echo
45+
if [[ ! $REPLY =~ ^[Yy]$ ]]
46+
then
47+
[[ "$0" = "$BASH_SOURCE" ]] && exit 1 || return 1
48+
fi
49+
50+
VERSION_LINE=$(sed -E -n 's/\"(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\"/"\1.\2.\3"/p' ./datadog_lambda/__init__.py)
51+
CURRENT_VERSION=$(echo "$VERSION_LINE" | cut -d '"' -f 2)
52+
53+
read -p "Ready to publish layers and update the version from $CURRENT_VERSION to $NEW_VERSION? (y/n)" -n 1 -r
54+
echo
55+
if [[ ! $REPLY =~ ^[Yy]$ ]]
56+
then
57+
[[ "$0" = "$BASH_SOURCE" ]] && exit 1 || return 1
58+
fi
59+
60+
echo ""
61+
echo "Replacing __version__ in ./datadog_lambda/__init__.py"
62+
echo ""
63+
sed -i "" -E "s/\"(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\"/\"$NEW_VERSION\"/" ./datadog_lambda/__init__.py
64+
65+
git commit ./datadog_lambda/__init__.py -m "Update module version to ${NEW_VERSION}"
66+
67+
echo ""
68+
echo "Building layers..."
69+
./scripts/build_layers.sh
70+
71+
echo ""
72+
echo "Publishing layers to AWS regions..."
73+
./scripts/publish_layers.sh
74+
75+
echo ""
76+
echo 'Pushing updates to github'
77+
MINOR_VERSION=$(echo $NEW_VERSION | cut -d '.' -f 2)
78+
git push origin master
79+
git push origin "refs/tags/v$MINOR_VERSION"
80+
81+
82+
echo 'Checking AWS Regions Again...'
83+
./scripts/list_layers.sh
84+
85+
86+
read -p "Do regions look good? Ready to publish $NEW_VERSION to Pypi? (y/n)" -n 1 -r
87+
echo
88+
if [[ ! $REPLY =~ ^[Yy]$ ]]
89+
then
90+
[[ "$0" = "$BASH_SOURCE" ]] && exit 1 || return 1
91+
fi
92+
echo ""
93+
echo "Publishing to https://pypi.org/project/datadog-lambda/"
94+
./scripts/pypi.sh
95+
96+
echo ""
97+
echo "Now create a new release with the tag v${MINOR_VERSION} created"
98+
echo "https://github.com/DataDog/datadog-lambda-python/releases/new"
99+
echo ""
100+
echo "Then publish a new serverless-plugin-datadog version with the new layer versions!"
101+
echo ""
102+

0 commit comments

Comments
 (0)