-
-
Notifications
You must be signed in to change notification settings - Fork 14
fix: improve version parsing and validation in CI workflow #75
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
Conversation
zortos293
commented
Dec 29, 2025
- 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
There was a problem hiding this 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.
| 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)" | ||
Copilot
AI
Dec 29, 2025
There was a problem hiding this comment.
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.
| 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 |
| # Ensure values are valid numbers (default if empty/invalid) | ||
| MAJOR=${MAJOR:-0} | ||
| MINOR=${MINOR:-0} | ||
| PATCH=${PATCH:-1} | ||
| MINOR=${MINOR:-1} | ||
| PATCH=${PATCH:-0} |
Copilot
AI
Dec 29, 2025
There was a problem hiding this comment.
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.
| 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" |
Copilot
AI
Dec 29, 2025
There was a problem hiding this comment.
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.
| 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" |
| shell: bash | ||
| run: | | ||
| VERSION="${{ needs.get-version.outputs.version_number }}" | ||
| # Update package.json |
Copilot
AI
Dec 29, 2025
There was a problem hiding this comment.
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.
| # Update package.json | |
| # Update version in package.json, tauri.conf.json, and Cargo.toml |