@@ -9,8 +9,38 @@ if ! [[ "$0" =~ scripts/set_avalanchego_version.sh ]]; then
9
9
exit 255
10
10
fi
11
11
12
- # Load the avalanche version
13
- source ./scripts/versions.sh
12
+ # TODO(marun) Reduce duplication between this script and versions.sh. The
13
+ # call to curl to get the full module hash fails on darwin runners tasked
14
+ # with running the unit test suite, so it's not an option to just include
15
+ # this in version.sh without further work, and that call further depends on
16
+ # the module hash, which depends on getting the module details from go mod.
17
+
18
+ # Get version from go.mod
19
+ MODULE_DETAILS=" $( go list -m " github.com/ava-labs/avalanchego" 2> /dev/null) "
20
+
21
+ # Extract just the version part
22
+ AVALANCHE_VERSION=" $( echo " ${MODULE_DETAILS} " | awk ' {print $2}' ) "
23
+
24
+ # Check if it matches pseudo-version pattern:
25
+ # v*YYYYMMDDHHMMSS-abcdef123456
26
+ #
27
+ # If not, the value is assumed to represent a tag
28
+ if [[ " ${AVALANCHE_VERSION} " =~ ^v.* [0-9]{14}-[0-9a-f]{12}$ ]]; then
29
+ # Extract module hash from version
30
+ MODULE_HASH=" $( echo " ${AVALANCHE_VERSION} " | cut -d' -' -f3) "
31
+
32
+ # The first 8 chars of the hash is used as the tag of avalanchego images
33
+ AVALANCHE_VERSION=" ${MODULE_HASH:: 8} "
34
+
35
+ FULL_AVALANCHEGO_VERSION=" $( curl -s " https://api.github.com/repos/ava-labs/avalanchego/commits/${MODULE_HASH} " | grep ' "sha":' | head -n1 | cut -d' "' -f4) "
36
+ fi
37
+
38
+ # FULL_AVALANCHEGO_VERSION needs to either be a tag or the full SHA to
39
+ # be usable for custom github action references.
40
+ if [[ -z " ${FULL_AVALANCHEGO_VERSION:- } " ]]; then
41
+ # Assume AVALANCHEGO_VERSION is a tag.
42
+ FULL_AVALANCHEGO_VERSION=" ${AVALANCHE_VERSION} "
43
+ fi
14
44
15
45
# Ensure the monitoring version is the same as the avalanche version
16
46
CUSTOM_ACTION=" ava-labs/avalanchego/.github/actions/run-monitored-tmpnet-cmd"
0 commit comments