mirror of
https://github.com/oven-sh/bun
synced 2026-02-02 15:08:46 +00:00
61 lines
2.2 KiB
YAML
61 lines
2.2 KiB
YAML
name: Update c-ares
|
|
|
|
on:
|
|
schedule:
|
|
- cron: "0 0 * * 0"
|
|
workflow_dispatch:
|
|
|
|
jobs:
|
|
check-update:
|
|
runs-on: ubuntu-latest
|
|
permissions:
|
|
contents: write
|
|
pull-requests: write
|
|
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Check c-ares version
|
|
id: check-version
|
|
run: |
|
|
CURRENT_VERSION=$(grep -oP 'CARES_VERSION\s+\K\S+' cmake/targets/BuildCares.cmake)
|
|
if [ -z "$CURRENT_VERSION" ]; then
|
|
echo "Error: Could not find current version in BuildCares.cmake"
|
|
exit 1
|
|
fi
|
|
echo "current=$CURRENT_VERSION" >> $GITHUB_OUTPUT
|
|
|
|
LATEST_RELEASE=$(curl -sL https://api.github.com/repos/c-ares/c-ares/releases/latest)
|
|
LATEST_TAG=$(echo "$LATEST_RELEASE" | jq -r '.tag_name')
|
|
LATEST_SHA=$(curl -sL "https://api.github.com/repos/c-ares/c-ares/git/ref/tags/$LATEST_TAG" | jq -r '.object.sha')
|
|
if [ -z "$LATEST_SHA" ]; then
|
|
echo "Error: Could not fetch latest version from GitHub API"
|
|
exit 1
|
|
fi
|
|
if [ ${#LATEST_SHA} -ne 40 ]; then
|
|
echo "Error: Invalid SHA length"
|
|
exit 1
|
|
fi
|
|
echo "latest=$LATEST_SHA" >> $GITHUB_OUTPUT
|
|
|
|
- name: Create PR if update needed
|
|
if: success() && steps.check-version.outputs.current != steps.check-version.outputs.latest
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
run: |
|
|
BRANCH="update-cares-${GITHUB_SHA::8}"
|
|
git checkout -b "$BRANCH"
|
|
|
|
sed -i "s/CARES_VERSION\s\+[0-9a-f]\+/CARES_VERSION ${{ steps.check-version.outputs.latest }}/" cmake/targets/BuildCares.cmake
|
|
|
|
git config user.name "github-actions[bot]"
|
|
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
|
|
git add cmake/targets/BuildCares.cmake
|
|
git commit -m "deps: update c-ares to ${{ steps.check-version.outputs.latest }}"
|
|
git push origin "$BRANCH"
|
|
|
|
gh pr create \
|
|
--title "deps: update c-ares to ${LATEST_SHA::8}" \
|
|
--body "Updates c-ares from ${CURRENT_VERSION::8} to ${LATEST_SHA::8}" \
|
|
--base main \
|
|
--head "$BRANCH" |