Fix version.h generation timing in build script
This commit is contained in:
@@ -139,6 +139,13 @@ compile_project() {
|
|||||||
print_warning "Clean failed or no Makefile found"
|
print_warning "Clean failed or no Makefile found"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Force regenerate version.h to pick up new tags
|
||||||
|
if make force-version > /dev/null 2>&1; then
|
||||||
|
print_success "Regenerated version.h"
|
||||||
|
else
|
||||||
|
print_warning "Failed to regenerate version.h"
|
||||||
|
fi
|
||||||
|
|
||||||
# Compile the project
|
# Compile the project
|
||||||
if make > /dev/null 2>&1; then
|
if make > /dev/null 2>&1; then
|
||||||
print_success "C-Relay compiled successfully"
|
print_success "C-Relay compiled successfully"
|
||||||
@@ -238,6 +245,49 @@ git_commit_and_push() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Function to commit and push changes without creating a tag (tag already created)
|
||||||
|
git_commit_and_push_no_tag() {
|
||||||
|
print_status "Preparing git commit..."
|
||||||
|
|
||||||
|
# Stage all changes
|
||||||
|
if git add . > /dev/null 2>&1; then
|
||||||
|
print_success "Staged all changes"
|
||||||
|
else
|
||||||
|
print_error "Failed to stage changes"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Check if there are changes to commit
|
||||||
|
if git diff --staged --quiet; then
|
||||||
|
print_warning "No changes to commit"
|
||||||
|
else
|
||||||
|
# Commit changes
|
||||||
|
if git commit -m "$NEW_VERSION - $COMMIT_MESSAGE" > /dev/null 2>&1; then
|
||||||
|
print_success "Committed changes"
|
||||||
|
else
|
||||||
|
print_error "Failed to commit changes"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Push changes and tags
|
||||||
|
print_status "Pushing to remote repository..."
|
||||||
|
if git push > /dev/null 2>&1; then
|
||||||
|
print_success "Pushed changes"
|
||||||
|
else
|
||||||
|
print_error "Failed to push changes"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Push only the new tag to avoid conflicts with existing tags
|
||||||
|
if git push origin "$NEW_VERSION" > /dev/null 2>&1; then
|
||||||
|
print_success "Pushed tag: $NEW_VERSION"
|
||||||
|
else
|
||||||
|
print_error "Failed to push tag: $NEW_VERSION"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
# Function to create Gitea release
|
# Function to create Gitea release
|
||||||
create_gitea_release() {
|
create_gitea_release() {
|
||||||
print_status "Creating Gitea release..."
|
print_status "Creating Gitea release..."
|
||||||
@@ -354,14 +404,23 @@ main() {
|
|||||||
# Increment minor version for releases
|
# Increment minor version for releases
|
||||||
increment_version "minor"
|
increment_version "minor"
|
||||||
|
|
||||||
# Compile project first
|
# Create new git tag BEFORE compilation so version.h picks it up
|
||||||
|
if git tag "$NEW_VERSION" > /dev/null 2>&1; then
|
||||||
|
print_success "Created tag: $NEW_VERSION"
|
||||||
|
else
|
||||||
|
print_warning "Tag $NEW_VERSION already exists, removing and recreating..."
|
||||||
|
git tag -d "$NEW_VERSION" > /dev/null 2>&1
|
||||||
|
git tag "$NEW_VERSION" > /dev/null 2>&1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Compile project first (will now pick up the new tag)
|
||||||
compile_project
|
compile_project
|
||||||
|
|
||||||
# Build release binaries
|
# Build release binaries
|
||||||
build_release_binaries
|
build_release_binaries
|
||||||
|
|
||||||
# Commit and push
|
# Commit and push (but skip tag creation since we already did it)
|
||||||
git_commit_and_push
|
git_commit_and_push_no_tag
|
||||||
|
|
||||||
# Create Gitea release with binaries
|
# Create Gitea release with binaries
|
||||||
create_gitea_release
|
create_gitea_release
|
||||||
@@ -378,11 +437,20 @@ main() {
|
|||||||
# Increment patch version for regular commits
|
# Increment patch version for regular commits
|
||||||
increment_version "patch"
|
increment_version "patch"
|
||||||
|
|
||||||
# Compile project
|
# Create new git tag BEFORE compilation so version.h picks it up
|
||||||
|
if git tag "$NEW_VERSION" > /dev/null 2>&1; then
|
||||||
|
print_success "Created tag: $NEW_VERSION"
|
||||||
|
else
|
||||||
|
print_warning "Tag $NEW_VERSION already exists, removing and recreating..."
|
||||||
|
git tag -d "$NEW_VERSION" > /dev/null 2>&1
|
||||||
|
git tag "$NEW_VERSION" > /dev/null 2>&1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Compile project (will now pick up the new tag)
|
||||||
compile_project
|
compile_project
|
||||||
|
|
||||||
# Commit and push
|
# Commit and push (but skip tag creation since we already did it)
|
||||||
git_commit_and_push
|
git_commit_and_push_no_tag
|
||||||
|
|
||||||
print_success "Build and push completed successfully!"
|
print_success "Build and push completed successfully!"
|
||||||
print_status "Version $NEW_VERSION pushed to repository"
|
print_status "Version $NEW_VERSION pushed to repository"
|
||||||
|
|||||||
Reference in New Issue
Block a user