@@ -56,31 +56,35 @@ jobs:
5656 git config --global user.email "alexhultman@gmail.com"
5757 git config --global user.name "Alex Hultman"
5858
59- # Platform patterns to match your filenames
6059 PLATFORMS=("win32_x64" "linux_x64" "linux_arm64" "darwin_x64" "darwin_arm64")
6160
6261 for PLATFORM in "${PLATFORMS[@]}"; do
6362 BRANCH="${PLATFORM}_binaries"
6463 echo "Updating $BRANCH..."
6564
66- # 1. Fetch the existing platform branch or create it if it doesn't exist
67- git fetch origin $BRANCH:$BRANCH || git checkout --orphan $BRANCH
68-
69- # 2. Switch to the platform branch
70- git checkout $BRANCH
65+ # 1. Fetch existing branch OR create a CLEAN orphan
66+ if git fetch origin $BRANCH; then
67+ git checkout $BRANCH
68+ git reset --hard origin/$BRANCH
69+ else
70+ git checkout --orphan $BRANCH
71+ git rm -rf . # CRITICAL: Remove leftovers from the 'binaries' branch
72+ fi
7173
72- # 3. Sync files from the 'binaries' branch (only files matching this platform)
73- # This brings in new .node files and updates .js/source_commit
74+ # 2. Sync files for this platform
7475 git checkout binaries -- "*${PLATFORM}*" "*.js" "source_commit"
7576
76- # 4. Commit and push normally
77+ # 3. Read the SHA for the commit message
78+ SOURCE_SHA=$(cat source_commit | tr -d '\n\r')
79+
80+ # 4. Commit and push
7781 git add .
78- if git commit -m "[GitHub Actions] Sync $PLATFORM binaries"; then
82+ if git commit -m "[GitHub Actions] $PLATFORM binaries for $SOURCE_SHA "; then
7983 git push "https://unetworkingab:${{ secrets.SECRET }}@github.com/uNetworking/uWebSockets.js" $BRANCH
8084 else
8185 echo "No changes for $PLATFORM, skipping push."
8286 fi
8387
84- # 5. Move back to binaries branch for the next loop iteration
85- git checkout binaries
88+ # 5. Force jump back to binaries branch to clean the workspace for the next loop
89+ git checkout -f binaries
8690 done
0 commit comments