Skip to content

Commit cc96a76

Browse files
Refactor split-binaries job in build workflow
Refactor the split-binaries job to streamline platform branch updates.
1 parent 543811d commit cc96a76

1 file changed

Lines changed: 41 additions & 36 deletions

File tree

‎.github/workflows/build.yml‎

Lines changed: 41 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -42,40 +42,45 @@ jobs:
4242
git push "https://unetworkingab:${{ secrets.SECRET }}@github.com/uNetworking/uWebSockets.js" binaries
4343
4444
split-binaries:
45-
needs: build
46-
runs-on: ubuntu-latest
47-
steps:
48-
- name: Checkout binaries branch
49-
uses: actions/checkout@v4
50-
with:
51-
ref: binaries
52-
fetch-depth: 0
53-
54-
- name: Split and Push to Platform Branches
55-
run: |
56-
git config --global user.email "alexhultman@gmail.com"
57-
git config --global user.name "Alex Hultman"
45+
needs: build
46+
runs-on: ubuntu-latest
47+
steps:
48+
- name: Checkout binaries branch
49+
uses: actions/checkout@v4
50+
with:
51+
ref: binaries
52+
fetch-depth: 0
53+
54+
- name: Split and Push to Platform Branches
55+
run: |
56+
git config --global user.email "alexhultman@gmail.com"
57+
git config --global user.name "Alex Hultman"
58+
59+
# Platform patterns to match your filenames
60+
PLATFORMS=("win32_x64" "linux_x64" "linux_arm64" "darwin_x64" "darwin_arm64")
61+
62+
for PLATFORM in "${PLATFORMS[@]}"; do
63+
BRANCH="${PLATFORM}_binaries"
64+
echo "Updating $BRANCH..."
65+
66+
# 1. Fetch the existing platform branch or create it if it doesn't exist
67+
git fetch origin $BRANCH:$BRANCH || git branch $BRANCH
5868
59-
# Define the mapping of filename patterns to target branches
60-
# Pattern: <filename_part>:<target_branch>
61-
PLATFORMS=("win32_x64:win32_x64_binaries" "linux_x64:linux_x64_binaries" "linux_arm64:linux_arm64_binaries" "darwin_x64:darwin_x64_binaries" "darwin_arm64:darwin_arm64_binaries")
62-
63-
for entry in "${PLATFORMS[@]}"; do
64-
PATTERN="${entry%%:*}"
65-
BRANCH="${entry#*:}"
66-
67-
echo "Processing $PATTERN for branch $BRANCH..."
68-
69-
# Create/Reset the target branch based on current binaries state
70-
git checkout -B $BRANCH
71-
72-
# Remove files that don't match this platform (keep only the relevant .node and .js)
73-
# This keeps the branch clean of other platforms' binaries
74-
find . -maxdepth 1 -type f ! -name "*${PATTERN}*" ! -name "*.js" ! -name "source_commit" -exec git rm {} \;
75-
76-
git commit -m "Update $BRANCH binaries" || true
77-
git push -f "https://unetworkingab:${{ secrets.SECRET }}@github.com/uNetworking/uWebSockets.js" $BRANCH
78-
79-
# Switch back to binaries to process the next platform
80-
git checkout binaries
81-
done
69+
# 2. Switch to the platform branch
70+
git checkout $BRANCH
71+
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+
git checkout binaries -- "*${PLATFORM}*" "*.js" "source_commit"
75+
76+
# 4. Commit and push normally
77+
git add .
78+
if git commit -m "[GitHub Actions] Sync $PLATFORM binaries"; then
79+
git push "https://unetworkingab:${{ secrets.SECRET }}@github.com/uNetworking/uWebSockets.js" $BRANCH
80+
else
81+
echo "No changes for $PLATFORM, skipping push."
82+
fi
83+
84+
# 5. Move back to binaries branch for the next loop iteration
85+
git checkout binaries
86+
done

0 commit comments

Comments
 (0)