Skip to content

Conversation

@zortos293
Copy link
Owner

  • Add semver validation with fallback to 0.1.0
  • Add grep validation for numeric version components
  • Consolidate version updates into single step with verification
  • Add debug output for version parsing
  • Default to v0.1.0 if no tags exist

- Add semver validation with fallback to 0.1.0
- Add grep validation for numeric version components
- Consolidate version updates into single step with verification
- Add debug output for version parsing
- Default to v0.1.0 if no tags exist
Copilot AI review requested due to automatic review settings December 29, 2025 00:48
@zortos293 zortos293 merged commit 29d7a41 into main Dec 29, 2025
8 checks passed
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR improves version parsing and validation in the CI workflow by adding robust input validation, consolidating multiple version update steps, and enhancing debugging capabilities for version management.

  • Changed default version from v0.0.1 to v0.1.0 with improved parsing that validates numeric components using grep
  • Consolidated three separate version update steps (package.json, tauri.conf.json, Cargo.toml) into a single step with validation
  • Added debug output throughout the version parsing process and verification of updated files

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +201 to +204
echo "package.json: $(grep '"version"' package.json | head -1)"
echo "tauri.conf.json: $(grep '"version"' src-tauri/tauri.conf.json | head -1)"
echo "Cargo.toml: $(grep '^version' src-tauri/Cargo.toml | head -1)"
Copy link

Copilot AI Dec 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The verification output only displays the lines containing version information but doesn't actually validate that the version was correctly set to the expected value. Consider comparing the extracted version against the expected VERSION variable to ensure the sed commands succeeded in updating all files correctly.

Suggested change
echo "package.json: $(grep '"version"' package.json | head -1)"
echo "tauri.conf.json: $(grep '"version"' src-tauri/tauri.conf.json | head -1)"
echo "Cargo.toml: $(grep '^version' src-tauri/Cargo.toml | head -1)"
pkg_version=$(grep '"version"' package.json | head -1 | sed 's/.*"version":[[:space:]]*"\([^"]*\)".*/\1/')
tauri_json_version=$(grep '"version"' src-tauri/tauri.conf.json | head -1 | sed 's/.*"version":[[:space:]]*"\([^"]*\)".*/\1/')
cargo_version=$(grep '^version' src-tauri/Cargo.toml | head -1 | sed 's/version[[:space:]]*=[[:space:]]*"\([^"]*\)".*/\1/')
echo "Expected version: $VERSION"
echo "package.json version: $pkg_version"
echo "tauri.conf.json version: $tauri_json_version"
echo "Cargo.toml version: $cargo_version"
mismatch=0
if [[ "$pkg_version" != "$VERSION" ]]; then
echo "Error: package.json version mismatch (got '$pkg_version')"
mismatch=1
fi
if [[ "$tauri_json_version" != "$VERSION" ]]; then
echo "Error: src-tauri/tauri.conf.json version mismatch (got '$tauri_json_version')"
mismatch=1
fi
if [[ "$cargo_version" != "$VERSION" ]]; then
echo "Error: src-tauri/Cargo.toml version mismatch (got '$cargo_version')"
mismatch=1
fi
if [[ "$mismatch" -ne 0 ]]; then
echo "Version verification failed. Please check sed commands and config files."
exit 1
fi

Copilot uses AI. Check for mistakes.
Comment on lines +52 to +55
# Ensure values are valid numbers (default if empty/invalid)
MAJOR=${MAJOR:-0}
MINOR=${MINOR:-0}
PATCH=${PATCH:-1}
MINOR=${MINOR:-1}
PATCH=${PATCH:-0}
Copy link

Copilot AI Dec 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fallback values after the double-pipe in the parameter expansion (lines 53-55) are redundant since the grep commands on lines 48-50 already provide fallback values via the || echo pattern. If grep succeeds, these variables will always contain a value. The parameter expansion fallbacks will never be used, making them unnecessary code.

Copilot uses AI. Check for mistakes.
sed -i "s/\"version\": \"[^\"]*\"/\"version\": \"$VERSION\"/" src-tauri/tauri.conf.json
# Validate version is a valid semver (x.y.z format)
if [[ ! "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "Error: Invalid version format '$VERSION', using fallback 0.1.0"
Copy link

Copilot AI Dec 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The validation only checks if the version appears to be a valid semver format but then silently falls back to "0.1.0" without propagating this error or stopping the workflow. This means if the version parsing fails in the get-version job, all builds will silently use 0.1.0, which could lead to confusing or incorrect releases. Consider either failing the workflow or logging a warning that's more visible.

Suggested change
echo "Error: Invalid version format '$VERSION', using fallback 0.1.0"
echo "Error: Invalid version format '$VERSION', using fallback 0.1.0"
echo "::warning::Invalid version format '$VERSION'; using fallback 0.1.0"

Copilot uses AI. Check for mistakes.
shell: bash
run: |
VERSION="${{ needs.get-version.outputs.version_number }}"
# Update package.json
Copy link

Copilot AI Dec 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment on line 188 says "# Update package.json" but the code block actually updates all three files (package.json, tauri.conf.json, and Cargo.toml). The comment should be removed or updated to reflect that all files are being updated in this block, as the step name already indicates this.

Suggested change
# Update package.json
# Update version in package.json, tauri.conf.json, and Cargo.toml

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants