|
|
|
@ -6,6 +6,7 @@ cd "$ROOT_DIR"
|
|
|
|
|
|
|
|
|
|
|
|
ABOUT_FILE="$ROOT_DIR/iti/__about__.py"
|
|
|
|
ABOUT_FILE="$ROOT_DIR/iti/__about__.py"
|
|
|
|
COPIER_FILE="$ROOT_DIR/copier.yml"
|
|
|
|
COPIER_FILE="$ROOT_DIR/copier.yml"
|
|
|
|
|
|
|
|
COPIER_TEMPLATE_FILE="$ROOT_DIR/copier-template/pyproject.toml.jinja"
|
|
|
|
README_FILE="$ROOT_DIR/README.md"
|
|
|
|
README_FILE="$ROOT_DIR/README.md"
|
|
|
|
|
|
|
|
|
|
|
|
die() {
|
|
|
|
die() {
|
|
|
|
@ -83,22 +84,20 @@ read_current_version() {
|
|
|
|
printf '%s\n' "$current_version"
|
|
|
|
printf '%s\n' "$current_version"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
replace_first_exact_line() {
|
|
|
|
replace_first_line_with_prefix() {
|
|
|
|
file=$1
|
|
|
|
file=$1
|
|
|
|
old_line=$2
|
|
|
|
prefix=$2
|
|
|
|
new_line=$3
|
|
|
|
new_line=$3
|
|
|
|
tmp_file=$(mktemp)
|
|
|
|
tmp_file=$(mktemp)
|
|
|
|
|
|
|
|
|
|
|
|
if awk -v old="$old_line" -v new="$new_line" '
|
|
|
|
if awk -v prefix="$prefix" -v new="$new_line" '
|
|
|
|
BEGIN { done = 0 }
|
|
|
|
BEGIN { done = 0 }
|
|
|
|
{
|
|
|
|
index($0, prefix) == 1 && !done {
|
|
|
|
if (!done && $0 == old) {
|
|
|
|
print new
|
|
|
|
print new
|
|
|
|
done = 1
|
|
|
|
done = 1
|
|
|
|
next
|
|
|
|
} else {
|
|
|
|
|
|
|
|
print
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
{ print }
|
|
|
|
END { if (!done) exit 1 }
|
|
|
|
END { if (!done) exit 1 }
|
|
|
|
' "$file" >"$tmp_file"; then
|
|
|
|
' "$file" >"$tmp_file"; then
|
|
|
|
mv "$tmp_file" "$file"
|
|
|
|
mv "$tmp_file" "$file"
|
|
|
|
@ -108,42 +107,61 @@ replace_first_exact_line() {
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
write_about_version() {
|
|
|
|
replace_first_line_in_section_with_prefix() {
|
|
|
|
current_version=$1
|
|
|
|
file=$1
|
|
|
|
target_version=$2
|
|
|
|
section_header=$2
|
|
|
|
replace_first_exact_line "$ABOUT_FILE" "__version__ = \"$current_version\"" "__version__ = \"$target_version\""
|
|
|
|
prefix=$3
|
|
|
|
}
|
|
|
|
new_line=$4
|
|
|
|
|
|
|
|
|
|
|
|
write_copier_tag() {
|
|
|
|
|
|
|
|
current_version=$1
|
|
|
|
|
|
|
|
target_version=$2
|
|
|
|
|
|
|
|
tmp_file=$(mktemp)
|
|
|
|
tmp_file=$(mktemp)
|
|
|
|
|
|
|
|
|
|
|
|
if awk -v current="$current_version" -v target="$target_version" '
|
|
|
|
if awk -v section="$section_header" -v prefix="$prefix" -v new="$new_line" '
|
|
|
|
BEGIN { in_framework = 0; done = 0 }
|
|
|
|
BEGIN { in_section = 0; done = 0 }
|
|
|
|
/^framework_tag:[[:space:]]*$/ { in_framework = 1; print; next }
|
|
|
|
$0 == section { in_section = 1; print; next }
|
|
|
|
in_framework && /^[^[:space:]]/ { in_framework = 0 }
|
|
|
|
in_section && /^[^[:space:]]/ { in_section = 0 }
|
|
|
|
in_framework && !done && $0 == " default: v" current {
|
|
|
|
in_section && !done && index($0, prefix) == 1 {
|
|
|
|
print " default: v" target
|
|
|
|
print new
|
|
|
|
done = 1
|
|
|
|
done = 1
|
|
|
|
next
|
|
|
|
next
|
|
|
|
}
|
|
|
|
}
|
|
|
|
{ print }
|
|
|
|
{ print }
|
|
|
|
END { if (!done) exit 1 }
|
|
|
|
END { if (!done) exit 1 }
|
|
|
|
' "$COPIER_FILE" >"$tmp_file"; then
|
|
|
|
' "$file" >"$tmp_file"; then
|
|
|
|
mv "$tmp_file" "$COPIER_FILE"
|
|
|
|
mv "$tmp_file" "$file"
|
|
|
|
else
|
|
|
|
else
|
|
|
|
rm -f "$tmp_file"
|
|
|
|
rm -f "$tmp_file"
|
|
|
|
die "framework_tag default not updated in $COPIER_FILE"
|
|
|
|
die "line not updated in $file"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
write_readme_tag() {
|
|
|
|
write_about_version() {
|
|
|
|
current_version=$1
|
|
|
|
target_version=$1
|
|
|
|
target_version=$2
|
|
|
|
replace_first_line_with_prefix "$ABOUT_FILE" "__version__ = " "__version__ = \"$target_version\""
|
|
|
|
old_line=' "iti-flask @ git+https://git.noahlan.cn/iti-framework/iTi-Flask.git@v'"$current_version"'",'
|
|
|
|
}
|
|
|
|
new_line=' "iti-flask @ git+https://git.noahlan.cn/iti-framework/iTi-Flask.git@v'"$target_version"'",'
|
|
|
|
|
|
|
|
replace_first_exact_line "$README_FILE" "$old_line" "$new_line"
|
|
|
|
write_copier_framework_tag() {
|
|
|
|
|
|
|
|
target_version=$1
|
|
|
|
|
|
|
|
replace_first_line_in_section_with_prefix "$COPIER_FILE" "framework_tag:" " default: v" " default: v$target_version"
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
write_copier_system_tag() {
|
|
|
|
|
|
|
|
target_version=$1
|
|
|
|
|
|
|
|
replace_first_line_in_section_with_prefix "$COPIER_FILE" "system_tag:" " default: v" " default: v$target_version"
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
write_copier_template_version() {
|
|
|
|
|
|
|
|
target_version=$1
|
|
|
|
|
|
|
|
replace_first_line_with_prefix "$COPIER_TEMPLATE_FILE" "version = " "version = \"$target_version\""
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
write_readme_dependency_tag() {
|
|
|
|
|
|
|
|
target_version=$1
|
|
|
|
|
|
|
|
replace_first_line_with_prefix "$README_FILE" ' "iti-flask @ git+https://git.noahlan.cn/iti-framework/iTi-Flask.git@v' ' "iti-flask @ git+https://git.noahlan.cn/iti-framework/iTi-Flask.git@v'"$target_version"'",'
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
write_readme_release_examples() {
|
|
|
|
|
|
|
|
target_version=$1
|
|
|
|
|
|
|
|
replace_first_line_with_prefix "$README_FILE" './iti.sh release v' "./iti.sh release v$target_version"
|
|
|
|
|
|
|
|
replace_first_line_with_prefix "$README_FILE" 'iti.cmd release v' "iti.cmd release v$target_version"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ensure_clean_tree() {
|
|
|
|
ensure_clean_tree() {
|
|
|
|
@ -190,11 +208,14 @@ main() {
|
|
|
|
ensure_tag_absent "$target_tag"
|
|
|
|
ensure_tag_absent "$target_tag"
|
|
|
|
uv run pytest -q
|
|
|
|
uv run pytest -q
|
|
|
|
|
|
|
|
|
|
|
|
write_about_version "$current_version" "$target_version"
|
|
|
|
write_about_version "$target_version"
|
|
|
|
write_copier_tag "$current_version" "$target_version"
|
|
|
|
write_copier_framework_tag "$target_version"
|
|
|
|
write_readme_tag "$current_version" "$target_version"
|
|
|
|
write_copier_system_tag "$target_version"
|
|
|
|
|
|
|
|
write_copier_template_version "$target_version"
|
|
|
|
|
|
|
|
write_readme_dependency_tag "$target_version"
|
|
|
|
|
|
|
|
write_readme_release_examples "$target_version"
|
|
|
|
|
|
|
|
|
|
|
|
git add iti/__about__.py copier.yml README.md
|
|
|
|
git add iti/__about__.py copier.yml copier-template/pyproject.toml.jinja README.md
|
|
|
|
git commit -m "chore: release $target_tag"
|
|
|
|
git commit -m "chore: release $target_tag"
|
|
|
|
git tag -a "$target_tag" -m "release $target_tag"
|
|
|
|
git tag -a "$target_tag" -m "release $target_tag"
|
|
|
|
git push origin "$branch" "$target_tag"
|
|
|
|
git push origin "$branch" "$target_tag"
|
|
|
|
|