-
Notifications
You must be signed in to change notification settings - Fork 1
feat: add VERSION file update with gitversion semver on checkout #11
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
6 commits
Select commit
Hold shift + click to select a range
97bdb34
Initial plan
Copilot 2c387f2
feat: add VERSION file update with gitversion semver on checkout
Copilot 51926a7
fix: improve version extraction logic for better semver detection
Copilot b2566d4
feat: add VERSION file update with gitversion semver on checkout
Copilot e8e0f28
feat: support flexible naming
tomgrv b06abdf
fix: 🐛 handle legitimate naming
tomgrv 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| #!/bin/bash | ||
| # Script to update VERSION file with GitVersion semver | ||
| # This script handles both GitVersion tool and fallback scenarios | ||
|
|
||
| set -e | ||
|
|
||
| # Define the VERSION file path | ||
| VERSION_FILE="VERSION" | ||
|
|
||
| # Function to update VERSION file | ||
| update_version_file() { | ||
| local version="$1" | ||
| if [ -n "$version" ]; then | ||
| echo "$version" > "$VERSION_FILE" | ||
| zz_log s "Updated VERSION file to: $version" | ||
| else | ||
| zz_log w "Could not determine version" | ||
| fi | ||
| } | ||
|
|
||
| # Function to extract semver from git describe | ||
| extract_semver_from_describe() { | ||
| local describe_output="$1" | ||
| # Extract version from tags ending with a semantic version, e.g.: | ||
| # feature_larasets_5.10.2-1-g97bdb34 -> 5.10.2-1-g97bdb34 | ||
| # release_5.10.2 -> 5.10.2 | ||
| # v5.10.2 -> 5.10.2 | ||
| # The regex matches any tag ending with X.Y.Z (optionally with suffixes). | ||
| echo "$describe_output" | sed -E 's/.*[_v]([0-9]+\.[0-9]+\.[0-9]+([-a-zA-Z0-9\.]*)?)/\1/' | head -1 | ||
| } | ||
|
|
||
| # Try GitVersion first (if available and working) | ||
| if command -v dotnet-gitversion >/dev/null 2>&1; then | ||
| # Try to get MajorMinorPatch from GitVersion | ||
| GITVERSION_OUTPUT=$(dotnet-gitversion -config .gitversion -showvariable MajorMinorPatch 2>/dev/null || echo "") | ||
| # Check if output is a valid version number (only digits and dots) and not default | ||
| if [ -n "$GITVERSION_OUTPUT" ] && echo "$GITVERSION_OUTPUT" | grep -qE '^[0-9]+\.[0-9]+\.[0-9]+$'; then | ||
| update_version_file "$GITVERSION_OUTPUT" | ||
| exit 0 | ||
| fi | ||
| fi | ||
|
|
||
| # Fallback to git describe | ||
| GIT_DESCRIBE=$(git describe --tags --always --dirty 2>/dev/null || echo "") | ||
| if [ -n "$GIT_DESCRIBE" ]; then | ||
| FALLBACK_VERSION=$(extract_semver_from_describe "$GIT_DESCRIBE") | ||
| update_version_file "$FALLBACK_VERSION" | ||
| exit 0 | ||
| fi | ||
|
|
||
| # Final fallback - keep existing version or use default | ||
| if [ -f "$VERSION_FILE" ]; then | ||
| zz_log w "Could not determine new version, keeping existing VERSION file" | ||
| else | ||
| update_version_file "1.0.0" | ||
| fi | ||
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.