Skip to content

Commit

Permalink
[CI] Ensure auto update processes all files
Browse files Browse the repository at this point in the history
  • Loading branch information
chalin committed Dec 12, 2024
1 parent d3767a7 commit 8020015
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 23 deletions.
4 changes: 2 additions & 2 deletions content/en/docs/zero-code/java/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ aliases:
- /docs/languages/java/automatic_instrumentation
cascade:
vers:
instrumentation: 2.6.0
otel: 1.40.0
instrumentation: 2.10.0
otel: 1.45.0
---

Zero-code instrumentation with Java uses a Java agent JAR or Spring Boot
Expand Down
41 changes: 28 additions & 13 deletions scripts/auto-update/all-versions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,36 @@

function auto_update_versions() {
local cmd="./scripts/auto-update/version-in-file.sh"
local updates=(
"opentelemetry-collector-releases vers content/en/docs/collector/_index.md"
"opentelemetry-collector-releases collector_vers content/en/docs/security/_index.md"
"opentelemetry-java otel content/en/docs/languages/java/_index.md"
"opentelemetry-java otel content/en/docs/zero-code/java/_index.md"
"opentelemetry-java-instrumentation instrumentation content/en/docs/languages/java/_index.md"
"opentelemetry-java-instrumentation instrumentation content/en/docs/zero-code/java/_index.md"
"opentelemetry-java-contrib contrib content/en/docs/languages/java/_index.md"
"opentelemetry-specification spec scripts/content-modules/adjust-pages.pl .gitmodules"
"opentelemetry-proto otlp scripts/content-modules/adjust-pages.pl .gitmodules"
"semantic-conventions semconv scripts/content-modules/adjust-pages.pl .gitmodules"
"semantic-conventions-java semconv content/en/docs/languages/java/_index.md"
local repo_and_files_to_update=(

# Format of an entry is
# "repo-name regex file-name [regex file-name...]"

"opentelemetry-collector-releases
vers content/en/docs/collector/_index.md
collector_vers content/en/docs/security/_index.md"
"opentelemetry-java
otel content/en/docs/languages/java/_index.md
otel content/en/docs/zero-code/java/_index.md"
"opentelemetry-java-instrumentation
instrumentation content/en/docs/languages/java/_index.md
instrumentation content/en/docs/zero-code/java/_index.md"
"opentelemetry-java-contrib
contrib content/en/docs/languages/java/_index.md"
"opentelemetry-specification
spec scripts/content-modules/adjust-pages.pl
spec .gitmodules"
"opentelemetry-proto
otlp scripts/content-modules/adjust-pages.pl
otlp .gitmodules"
"semantic-conventions
semconv scripts/content-modules/adjust-pages.pl
semconv .gitmodules"
"semantic-conventions-java
semconv content/en/docs/languages/java/_index.md"
)

for args in "${updates[@]}"; do
for args in "${repo_and_files_to_update[@]}"; do
echo "> $cmd $args"
$cmd $args
echo
Expand Down
26 changes: 18 additions & 8 deletions scripts/auto-update/version-in-file.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,22 @@ else
shift
fi

repo=$1
variable_name=$2
file_names=("${@:3}") # remaining args

repo=$1; shift;
latest_version=$(gh api -q .tag_name "repos/open-telemetry/$repo/releases/latest")
latest_vers_no_v="${latest_version#v}" # Remove leading 'v'

echo "REPO: $repo"
echo "LATEST VERSION: $latest_version"

for file_name in "${file_names[@]}"
do
function process_file() {
local name="$1"
local file_path="$2"

if [[ -z "$file_path" ]]; then
echo "ERROR: Missing name or file path for processing." >&2
return 1
fi

# Version line regex `vers_match_regex` to match version specifier -- works under Linux and macOS.
if [[ $file_name == ".gitmodules" ]]; then
vers_match_regex="$variable_name-pin ="
Expand All @@ -50,6 +54,12 @@ do
if [[ -e "$file_name".bak ]]; then
rm "$file_name".bak
fi
}

while [[ $# -gt 0 ]]; do
variable_name=$1; shift;
file_name=$1; shift;
process_file $variable_name $file_name
done

if git diff --quiet "${file_names[@]}"; then
Expand All @@ -76,8 +86,8 @@ if [ "$existing_pr_count" -gt 0 ]; then
fi

if [[ "$repo" == "opentelemetry-specification"
|| "$repo" == "opentelemetry-proto"
|| "$repo" == "semantic-conventions" ]]; then
|| "$repo" == "opentelemetry-proto"
|| "$repo" == "semantic-conventions" ]]; then
echo "Switching to $repo at tag $latest_version"
( set -x;
npm run get:submodule -- content-modules/$repo &&
Expand Down

0 comments on commit 8020015

Please sign in to comment.