File tree Expand file tree Collapse file tree 1 file changed +19
-10
lines changed
Expand file tree Collapse file tree 1 file changed +19
-10
lines changed Original file line number Diff line number Diff line change @@ -26,24 +26,33 @@ LogshRun() { _dlm="####R#E#C#D#E#L#I#M#I#T#E#R####" && _all=$({ _out=$("$@") &&
2626__main__ () {
2727 cd " ${REPO_ROOT:? } " || return $? # cd repo root
2828
29+ git fetch --tags
30+
2931 trap " git switch -" EXIT
3032
31- latest_git_tag=$( git tag --sort v:refname | tail -n 1)
33+ latest_git_tag=$( git tag --sort= v:refname | grep -E " ^v[0-9]+ " | tail -n 1)
3234 latest_git_tag_commit=$( git rev-list -n 1 " ${latest_git_tag:? } " )
3335
3436 git switch --detach " ${latest_git_tag:? } "
3537 targets=$(
36- find " ${REPO_ROOT:? } " -name go.mod -print | # find go.mod
37- sed " s@${REPO_ROOT:? } /@@g" | # trim repo root path
38- grep -v " ^go\.mod$" | # ignore root go.mod
39- grep -v " ^tests/go\.mod$" | # ignore tests/go.mod
40- sed " s@/go\.mod@@g" | # trim go.mod for extract module dir
41- : || true
38+ find " ${REPO_ROOT:? } " -name go.mod -print | # find go.mod
39+ sed " s@${REPO_ROOT:? } /@@g; s@/*go\.mod@@g" | # trim repo root path
40+ grep -v " ^$" | # ignore root go.mod
41+ grep -v " ^tests$" | # ignore tests/go.mod
42+ cat || true
4243 )
4344 LogshInfo " $( printf " targets: %s" " ${targets:- none} " ) "
44- while read -r mod; do
45- git tag -a " ${mod:? } /${latest_git_tag:? } " -m " ${mod:? } /${latest_git_tag:? } " " ${latest_git_tag_commit:? } "
46- done <<< " ${targets:-}"
45+ if [ -n " ${targets:- } " ]; then
46+ while read -r mod; do
47+ mod_tag=" ${mod:? } /${latest_git_tag:? } "
48+ if git tag --sort=v:refname | grep -qE " ^${mod_tag:? } $" ; then
49+ LogshInfo " $( printf " tag already exists: %s" " ${mod_tag:? } " ) "
50+ continue
51+ fi
52+ git tag -a " ${mod_tag:? } " -m " ${mod_tag:? } " " ${latest_git_tag_commit:? } "
53+ done <<< " ${targets:?}"
54+ git push --tags
55+ fi
4756}
4857
4958__main__ " $@ "
You can’t perform that action at this time.
0 commit comments