diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 987de7212..a60c91aaa 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -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. diff --git a/internal/tools/update_specification_version.sh b/internal/tools/update_specification_version.sh new file mode 100755 index 000000000..ccc195c6c --- /dev/null +++ b/internal/tools/update_specification_version.sh @@ -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