Skip to content

Commit

Permalink
chore(release): freeze repos files
Browse files Browse the repository at this point in the history
Signed-off-by: Shumpei Wakabayashi <shumpei.wakabayashi@tier4.jp>
  • Loading branch information
shmpwk committed Oct 13, 2022
1 parent 9d6e2ea commit c81139e
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 7 deletions.
12 changes: 6 additions & 6 deletions autoware.repos
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ repositories:
core/autoware_adapi_msgs:
type: git
url: https://github.com/autowarefoundation/autoware_adapi_msgs.git
version: 6ff9b7b22d9ed7ac4f46b05e4a3e9f6dc007af51
version: c9a964e24af0c6edc050d2b2ee01e6e110cbfdbd
core/autoware_common:
type: git
url: https://github.com/autowarefoundation/autoware_common.git
version: ef386c9d9d705ea31eb311d60deb5e39ccae00ec
version: ba4d3cc3f729ebedc16aba7d745bcc54fd935e61
core/autoware.core:
type: git
url: https://github.com/autowarefoundation/autoware.core.git
version: 4df187097af1aecbfaedb1ac32142e4ddc785440
version: 062fdea5059eaf196a2d0fd531e4433efd1502e4
core/external/autoware_auto_msgs: # TODO(mfc): Remove when autoware_msgs is merged
type: git
url: https://github.com/tier4/autoware_auto_msgs.git
Expand All @@ -24,11 +24,11 @@ repositories:
universe/autoware.universe:
type: git
url: https://github.com/autowarefoundation/autoware.universe.git
version: c7698fc5d6b54932816077539b01c224e60861c2
version: 4be6931c811422f16d95c1460c046f2540d1f628
universe/external/tier4_ad_api_adaptor: # TODO(TIER IV): Improve design/code and transfer to AWF
type: git
url: https://github.com/tier4/tier4_ad_api_adaptor.git
version: 15c7aa413ba9aa3abd8a978dc98acbb83e6ed1cd
version: 050fa514074be9e55a772ff9776cea5cfa04a403
universe/external/tier4_autoware_msgs:
type: git
url: https://github.com/tier4/tier4_autoware_msgs.git
Expand Down Expand Up @@ -57,7 +57,7 @@ repositories:
launcher/autoware_launch:
type: git
url: https://github.com/autowarefoundation/autoware_launch.git
version: c999488b2fb753939b1af3e10c148b84079a9db0
version: 5a770252eaa4a50144fbdf8ce98bd02a7ce4e180
# sensor_component
sensor_component/external/sensor_component_description:
type: git
Expand Down
67 changes: 67 additions & 0 deletions freeze-repos.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
#!/usr/bin/env bash

set -euC

function update_repository_version {
local -r repos_file="$1"
local -r repository="$2"

url=$(yq ".repositories[] | select(key == \"$repository\").url" "$repos_file")
version=$(yq ".repositories[] | select(key == \"$repository\").version" "$repos_file")

tag_hash=$(git ls-remote --tags "$url" "$version" | awk '{print $1}')
branch_hash=$(git ls-remote --heads "$url" "$version" | awk '{print $1}')

if [ -n "$tag_hash" ]; then
new_version="$tag_hash"
elif [ -n "$branch_hash" ]; then
new_version="$branch_hash"
else
new_version="$version"
fi

echo "$repository: $new_version"
yq --inplace ".repositories.\"$repository\".version = \"$new_version\"" "$repos_file"
}

function get_repositories_in_repos() {
local -r repos_file="$1"

yq '.repositories' "$repos_file" | grep -E "^[a-zA-Z]+" | sed "s/:.*//g"
}

function freeze_repos_file {
local -r repos_file="$1"

local -r repositories=$(get_repositories_in_repos "$repos_file")
if [ -z "$repositories" ]; then
echo "no repository found"
exit 1
fi

for repository in $repositories; do
update_repository_version "$repos_file" "$repository"
done
}

function freeze_all_repos_files {
for repos_file in *.repos; do
freeze_repos_file "$repos_file"
done
}

function main {
if ! (command -v yq >/dev/null 2>&1); then
echo "yq not found"
exit 1
fi

freeze_all_repos_files

git add "*.repos"
git commit -s -m "chore(release): freeze repos files"
}

if [[ ${BASH_SOURCE[0]} == "${0}" ]]; then
main "$@"
fi
2 changes: 1 addition & 1 deletion simulator.repos
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ repositories:
simulator/scenario_simulator:
type: git
url: https://github.com/tier4/scenario_simulator_v2.git
version: d1bb941a4a46d8210ceb4a740042269585b2eaa3
version: 724e9130496494a303fc75af7da4f006d83f4294

0 comments on commit c81139e

Please sign in to comment.