Skip to content

Commit

Permalink
Merge pull request #40 from wravery/dev
Browse files Browse the repository at this point in the history
chore: unify update-bindings workflow and resulting PR
  • Loading branch information
wravery authored Jan 30, 2025
2 parents a66b064 + e60a5c4 commit dab2d0b
Show file tree
Hide file tree
Showing 6 changed files with 252 additions and 223 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,10 @@ jobs:
echo "CEF_PATH=${{ matrix.os == 'windows-latest'
&& '$env:USERPROFILE'
|| '$HOME'
}}/.local/share/cef" >> $${{ matrix.os == 'windows-latest'
}}/.local/share/cef" >> "$${{ matrix.os == 'windows-latest'
&& 'env:'
|| ''
}}GITHUB_ENV
}}GITHUB_ENV"
echo "${{ matrix.os == 'macos-latest'
&& 'DYLD_FALLBACK_LIBRARY_PATH'
|| (matrix.os == 'windows-latest'
Expand All @@ -61,10 +61,10 @@ jobs:
&& '$DYLD_FALLBACK_LIBRARY_PATH:$HOME/.local/share/cef'
|| (matrix.os == 'windows-latest'
&& '$env:PATH;$env:USERPROFILE/.local/share/cef'
|| '$LD_LIBRARY_PATH:$HOME/.local/share/cef') }}" >> $${{ matrix.os == 'windows-latest'
|| '$LD_LIBRARY_PATH:$HOME/.local/share/cef') }}" >> "$${{ matrix.os == 'windows-latest'
&& 'env:'
|| ''
}}GITHUB_ENV
}}GITHUB_ENV"
- name: Build
run: cargo build --verbose
Expand Down
193 changes: 193 additions & 0 deletions .github/workflows/update-bindings.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,193 @@
name: Update bindings

on:
push:
branches:
- dev
paths:
- Cargo.lock

jobs:
update-linux:
runs-on: ubuntu-latest
outputs:
changed: ${{ steps.pack-changes.outputs.changed }}

steps:
- uses: actions/[email protected]

- name: Install Dependencies
run: |
sudo apt-get update
sudo apt-get install -yq gcc-14-aarch64-linux-gnu gcc-14-arm-linux-gnueabi
- name: Update Bindings
run: |
cargo run -p update-bindings -- -b -d x86_64-unknown-linux-gnu
cargo run -p update-bindings -- -b -d aarch64-unknown-linux-gnu
cargo run -p update-bindings -- -b -d arm-unknown-linux-gnueabi
- name: Pack Changes
id: pack-changes
run: |
git add .
CHANGED=($(git diff --name-only --staged | xargs))
if [ ${#CHANGED} -gt 0 ]; then
tar -czf update-linux.tar.gz ${CHANGED[@]}
echo "changed=true" >> "$GITHUB_OUTPUT"
else
echo "changed=false" >> "$GITHUB_OUTPUT"
fi
- name: Upload Artifact
if: steps.pack-changes.outputs.changed == 'true'
uses: actions/[email protected]
with:
name: update-linux
path: update-linux.tar.gz

update-macos:
runs-on: macos-latest
outputs:
changed: ${{ steps.pack-changes.outputs.changed }}

steps:
- uses: actions/[email protected]

- name: Update Bindings
run: |
cargo run -p update-bindings -- -b -d aarch64-apple-darwin
cargo run -p update-bindings -- -b -d x86_64-apple-darwin
- name: Pack Changes
id: pack-changes
run: |
git add .
CHANGED=($(git diff --name-only --staged | xargs))
if [ ${#CHANGED} -gt 0 ]; then
tar -czf update-macos.tar.gz ${CHANGED[@]}
echo "changed=true" >> "$GITHUB_OUTPUT"
else
echo "changed=false" >> "$GITHUB_OUTPUT"
fi
- name: Upload Artifact
if: steps.pack-changes.outputs.changed == 'true'
uses: actions/[email protected]
with:
name: update-macos
path: update-macos.tar.gz

update-windows:
runs-on: windows-latest
outputs:
changed: ${{ steps.pack-changes.outputs.changed }}

steps:
- uses: actions/[email protected]

- name: Update Bindings
run: |
cargo run -p update-bindings -- -b -d x86_64-pc-windows-msvc
cargo run -p update-bindings -- -b -d aarch64-pc-windows-msvc
cargo run -p update-bindings -- -b -d i686-pc-windows-msvc
- name: Pack Changes
id: pack-changes
run: |
git add .
$changed = @(git diff --name-only --staged)
if ($changed.Length -gt 0) {
tar -czf update-windows.tar.gz $changed
echo "changed=true" >> "$env:GITHUB_OUTPUT"
} else {
echo "changed=false" >> "$env:GITHUB_OUTPUT"
}
- name: Upload Artifact
if: steps.pack-changes.outputs.changed == 'true'
uses: actions/[email protected]
with:
name: update-windows
path: update-windows.tar.gz

merge-changes:
runs-on: ubuntu-latest
needs:
- update-linux
- update-macos
- update-windows
if: needs.update-linux.outputs.changed == 'true' || needs.update-macos.outputs.changed == 'true' || needs.update-windows.outputs.changed == 'true'

steps:
- uses: actions/[email protected]

- name: Download Linux Artifact
if: needs.update-linux.outputs.changed == 'true'
uses: actions/[email protected]
with:
name: update-linux

- name: Download macOS Artifact
if: needs.update-macos.outputs.changed == 'true'
uses: actions/[email protected]
with:
name: update-macos

- name: Download Windows Artifact
if: needs.update-windows.outputs.changed == 'true'
uses: actions/[email protected]
with:
name: update-windows

- name: Merge PR
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git switch -c update-bindings
RESET_REV=$(git rev-parse HEAD)
${{ needs.update-linux.outputs.changed == 'true'
&& 'echo "Extracting update-linux.tar.gz"
tar -xzf update-linux.tar.gz
rm update-linux.tar.gz'
|| 'echo "No changes in update-linux"' }}
${{ needs.update-macos.outputs.changed == 'true'
&& 'echo "Extracting update-macos.tar.gz"
tar -xzf update-macos.tar.gz
rm update-macos.tar.gz'
|| 'echo "No changes in update-macos"' }}
${{ needs.update-windows.outputs.changed == 'true'
&& 'echo "Extracting update-windows.tar.gz"
tar -xzf update-windows.tar.gz
rm update-windows.tar.gz'
|| 'echo "No changes in update-windows"' }}
git reset ${RESET_REV}
git add .
CHANGED=($(git diff --name-only --staged | xargs))
if [ ${#CHANGED} -gt 0 ]; then
git push --force -u origin update-bindings
FILES=()
for VALUE in ${CHANGED[@]}; do
base64 -w0 "${VALUE}" > "${VALUE}.base64"
FILES+=("-F" "files[][path]=${VALUE}" "-F" "files[][contents]=@${VALUE}.base64")
done
gh api graphql \
-F githubRepository=${GITHUB_REPOSITORY} \
-F branchName=update-bindings \
-F expectedHeadOid=${RESET_REV} \
-F 'commitMessage=chore: update bindings' \
-F [email protected]/api/createCommitOnBranch.graphql \
${FILES}
git pull
gh pr create -f
fi
60 changes: 0 additions & 60 deletions .github/workflows/update-linux.yml

This file was deleted.

54 changes: 0 additions & 54 deletions .github/workflows/update-macos.yml

This file was deleted.

61 changes: 0 additions & 61 deletions .github/workflows/update-windows.yml

This file was deleted.

Loading

0 comments on commit dab2d0b

Please sign in to comment.