Skip to content

Commit 34f9689

Browse files
chore(go): update release script (#1676)
1 parent e2fb76c commit 34f9689

File tree

3 files changed

+26
-15
lines changed

3 files changed

+26
-15
lines changed

AwsCryptographicMaterialProviders/runtimes/go/ImplementationFromDafny-go/go.mod

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@ require (
3434
)
3535

3636
replace (
37-
github.com/aws/aws-cryptographic-material-providers-library/releases/go/dynamodb v0.0.0 => ../../../../ComAmazonawsDynamodb/runtimes/go/ImplementationFromDafny-go/
38-
github.com/aws/aws-cryptographic-material-providers-library/releases/go/kms v0.0.0 => ../../../../ComAmazonawsKms/runtimes/go/ImplementationFromDafny-go/
39-
github.com/aws/aws-cryptographic-material-providers-library/releases/go/primitives v0.0.0 => ../../../../AwsCryptographyPrimitives/runtimes/go/ImplementationFromDafny-go/
37+
github.com/aws/aws-cryptographic-material-providers-library/releases/go/dynamodb => ../../../../ComAmazonawsDynamodb/runtimes/go/ImplementationFromDafny-go/
38+
github.com/aws/aws-cryptographic-material-providers-library/releases/go/kms => ../../../../ComAmazonawsKms/runtimes/go/ImplementationFromDafny-go/
39+
github.com/aws/aws-cryptographic-material-providers-library/releases/go/primitives => ../../../../AwsCryptographyPrimitives/runtimes/go/ImplementationFromDafny-go/
4040

4141
)
4242

AwsCryptographicMaterialProviders/runtimes/go/TestsFromDafny-go/go.mod

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@ module github.com/aws/aws-cryptographic-material-providers-library/releases/go/m
22

33
go 1.23.0
44

5-
replace github.com/aws/aws-cryptographic-material-providers-library/releases/go/mpl v0.0.0 => ../ImplementationFromDafny-go
5+
replace github.com/aws/aws-cryptographic-material-providers-library/releases/go/mpl => ../ImplementationFromDafny-go
66

77
replace (
8-
github.com/aws/aws-cryptographic-material-providers-library/releases/go/dynamodb v0.0.0 => ../../../../ComAmazonawsDynamodb/runtimes/go/ImplementationFromDafny-go/
9-
github.com/aws/aws-cryptographic-material-providers-library/releases/go/kms v0.0.0 => ../../../../ComAmazonawsKms/runtimes/go/ImplementationFromDafny-go/
10-
github.com/aws/aws-cryptographic-material-providers-library/releases/go/primitives v0.0.0 => ../../../../AwsCryptographyPrimitives/runtimes/go/ImplementationFromDafny-go/
8+
github.com/aws/aws-cryptographic-material-providers-library/releases/go/dynamodb => ../../../../ComAmazonawsDynamodb/runtimes/go/ImplementationFromDafny-go/
9+
github.com/aws/aws-cryptographic-material-providers-library/releases/go/kms => ../../../../ComAmazonawsKms/runtimes/go/ImplementationFromDafny-go/
10+
github.com/aws/aws-cryptographic-material-providers-library/releases/go/primitives => ../../../../AwsCryptographyPrimitives/runtimes/go/ImplementationFromDafny-go/
1111

1212
)
1313

scripts/go-release-automation.sh

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ get_release_dir_name() {
3131
run_release_script() {
3232
PROJECT_NAME=$1
3333
VERSION=$2
34+
ROOT_DIR="$(git rev-parse --show-toplevel)" || { echo "Error: root directory not found"; exit 1; }
3435

3536
echo "Starting Go release script for $PROJECT_NAME $VERSION"
3637

@@ -71,7 +72,8 @@ run_release_script() {
7172
# Replacement directives are removed to get package from go pkg instead of local copy
7273
# We need to copy `go.mod` otherwise without it this script will not work in the first release because all the go tools used in this script works only when there is a `go.mod` in the directory. Removing replacement directives helps in automating copying of `go.mod`.
7374
echo "Removing all replace directives from go.mod..."
74-
go mod edit -json | jq -r '.Replace[].Old.Path' | xargs -n1 go mod edit -dropreplace
75+
# This expects the replaced package does not have a version
76+
go mod edit -json | jq -r '.Replace[].Old.Path' | xargs -n1 go mod edit -dropreplace
7577

7678
# Get the mapped release directory name
7779
RELEASE_DIR_NAME=$(get_release_dir_name "$PROJECT_NAME")
@@ -83,7 +85,7 @@ run_release_script() {
8385
# ImplementationFromDafny.go: This file is for devlopment. Users is expected use API(s) from `*/api_client.go`
8486
# ImplementationFromDafny-go.dtr: This is the dafny translation record only needed for code generation
8587
# go.sum: This files will be updated by go mod tidy
86-
rsync -av --exclude="ImplementationFromDafny.go" --exclude="ImplementationFromDafny-go.dtr" --exclude="go.sum" ./ "$(git rev-parse --show-toplevel)/releases/go/$RELEASE_DIR_NAME/"
88+
rsync -av --exclude="ImplementationFromDafny.go" --exclude="ImplementationFromDafny-go.dtr" --exclude="go.sum" ./ "$ROOT_DIR/releases/go/$RELEASE_DIR_NAME/"
8789

8890
case "$PROJECT_NAME" in
8991
"AwsEncryptionSDK"|"DynamoDbEncryption") copy_examples ;;
@@ -92,29 +94,37 @@ run_release_script() {
9294
# Run Go tools in releases directory
9395
echo "Running Go tools in releases/go/$RELEASE_DIR_NAME..."
9496

95-
cd "$(git rev-parse --show-toplevel)/releases/go/$RELEASE_DIR_NAME/" || { echo "Error: releases directory not found"; exit 1; }
97+
cd "$ROOT_DIR/releases/go/$RELEASE_DIR_NAME/" || { echo "Error: releases directory not found"; exit 1; }
9698

9799
run_go_tools
98100

99101
case "$PROJECT_NAME" in
100102
"AwsEncryptionSDK"|"DynamoDbEncryption") test_examples ;;
101103
esac
102104

105+
make -C "$ROOT_DIR" setup_prettier
106+
make -C "$ROOT_DIR" format_java_misc
107+
108+
if grep -q "replace" go.mod; then
109+
echo "Error: Found replace directives in go.mod files. Is this expected?"
110+
exit 1
111+
fi
112+
103113
# Prepare for commit
104114
echo "creating a branch..."
105115

106116
git checkout -b "golang-release-staging-branch/$RELEASE_DIR_NAME/${VERSION}"
107117
git add *
108118

109-
git commit -m "Release $RELEASE_DIR_NAME Go module ${VERSION}"
119+
git commit -m "chore(go): Release $RELEASE_DIR_NAME Go module ${VERSION}"
110120
git push origin "golang-release-staging-branch/$RELEASE_DIR_NAME/${VERSION}"
111121
}
112122

113123
copy_examples() {
114124
local source_dir replace_pkg
115125
case "$PROJECT_NAME" in
116126
"AwsEncryptionSDK")
117-
source_dir="$PROJECT_NAME/runtimes/go/ImplementationFromDafny-go/examples"
127+
source_dir="$PROJECT_NAME/runtimes/go/examples"
118128
replace_pkg="github.com/aws/aws-encryption-sdk/releases/go/encryption-sdk=../"
119129
;;
120130
"DynamoDbEncryption")
@@ -124,15 +134,16 @@ copy_examples() {
124134
*) return ;;
125135
esac
126136

127-
cd "$(git rev-parse --show-toplevel)/$source_dir"
137+
cd "$ROOT_DIR/$source_dir"
138+
run_go_tools
128139
echo "Removing all replace directives from go.mod and only adding replacement for ESDK/DB-ESDK"
129140
go mod edit -json | jq -r '.Replace[].Old.Path' | xargs -n1 go mod edit -dropreplace
130141
go mod edit -replace="$replace_pkg"
131-
rsync -av --exclude="go.sum" ./ "$(git rev-parse --show-toplevel)/releases/go/$RELEASE_DIR_NAME/examples"
142+
rsync -av --exclude="go.sum" ./ "$ROOT_DIR/releases/go/$RELEASE_DIR_NAME/examples"
132143
}
133144

134145
test_examples() {
135-
cd "$(git rev-parse --show-toplevel)/releases/go/$RELEASE_DIR_NAME/examples" || { echo "Error: examples directory not found"; exit 1; }
146+
cd "$ROOT_DIR/releases/go/$RELEASE_DIR_NAME/examples" || { echo "Error: examples directory not found"; exit 1; }
136147
run_go_tools
137148
go run main.go
138149
}

0 commit comments

Comments
 (0)