Skip to content

Commit cd97927

Browse files
committed
Keep Directory.Build.props from target branch - preserve net8 versions
1 parent c0ac39e commit cd97927

File tree

1 file changed

+17
-39
lines changed

1 file changed

+17
-39
lines changed

.github/workflows/sync-version-branches.yml

Lines changed: 17 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -121,58 +121,36 @@ jobs:
121121
fi
122122
done
123123
124-
# Reset .csproj files to target branch versions
125-
echo "📝 Resetting .csproj files to ${{ matrix.target_branch }} versions..."
124+
# Reset .csproj files and Directory.Build.props to target branch versions
125+
echo "📝 Resetting .csproj files and Directory.Build.props to ${{ matrix.target_branch }} versions..."
126126
find . -name "*.csproj" -type f -exec git checkout ${{ matrix.target_branch }} -- {} \;
127-
128-
# Update version and target framework in Directory.Build.props
129-
dotnet_version=$(echo "${{ matrix.target_branch }}" | sed 's/[^0-9]*//g')
130-
echo "dotnet_version=$dotnet_version" >> $GITHUB_ENV
127+
128+
# Also reset Directory.Build.props to keep the net8 version
131129
if [ -f "src/Directory.Build.props" ]; then
132-
echo "🔄 Updating version and target framework to .NET $dotnet_version..."
133-
134-
# Get current version from main
135-
current_version=$(grep -oP '<Version>\K[^<]+' src/Directory.Build.props)
136-
echo "Current version from main: $current_version"
137-
138-
# Replace the major version (9 → 8) while keeping the rest
139-
new_version=$(echo "$current_version" | sed "s/^9\./$dotnet_version./")
140-
echo "New version for ${{ matrix.target_branch }}: $new_version"
130+
echo "📝 Resetting Directory.Build.props to ${{ matrix.target_branch }} version..."
131+
git checkout ${{ matrix.target_branch }} -- src/Directory.Build.props
141132
142-
# Update version number
143-
sed -i "s|<Version>$current_version</Version>|<Version>$new_version</Version>|g" src/Directory.Build.props
144-
145-
# Update target framework (net9.0 → net8.0)
146-
sed -i "s|<TargetFramework>net9\.0</TargetFramework>|<TargetFramework>net$dotnet_version.0</TargetFramework>|g" src/Directory.Build.props
147-
148-
# Show the changes
149-
echo "Updated Directory.Build.props:"
133+
echo "Directory.Build.props from ${{ matrix.target_branch }}:"
150134
grep -E "<Version>|<TargetFramework>" src/Directory.Build.props
151135
fi
152136
153-
# Verify Directory.Build.props was updated correctly
154-
if [ -f "src/Directory.Build.props" ]; then
155-
if grep -q "<TargetFramework>net9" src/Directory.Build.props; then
156-
echo "❌ ERROR: TargetFramework still shows net9.0, update failed!"
157-
echo "Content of Directory.Build.props:"
158-
cat src/Directory.Build.props
159-
exit 1
160-
fi
161-
if grep -q "<Version>9\." src/Directory.Build.props; then
162-
echo "❌ ERROR: Version still starts with 9., update failed!"
163-
echo "Content of Directory.Build.props:"
164-
cat src/Directory.Build.props
165-
exit 1
166-
fi
167-
echo "✅ Directory.Build.props updated successfully"
168-
fi
169137
170138
# Stage all changes
171139
git add -A
140+
141+
# Show what files have changes
142+
echo "📋 Files with changes after cherry-pick and reset:"
143+
git diff --cached --name-status
144+
145+
# Show actual changes
146+
echo "📝 Actual changes to be committed:"
147+
git diff --cached --stat
172148
173149
# Check if there are changes to commit
174150
if git diff --cached --quiet; then
175151
echo "ℹ️ No changes to commit after processing"
152+
echo "This means all changes from main are already in ${{ matrix.target_branch }}"
153+
echo "or only affected .csproj/Directory.Build.props files which we reset."
176154
git checkout main
177155
git branch -D "$sync_branch"
178156
exit 0

0 commit comments

Comments
 (0)