Skip to content

Commit 6268813

Browse files
Fix script for cross-platform compatibility and robust version extraction
Co-authored-by: thomasturrell <1552612+thomasturrell@users.noreply.github.com>
1 parent ccfe3ed commit 6268813

3 files changed

Lines changed: 13 additions & 11 deletions

File tree

.github/scripts/update-example-versions.sh

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,9 @@ get_version_from_pom() {
2020
if command -v xmllint &> /dev/null; then
2121
xmllint --xpath '//*[local-name()="project"]/*[local-name()="version"]/text()' "$pom_file" 2>/dev/null | head -1
2222
else
23-
# Fallback to grep/sed approach
24-
grep -m 1 "^ <version>" "$pom_file" | sed 's/.*<version>\(.*\)<\/version>.*/\1/'
23+
# Fallback to grep/sed approach - skip parent block, get project version
24+
# First skip everything in the parent block, then get the first version tag
25+
awk '/<parent>/,/<\/parent>/ {next} /<version>/ {print; exit}' "$pom_file" | sed 's/.*<version>\(.*\)<\/version>.*/\1/'
2526
fi
2627
}
2728

@@ -64,12 +65,12 @@ main() {
6465
cp "$file" "$file.bak"
6566

6667
# Replace version numbers in Maven dependency examples
67-
# Pattern: <version>X.Y.Z</version> where X.Y.Z is a version number
68+
# Pattern: <version>X.Y.Z</version> where X.Y.Z is a version number (or more components)
6869
# Only replace in dependency blocks (between <dependency> and </dependency>)
69-
sed -i.tmp '/<dependency>/,/<\/dependency>/ s/<version>[0-9]\+\.[0-9]\+\.[0-9]\+<\/version>/<version>'"$RELEASE_VERSION"'<\/version>/g' "$file"
70-
71-
# Clean up temporary file
72-
rm -f "$file.tmp"
70+
# Use a more flexible pattern to match versions with multiple components
71+
# Use cross-platform sed syntax with explicit temp file
72+
sed '/<dependency>/,/<\/dependency>/ s|<version>[^<]*</version>|<version>'"$RELEASE_VERSION"'</version>|g' "$file" > "$file.tmp"
73+
mv "$file.tmp" "$file"
7374

7475
# Check if file was modified
7576
if ! diff -q "$file" "$file.bak" > /dev/null 2>&1; then

.github/workflows/manual-release.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,8 @@ jobs:
198198
echo "Documentation examples updated with release version"
199199
200200
# Amend the release commit created by release:prepare to include doc updates
201-
git add README.md
201+
# Add all modified files that the script may have updated
202+
git add -u
202203
git commit --amend --no-edit
203204
204205
# Update the tag to point to the amended commit

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ To use the xAPI Java Client include the appropriate XML in the `dependencies` se
2828
<dependency>
2929
<groupId>dev.learning.xapi</groupId>
3030
<artifactId>xapi-client</artifactId>
31-
<version>1.1.11</version>
31+
<version>1.1.21</version>
3232
</dependency>
3333
</dependencies>
3434
</project>
@@ -302,7 +302,7 @@ To use the xAPI Model Spring Boot Starter include the appropriate XML in the `de
302302
<dependency>
303303
<groupId>dev.learning.xapi</groupId>
304304
<artifactId>xapi-model-spring-boot-starter</artifactId>
305-
<version>1.1.11</version>
305+
<version>1.1.21</version>
306306
</dependency>
307307
```
308308

@@ -357,7 +357,7 @@ To use the xAPI Model include the appropriate XML in the `dependencies` section
357357
<dependency>
358358
<groupId>dev.learning.xapi</groupId>
359359
<artifactId>xapi-model</artifactId>
360-
<version>1.1.11</version>
360+
<version>1.1.21</version>
361361
</dependency>
362362
</dependencies>
363363
</project>

0 commit comments

Comments
 (0)