-
Notifications
You must be signed in to change notification settings - Fork 1.4k
fix: Java README version stuck at 1.0.5-01; release sed regex can't match numeric qualifiers #2226
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| #!/usr/bin/env bash | ||
|
|
||
| set -euo pipefail | ||
|
|
||
| SCRIPT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) | ||
| UPDATER="${SCRIPT_DIR}/update-documentation-versions.sh" | ||
| TEMP_DIR=$(mktemp -d) | ||
| trap 'rm -rf "$TEMP_DIR"' EXIT | ||
|
|
||
| run_case() { | ||
| local name=$1 | ||
| local old_version=$2 | ||
| local old_dev_version=$3 | ||
| local version=$4 | ||
| local dev_version=$5 | ||
| local old_jbang_version=$6 | ||
| local case_dir="${TEMP_DIR}/${name}" | ||
|
|
||
| mkdir "$case_dir" | ||
| printf '%s\n' \ | ||
| '<dependency>' \ | ||
| ' <artifactId>copilot-sdk-java</artifactId>' \ | ||
| " <version>${old_version}</version>" \ | ||
| '</dependency>' \ | ||
| "implementation 'com.github:copilot-sdk-java:${old_version}'" \ | ||
| '<dependency>' \ | ||
| ' <artifactId>copilot-sdk-java</artifactId>' \ | ||
| " <version>${old_dev_version}</version>" \ | ||
| '</dependency>' \ | ||
| "implementation 'com.github:copilot-sdk-java:${old_dev_version}'" \ | ||
| > "${case_dir}/README.md" | ||
| printf '%s\n' \ | ||
| "///usr/bin/env jbang \"\$0\" \"\$@\" ; exit \$?" \ | ||
| "//DEPS com.github:copilot-sdk-java:${old_jbang_version}" \ | ||
| > "${case_dir}/jbang-example.java" | ||
|
|
||
| "$UPDATER" "$version" "$dev_version" "${case_dir}/README.md" "${case_dir}/jbang-example.java" | ||
|
|
||
| grep -Fqx " <version>${version}</version>" "${case_dir}/README.md" | ||
| grep -Fqx "implementation 'com.github:copilot-sdk-java:${version}'" "${case_dir}/README.md" | ||
| grep -Fqx " <version>${dev_version}</version>" "${case_dir}/README.md" | ||
| grep -Fqx "implementation 'com.github:copilot-sdk-java:${dev_version}'" "${case_dir}/README.md" | ||
| grep -Fqx "//DEPS com.github:copilot-sdk-java:${version}" "${case_dir}/jbang-example.java" | ||
|
|
||
| if grep -Fq "$old_version" "${case_dir}/README.md" "${case_dir}/jbang-example.java" || | ||
| grep -Fq "$old_dev_version" "${case_dir}/README.md"; then | ||
| echo "Stale version remained in ${name} test output" >&2 | ||
| exit 1 | ||
| fi | ||
| } | ||
|
|
||
| run_case stable 1.0.8 1.0.9-SNAPSHOT 1.0.9 1.0.10-SNAPSHOT "\${project.version}" | ||
| run_case preview 1.0.9-preview.2-01 1.0.10-preview.2-SNAPSHOT 1.0.10-preview.2 1.0.11-preview.2-SNAPSHOT 1.0.9-preview.2-01 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,80 @@ | ||
| #!/usr/bin/env bash | ||
|
|
||
| set -euo pipefail | ||
|
|
||
| if [[ $# -ne 4 ]]; then | ||
| echo "Usage: $0 <release-version> <development-version> <readme> <jbang-example>" >&2 | ||
| exit 2 | ||
| fi | ||
|
|
||
| VERSION=$1 | ||
| DEV_VERSION=$2 | ||
| README=$3 | ||
| JBANG_EXAMPLE=$4 | ||
| VERSION_FORMAT='[0-9]+\.[0-9]+\.[0-9]+(-(preview|(beta-)?java(-preview)?)\.[0-9]+)?' | ||
|
|
||
| if [[ ! "$VERSION" =~ ^${VERSION_FORMAT}$ ]]; then | ||
| echo "Invalid release version: $VERSION" >&2 | ||
| exit 2 | ||
| fi | ||
| if [[ ! "$DEV_VERSION" =~ ^${VERSION_FORMAT}-SNAPSHOT$ ]]; then | ||
| echo "Invalid development version: $DEV_VERSION" >&2 | ||
| exit 2 | ||
| fi | ||
| if [[ ! -f "$README" || ! -f "$JBANG_EXAMPLE" ]]; then | ||
| echo "README and JBang example files must exist" >&2 | ||
| exit 2 | ||
| fi | ||
|
|
||
| export VERSION DEV_VERSION | ||
|
|
||
| perl -0 - "$README" <<'PERL' | ||
| use strict; | ||
| use warnings; | ||
|
|
||
| my ($path) = @ARGV; | ||
| open my $input, '<', $path or die "Cannot read $path: $!\n"; | ||
| my $content = do { local $/; <$input> }; | ||
| close $input or die "Cannot close $path: $!\n"; | ||
|
|
||
| # Match accepted release versions plus numeric suffixes left by the former broken updater. | ||
| my $version = qr/[0-9]+\.[0-9]+\.[0-9]+(?:-(?:preview|(?:beta-)?java(?:-preview)?)\.[0-9]+)?(?:-[0-9]+)*/; | ||
| my $snapshot_xml = ($content =~ s{<version>$version-SNAPSHOT</version>}{<version>$ENV{DEV_VERSION}</version>}g); | ||
| my $snapshot_gradle = ($content =~ s{(copilot-sdk-java:)$version-SNAPSHOT(?![-A-Za-z0-9.])}{$1 . $ENV{DEV_VERSION}}ge); | ||
| my $release_xml = ($content =~ s{<version>$version</version>}{<version>$ENV{VERSION}</version>}g); | ||
| my $release_gradle = ($content =~ s{(copilot-sdk-java:)$version(?![-A-Za-z0-9.])}{$1 . $ENV{VERSION}}ge); | ||
|
|
||
| die "Expected one release and one snapshot example for both Maven and Gradle in $path\n" | ||
| unless $snapshot_xml == 1 && $snapshot_gradle == 1 && $release_xml == 1 && $release_gradle == 1; | ||
|
|
||
| open my $output, '>', $path or die "Cannot write $path: $!\n"; | ||
| print {$output} $content; | ||
| close $output or die "Cannot close $path: $!\n"; | ||
| PERL | ||
|
|
||
| perl -0 - "$JBANG_EXAMPLE" <<'PERL' | ||
| use strict; | ||
| use warnings; | ||
|
|
||
| my ($path) = @ARGV; | ||
| open my $input, '<', $path or die "Cannot read $path: $!\n"; | ||
| my $content = do { local $/; <$input> }; | ||
| close $input or die "Cannot close $path: $!\n"; | ||
|
|
||
| my $version = qr/[0-9]+\.[0-9]+\.[0-9]+(?:-(?:preview|(?:beta-)?java(?:-preview)?)\.[0-9]+)?(?:-[0-9]+)*/; | ||
| my $version_count = ($content =~ s{(copilot-sdk-java:)$version(?![-A-Za-z0-9.])}{$1 . $ENV{VERSION}}ge); | ||
| my $placeholder_count = ($content =~ s{copilot-sdk-java:\$\{project\.version\}}{copilot-sdk-java:$ENV{VERSION}}g); | ||
|
|
||
| die "Expected exactly one Copilot SDK dependency in $path\n" | ||
| unless $version_count + $placeholder_count == 1; | ||
|
|
||
| open my $output, '>', $path or die "Cannot write $path: $!\n"; | ||
| print {$output} $content; | ||
| close $output or die "Cannot close $path: $!\n"; | ||
| PERL | ||
|
|
||
| grep -Fqx " <version>${VERSION}</version>" "$README" | ||
| grep -Fqx "implementation 'com.github:copilot-sdk-java:${VERSION}'" "$README" | ||
| grep -Fqx " <version>${DEV_VERSION}</version>" "$README" | ||
| grep -Fqx "implementation 'com.github:copilot-sdk-java:${DEV_VERSION}'" "$README" | ||
| grep -Fqx "//DEPS com.github:copilot-sdk-java:${VERSION}" "$JBANG_EXAMPLE" |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.