Merge pull request #115 from tauri-apps/renovate/bindgen-0.x #36
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Update bindings | |
| on: | |
| push: | |
| branches: | |
| - dev | |
| paths: | |
| - Cargo.toml | |
| - update-bindings/** | |
| - .github/workflows/update-bindings.yml | |
| jobs: | |
| update-linux: | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| target: | |
| - x86_64-unknown-linux-gnu | |
| - aarch64-unknown-linux-gnu | |
| - arm-unknown-linux-gnueabi | |
| outputs: | |
| changed: | |
| ${{ (steps.pack-changes.outputs.changed-x86_64-unknown-linux-gnu == 'true' | |
| || steps.pack-changes.outputs.changed-aarch64-unknown-linux-gnu == 'true' | |
| || steps.pack-changes.outputs.changed-arm-unknown-linux-gnueabi == 'true') | |
| && 'true' || 'false' }} | |
| steps: | |
| - uses: actions/checkout@v4.2.2 | |
| - 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 -t ${{ matrix.target }} | |
| - name: Pack Changes | |
| id: pack-changes | |
| run: | | |
| git add . | |
| CHANGED=($(git diff --name-only --staged | xargs)) | |
| if [ ${#CHANGED[@]} -gt 0 ]; then | |
| tar -czf update-${{ matrix.target }}.tar.gz ${CHANGED[@]} | |
| echo "changed-${{ matrix.target }}=true" >> "$GITHUB_OUTPUT" | |
| else | |
| echo "changed-${{ matrix.target }}=false" >> "$GITHUB_OUTPUT" | |
| fi | |
| - name: Upload Artifact | |
| uses: actions/upload-artifact@v4.6.2 | |
| with: | |
| name: update-${{ matrix.target }} | |
| path: update-${{ matrix.target }}.tar.gz | |
| if-no-files-found: ignore | |
| update-macos: | |
| runs-on: macos-latest | |
| strategy: | |
| matrix: | |
| target: | |
| - aarch64-apple-darwin | |
| - x86_64-apple-darwin | |
| outputs: | |
| changed: | |
| ${{ (steps.pack-changes.outputs.changed-aarch64-apple-darwin == 'true' | |
| || steps.pack-changes.outputs.changed-x86_64-apple-darwin == 'true') | |
| && 'true' || 'false' }} | |
| steps: | |
| - uses: actions/checkout@v4.2.2 | |
| - name: Update Bindings | |
| run: | | |
| cargo run -p update-bindings -- -b -d -t ${{ matrix.target }} | |
| - name: Pack Changes | |
| id: pack-changes | |
| run: | | |
| git add . | |
| CHANGED=($(git diff --name-only --staged | xargs)) | |
| if [ ${#CHANGED[@]} -gt 0 ]; then | |
| tar -czf update-${{ matrix.target }}.tar.gz ${CHANGED[@]} | |
| echo "changed-${{ matrix.target }}=true" >> "$GITHUB_OUTPUT" | |
| else | |
| echo "changed-${{ matrix.target }}=false" >> "$GITHUB_OUTPUT" | |
| fi | |
| - name: Upload Artifact | |
| uses: actions/upload-artifact@v4.6.2 | |
| with: | |
| name: update-${{ matrix.target }} | |
| path: update-${{ matrix.target }}.tar.gz | |
| if-no-files-found: ignore | |
| update-windows: | |
| runs-on: windows-latest | |
| strategy: | |
| matrix: | |
| target: | |
| - x86_64-pc-windows-msvc | |
| - aarch64-pc-windows-msvc | |
| - i686-pc-windows-msvc | |
| outputs: | |
| changed: | |
| ${{ (steps.pack-changes.outputs.changed-x86_64-pc-windows-msvc == 'true' | |
| || steps.pack-changes.outputs.changed-aarch64-pc-windows-msvc == 'true' | |
| || steps.pack-changes.outputs.changed-i686-pc-windows-msvc == 'true') | |
| && 'true' || 'false' }} | |
| steps: | |
| - uses: actions/checkout@v4.2.2 | |
| - name: Update Bindings | |
| run: | | |
| cargo run -p update-bindings -- -b -d -t ${{ matrix.target }} | |
| - name: Pack Changes | |
| id: pack-changes | |
| run: | | |
| git add . | |
| $changed = @(git diff --name-only --staged) | |
| if ($changed.Length -gt 0) { | |
| tar -czf update-${{ matrix.target }}.tar.gz $changed | |
| echo "changed-${{ matrix.target }}=true" >> "$env:GITHUB_OUTPUT" | |
| } else { | |
| echo "changed-${{ matrix.target }}=false" >> "$env:GITHUB_OUTPUT" | |
| } | |
| - name: Upload Artifact | |
| uses: actions/upload-artifact@v4.6.2 | |
| with: | |
| name: update-${{ matrix.target }} | |
| path: update-${{ matrix.target }}.tar.gz | |
| if-no-files-found: ignore | |
| 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' | |
| outputs: | |
| merged: ${{ steps.merge-artifacts.outputs.merged == 'true' }} | |
| steps: | |
| - name: Download Artifacts | |
| uses: actions/download-artifact@v4.3.0 | |
| with: | |
| pattern: update-* | |
| merge-multiple: true | |
| - name: Merge Artifacts | |
| id: merge-artifacts | |
| run: | | |
| FILES=(update-*.tar.gz) | |
| if [ ${#FILES[@]} -gt 0 ]; then | |
| mkdir merged | |
| cd merged | |
| for FILE in ${FILES[@]}; do | |
| echo "Extracting $FILE" | |
| tar -xzf ../$FILE | |
| rm ../$FILE | |
| done | |
| echo "Archiving merged changes" | |
| tar -czvf ../merge-changes.tar.gz . | |
| echo "merged=true" >> "$GITHUB_OUTPUT" | |
| else | |
| echo "No changes to merge" | |
| echo "merged=false" >> "$GITHUB_OUTPUT" | |
| fi | |
| - name: Upload Merged Artifacts | |
| if: steps.merge-artifacts.outputs.merged == 'true' | |
| uses: actions/upload-artifact@v4.6.2 | |
| with: | |
| name: merge-changes | |
| path: merge-changes.tar.gz | |
| publish-pr: | |
| runs-on: ubuntu-latest | |
| needs: merge-changes | |
| if: needs.merge-changes.outputs.merged == 'true' | |
| steps: | |
| - uses: actions/checkout@v4.2.2 | |
| - name: Download Artifacts | |
| uses: actions/download-artifact@v4.3.0 | |
| with: | |
| name: merge-changes | |
| - name: Merge PR | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| git switch -c update-bindings | |
| RESET_REV=$(git rev-parse HEAD) | |
| echo "Extracting merge-changes.tar.gz" | |
| tar -xzf merge-changes.tar.gz | |
| rm merge-changes.tar.gz | |
| 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 query=@.github/api/createCommitOnBranch.graphql \ | |
| ${FILES[@]} | |
| git pull | |
| gh pr create -f | |
| fi |