Add a tool that allows us to quickly update specification URLs to a s… (#9)

Co-authored-by: Liudmila Molkova <limolkova@microsoft.com>
Co-authored-by: Johannes Tax <johannes@johannes.tax>
Co-authored-by: Christian Neumüller <christian+github@neumueller.me>
This commit is contained in:
Josh Suereth 2023-05-16 12:25:46 -04:00 committed by GitHub
parent 3bb601c243
commit b5bcbccc17
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 38 additions and 0 deletions

View File

@ -114,3 +114,11 @@ To quickly fix typos, use
```bash
make misspell-correction
```
## Updating the referenced specification version
1. Open the `./internal/tools/update_specification_version.sh` script.
2. Modify the `PREVIOUS_SPECIFICATION_VERSION` to be the same value as `LATEST_SPECIFICATION_VERSION`
3. Modify `LATEST_SPECIFICATION_VERSION` to the latest specification tag, e.g. `1.21`
4. Run the script from the root directory, e.g. `semantic-conventions$ ./internal/tools/update_specification_version.sh`.
5. Add all modified files to the change submit and submit a PR.

View File

@ -0,0 +1,30 @@
#!/bin/bash
# Example usage:
#
# ./internal/tools/update_specification_version.sh
# Set this to the version number you want to CHANGE in URLs in the repository.
PREVIOUS_SPECIFICATION_VERSION="main"
# Set this to the version number you want to KEEP in URLs in the repository.
LATEST_SPECIFICATION_VERSION="1.20.0"
# The specific pattern we look for when replacing URLs
SPECIFICATION_URL_PREFIX="https://github.com/open-telemetry/opentelemetry-specification/tree/"
SPECIFICATION_BLOB_URL_PREFIX="https://github.com/open-telemetry/opentelemetry-specification/blob/"
fix_file() {
echo Fixing file $1
sed -i \
-e "s,${SPECIFICATION_URL_PREFIX}${PREVIOUS_SPECIFICATION_VERSION},${SPECIFICATION_URL_PREFIX}${LATEST_SPECIFICATION_VERSION},g" \
-e "s,${SPECIFICATION_BLOB_URL_PREFIX}${PREVIOUS_SPECIFICATION_VERSION},${SPECIFICATION_URL_PREFIX}${LATEST_SPECIFICATION_VERSION},g" \
"$1"
}
important_files=("specification" "semantic_conventions" "README.md" "supplementary-guidelines")
# TODO - limit to markdown/yaml files?
find "${important_files[@]}" -type f -not -path '*/.*' -print0 | while read -d $'\0' file; do
fix_file "$file"
done