Skip to content

Commit caf1243

Browse files
committed
Improve publish script
1 parent feb712f commit caf1243

File tree

1 file changed

+50
-35
lines changed

1 file changed

+50
-35
lines changed

scripts/publish_prod.sh

Lines changed: 50 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -4,29 +4,23 @@
44

55
set -e
66

7+
# Ensure on main, and pull the latest
78
BRANCH=$(git rev-parse --abbrev-ref HEAD)
8-
echo $BRANCH
9-
109
if [ $BRANCH != "main" ]; then
1110
echo "Not on main, aborting"
1211
exit 1
12+
else
13+
echo "Updating main"
14+
git pull origin main
1315
fi
1416

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?'
17+
# # Ensure no uncommitted changes
18+
if [ -n "$(git status --porcelain)" ]; then
19+
echo "Detected uncommitted changes, aborting"
2720
exit 1
2821
fi
2922

23+
# Read the new version
3024
if [ -z "$1" ]; then
3125
echo "Must specify a desired version number"
3226
exit 1
@@ -37,10 +31,27 @@ else
3731
NEW_VERSION=$1
3832
fi
3933

40-
echo 'Checking AWS Regions'
41-
./scripts/list_layers.sh
34+
# Ensure AWS access before proceeding
35+
saml2aws login -a govcloud-us1-fed-human-engineering
36+
AWS_PROFILE=govcloud-us1-fed-human-engineering aws sts get-caller-identity
37+
aws-vault exec prod-engineering -- aws sts get-caller-identity
4238

43-
read -p "Do the list look good? (y/n) " -n 1 -r
39+
# Ensure pypi registry access
40+
read -p "Do you have the PyPi login credentials for datadog account (y/n)? " -n 1 -r
41+
echo
42+
if [[ ! $REPLY =~ ^[Yy]$ ]]
43+
then
44+
[[ "$0" = "$BASH_SOURCE" ]] && exit 1 || return 1
45+
fi
46+
47+
echo 'Checking existing layers in commercial AWS regions'
48+
aws-vault exec prod-engineering -- ./scripts/list_layers.sh
49+
50+
echo 'Checking existing layers in GovCloud AWS regions'
51+
saml2aws login -a govcloud-us1-fed-human-engineering
52+
AWS_PROFILE=govcloud-us1-fed-human-engineering ./scripts/list_layers.sh
53+
54+
read -p "Do the layer lists look good? Proceed publishing the new version (y/n)? " -n 1 -r
4455
echo
4556
if [[ ! $REPLY =~ ^[Yy]$ ]]
4657
then
@@ -69,39 +80,43 @@ echo "Building layers..."
6980
./scripts/build_layers.sh
7081

7182
echo
72-
echo "Signing layers..."
73-
./scripts/sign_layers.sh prod
83+
echo "Signing layers for commercial AWS regions"
84+
aws-vault exec prod-engineering -- ./scripts/sign_layers.sh prod
7485

7586
echo
76-
echo "Publishing layers to AWS regions..."
77-
./scripts/publish_layers.sh
87+
echo "Publishing layers to commercial AWS regions"
88+
aws-vault exec prod-engineering -- ./scripts/publish_layers.sh
7889

79-
echo
80-
echo 'Pushing updates to github'
81-
MINOR_VERSION=$(echo $NEW_VERSION | cut -d '.' -f 2)
82-
git push origin main
83-
git tag "v$MINOR_VERSION"
84-
git push origin "refs/tags/v$MINOR_VERSION"
90+
echo "Publishing layers to GovCloud AWS regions"
91+
saml2aws login -a govcloud-us1-fed-human-engineering
92+
AWS_PROFILE=govcloud-us1-fed-human-engineering ./scripts/publish_layers.sh
8593

94+
echo 'Checking published layers in commercial AWS regions'
95+
aws-vault exec prod-engineering -- ./scripts/list_layers.sh
8696

87-
echo 'Checking AWS Regions Again...'
88-
./scripts/list_layers.sh
97+
echo 'Checking published layers in GovCloud AWS regions'
98+
saml2aws login -a govcloud-us1-fed-human-engineering
99+
AWS_PROFILE=govcloud-us1-fed-human-engineering ./scripts/list_layers.sh
89100

90101

91-
read -p "Do regions look good? Ready to publish $NEW_VERSION to Pypi? (y/n)" -n 1 -r
102+
read -p "Do the layer lists look good? Ready to publish $NEW_VERSION to Pypi? (y/n)" -n 1 -r
92103
echo
93104
if [[ ! $REPLY =~ ^[Yy]$ ]]
94105
then
95106
[[ "$0" = "$BASH_SOURCE" ]] && exit 1 || return 1
96107
fi
108+
97109
echo
98110
echo "Publishing to https://pypi.org/project/datadog-lambda/"
99111
./scripts/pypi.sh
100112

101113
echo
102-
echo "Now create a new release with the tag v${MINOR_VERSION} created"
103-
echo "https://github.com/DataDog/datadog-lambda-python/releases/new"
104-
echo
105-
echo "Then publish a new serverless-plugin-datadog version with the new layer versions!"
106-
echo
114+
echo 'Publishing updates to github'
115+
MINOR_VERSION=$(echo $NEW_VERSION | cut -d '.' -f 2)
116+
git push origin main
117+
git tag "v$MINOR_VERSION"
118+
git push origin "refs/tags/v$MINOR_VERSION"
107119

120+
echo
121+
echo "Now create a new release with the tag v${MINOR_VERSION} created"
122+
echo "https://github.com/DataDog/datadog-lambda-python/releases/new?tag=v$MINOR_VERSION&title=v$MINOR_VERSION"

0 commit comments

Comments
 (0)