Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
136 changes: 136 additions & 0 deletions .github/workflows/update_rd_pipe_dlls.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
name: Update rd_pipe DLLs

on:
schedule:
- cron: '0 6 * * *'
workflow_dispatch:

permissions:
contents: write
pull-requests: write

jobs:
update:
runs-on: ubuntu-latest
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
UPSTREAM: leonardder/rd_pipe-rs
steps:
- name: Checkout
uses: actions/checkout@v6

- name: Resolve latest upstream release
run: |
set -euo pipefail
data=$(gh release view --repo "$UPSTREAM" --json tagName,url,assets)
tag=$(echo "$data" | jq -r '.tagName')
url=$(echo "$data" | jq -r '.url')
asset=$(echo "$data" | jq -r '.assets[] | select(.name | endswith(".zip")) | .name' | head -n1)
if [ -z "$tag" ] || [ -z "$asset" ]; then
echo "Failed to resolve tag or asset" >&2
exit 1
fi
echo "TAG=$tag" >> "$GITHUB_ENV"
echo "RELEASE_URL=$url" >> "$GITHUB_ENV"
echo "ASSET_NAME=$asset" >> "$GITHUB_ENV"
echo "BRANCH=update-rd-pipe-$tag" >> "$GITHUB_ENV"

- name: Check if branch already exists
run: |
set -euo pipefail
if git ls-remote --exit-code --heads origin "$BRANCH" >/dev/null 2>&1; then
echo "Branch $BRANCH already exists on origin; skipping."
echo "SKIP=1" >> "$GITHUB_ENV"
fi

- name: Download release asset
if: env.SKIP != '1'
run: |
set -euo pipefail
mkdir -p "$RUNNER_TEMP/rdpipe"
gh release download "$TAG" \
--repo "$UPSTREAM" \
--pattern "$ASSET_NAME" \
--dir "$RUNNER_TEMP/rdpipe"

- name: Extract target DLLs
if: env.SKIP != '1'
run: |
set -euo pipefail
dest="$RUNNER_TEMP/rdpipe/extracted"
mkdir -p "$dest"
unzip -o "$RUNNER_TEMP/rdpipe/$ASSET_NAME" \
'arm64/rd_pipe.dll' 'x86/rd_pipe.dll' 'x64/rd_pipe.dll' \
-d "$dest"
for arch in arm64 x86 x64; do
test -f "$dest/$arch/rd_pipe.dll" || { echo "Missing $arch/rd_pipe.dll in zip" >&2; exit 1; }
done

- name: Compare SHA256 hashes
if: env.SKIP != '1'
run: |
set -euo pipefail
src="$RUNNER_TEMP/rdpipe/extracted"
changed=0
changed_archs=""
for arch in arm64 x86 x64; do
new=$(sha256sum "$src/$arch/rd_pipe.dll" | awk '{print $1}')
old=$(sha256sum "addon/dll/$arch/rd_pipe.dll" | awk '{print $1}')
echo "$arch: old=$old new=$new"
if [ "$new" != "$old" ]; then
changed=1
changed_archs="$changed_archs $arch"
fi
done
echo "CHANGED=$changed" >> "$GITHUB_ENV"
echo "CHANGED_ARCHES=${changed_archs# }" >> "$GITHUB_ENV"
if [ "$changed" = "0" ]; then
echo "All DLLs match upstream $TAG; nothing to do."
fi

- name: Copy updated DLLs
if: env.SKIP != '1' && env.CHANGED == '1'
run: |
set -euo pipefail
src="$RUNNER_TEMP/rdpipe/extracted"
for arch in arm64 x86 x64; do
cp "$src/$arch/rd_pipe.dll" "addon/dll/$arch/rd_pipe.dll"
done

- name: Configure git identity
if: env.SKIP != '1' && env.CHANGED == '1'
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"

- name: Create branch, commit, push
if: env.SKIP != '1' && env.CHANGED == '1'
run: |
set -euo pipefail
git checkout -b "$BRANCH"
git add addon/dll/arm64/rd_pipe.dll addon/dll/x86/rd_pipe.dll addon/dll/x64/rd_pipe.dll
git commit -m "Update rd_pipe DLLs to $TAG"
git push -u origin "$BRANCH"

- name: Create pull request
if: env.SKIP != '1' && env.CHANGED == '1'
run: |
set -euo pipefail
body=$(cat <<EOF
Auto-generated by \`.github/workflows/update_rd_pipe_dlls.yml\`.

Upstream release: $RELEASE_URL
Tag: \`$TAG\`
Changed architectures: $CHANGED_ARCHES
EOF
)
pr_url=$(gh pr create \
--title "Update rd_pipe DLLs to $TAG" \
--body "$body" \
--base main \
--head "$BRANCH")
echo "PR_URL=$pr_url" >> "$GITHUB_ENV"

- name: Enable auto-merge
if: env.SKIP != '1' && env.CHANGED == '1'
run: gh pr merge --auto --squash "$PR_URL"