@@ -31,6 +31,7 @@ get_release_dir_name() {
3131run_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
113123copy_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
134145test_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