github.com/openshift-online/ocm-sdk-go@v0.1.473/hack/update-model.sh (about) 1 #!/bin/bash -e 2 3 # ============================================================================== 4 # Script: update-model.sh 5 # 6 # This script ensures that all the `ocm-api-model` submodules used across the 7 # project are updated to the latest version or pinned to a specific commit SHA. 8 # 9 # The OCM SDK can be generated simply by running the following after all changes have been made: 10 # 11 # ./hack/update-model.sh 12 # make update 13 # 14 # USAGE: 15 # ./update-model.sh [COMMIT_SHA] 16 # 17 # ARGUMENTS: 18 # COMMIT_SHA (optional) - If provided, all listed modules will be pinned to 19 # this specific commit instead of updating to latest. 20 # 21 # EXAMPLES: 22 # ./update-model.sh 23 # → Updates all modules to their latest versions. 24 # 25 # ./update-model.sh f67fb59980981bdc81d95d1379a82da5bcec57bf 26 # → Pins all modules to the specified commit SHA. 27 # 28 # ============================================================================== 29 30 # Optional commit SHA 31 COMMIT_SHA="$1" 32 33 # List of go.mod directories 34 MODULE_DIRS=( 35 "./metamodel_generator" 36 "./examples" 37 "." 38 ) 39 40 # The modules to update 41 MODULES=( 42 "github.com/openshift-online/ocm-api-model/model" 43 "github.com/openshift-online/ocm-api-model/clientapi" 44 ) 45 46 echo "Updating Go modules..." 47 if [ -n "$COMMIT_SHA" ]; then 48 echo "Using specific commit SHA: $COMMIT_SHA" 49 fi 50 51 for dir in "${MODULE_DIRS[@]}"; do 52 echo "Updating in directory: $dir" 53 pushd "$dir" > /dev/null || { 54 echo "Failed to enter $dir" 55 continue 56 } 57 58 for mod in "${MODULES[@]}"; do 59 if [ -n "$COMMIT_SHA" ]; then 60 echo " - Pinning $mod to $COMMIT_SHA" 61 go get "${mod}@${COMMIT_SHA}" 62 else 63 echo " - Updating $mod to latest" 64 go get -u "$mod" 65 fi 66 done 67 68 echo " - Tidying up module" 69 go mod tidy 70 71 popd > /dev/null 72 done 73 74 echo "Done."