Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
auricom committed Sep 20, 2024
1 parent 5b38212 commit 0c709b9
Show file tree
Hide file tree
Showing 5 changed files with 424 additions and 1 deletion.
61 changes: 61 additions & 0 deletions .github/scripts/update-go-dependencies.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
#!/bin/bash

set -oue pipefail

COSMOSSDK_BRANCH=${COSMOSSDK_BRANCH:-refs/heads/release/v0.50.x}

# Function to get the latest commit SHA for a given repo and branch
get_latest_commit() {
local repo=$1
local branch=$2
git ls-remote "https://github.com/${repo}.git" "${branch}" | cut -f1
}

# Function to get pseudo-version from commit SHA
get_pseudo_version() {
local repo=$1
local commit_sha=$2

pseudo_version=$(go list -m -f '{{.Version}}' $module@$commit_sha)

echo "${pseudo_version}"
}

# Extract module paths and versions from go.mod on current folder
modules=$(go mod edit --json | jq -r '.Require[] | select(.Path | contains("/")) | .Path')

latest_commit_main=$(get_latest_commit "cosmos/cosmos-sdk" "main")
echo "cosmos/cosmos-sdk main latest_commit: $latest_commit_main"
latest_commit_branch=$(get_latest_commit "cosmos/cosmos-sdk" "$COSMOSSDK_BRANCH")
echo "cosmos/cosmos-sdk $COSMOSSDK_BRANCH latest_commit: $latest_commit_branch"

# Version override logic
for module in $modules; do

echo "module: $module"

if [[ $module =~ "cosmossdk.io" ]]; then
# modules that need to follow HEAD on main
if [[ $module =~ "log" ]] || [[ $module =~ "math" ]] || [[ $module =~ "depinject" ]] || [[ $module =~ "core/testing" ]] || [[ $module =~ "x/accounts" ]] | [[ $module =~ "x/authz" ]]; then
pseudo_version=$(get_pseudo_version "cosmos/cosmos-sdk" $latest_commit_main)
echo "Updating $module to pseudo-version $pseudo_version"
go mod edit -replace=$module=$module@$pseudo_version
go mod download $module@$pseudo_version
else
# modules that need to follow HEAD on release branch
pseudo_version=$(get_pseudo_version "cosmos/cosmos-sdk" $latest_commit_branch)
echo "Updating $module to pseudo-version $pseudo_version"
go mod edit -replace=$module=$module@$pseudo_version
go mod download $module@$pseudo_version
fi
elif [[ $module == "github.com/cosmos/cosmos-sdk" ]]; then
# modules that need to follow HEAD on release branch
pseudo_version=$(get_pseudo_version "cosmos/cosmos-sdk" $latest_commit_branch)
echo "Updating $module to pseudo-version $pseudo_version"
go mod edit -replace=$module=$module@$pseudo_version
go mod download $module@$pseudo_version
fi
done

go mod verify
go mod tidy
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit 0c709b9

Please sign in to comment.