Skip to content

Update Registry Dependency #11

Update Registry Dependency

Update Registry Dependency #11

name: Update Registry Dependency
on:
schedule:
# Run weekly on Mondays at 9 AM UTC
- cron: '0 9 * * 1'
workflow_dispatch: # Allow manual triggering
jobs:
update-registry:
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- name: Generate GitHub App Token
id: generate-token
uses: actions/create-github-app-token@v2
with:
app-id: ${{ secrets.HYPER_GONK_APP_ID }}
private-key: ${{ secrets.HYPER_GONK_PRIVATE_KEY }}
- name: Checkout repository
uses: actions/checkout@v6
with:
ref: main
token: ${{ steps.generate-token.outputs.token }}
- name: Get GitHub App User ID
id: get-user-id
run: echo "user-id=$(gh api /users/${{ steps.generate-token.outputs.app-slug }}[bot] --jq .id)" >> "$GITHUB_OUTPUT"
env:
GH_TOKEN: ${{ steps.generate-token.outputs.token }}
- name: Configure Git
run: |
git config user.name "${{ steps.generate-token.outputs.app-slug }}[bot]"
git config user.email "${{ steps.get-user-id.outputs.user-id }}+${{ steps.generate-token.outputs.app-slug }}[bot]@users.noreply.github.com"
- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version-file: .nvmrc
- name: Setup pnpm
uses: pnpm/action-setup@v4
- name: Get latest Registry version
id: get-version
run: |
LATEST_REGISTRY=$(npm view @hyperlane-xyz/registry version)
echo "registry=$LATEST_REGISTRY" >> $GITHUB_OUTPUT
echo "Latest Registry: $LATEST_REGISTRY"
- name: Update registry dependency in all packages
run: |
NEW_VERSION="${{ steps.get-version.outputs.registry }}"
echo "Updating @hyperlane-xyz/registry to $NEW_VERSION"
# Find all package.json files that have @hyperlane-xyz/registry and update them
find typescript -name 'package.json' -type f | while read pkg; do
if grep -q '"@hyperlane-xyz/registry"' "$pkg"; then
echo "Updating $pkg"
# Use node to update the version properly
node -e "
const fs = require('fs');
const pkg = JSON.parse(fs.readFileSync('$pkg', 'utf8'));
if (pkg.dependencies && pkg.dependencies['@hyperlane-xyz/registry']) {
pkg.dependencies['@hyperlane-xyz/registry'] = '$NEW_VERSION';
}
if (pkg.devDependencies && pkg.devDependencies['@hyperlane-xyz/registry']) {
pkg.devDependencies['@hyperlane-xyz/registry'] = '$NEW_VERSION';
}
fs.writeFileSync('$pkg', JSON.stringify(pkg, null, 2) + '\n');
"
fi
done
- name: Install dependencies
run: pnpm install --no-frozen-lockfile
- name: Check for changes and create PR
env:
GITHUB_TOKEN: ${{ steps.generate-token.outputs.token }}
run: |
if ! git diff --quiet; then
git checkout -b ci/update-registry-dep
git add -A
git commit -m "chore: update @hyperlane-xyz/registry to ${{ steps.get-version.outputs.registry }}
- Update @hyperlane-xyz/registry to ${{ steps.get-version.outputs.registry }}
- Update pnpm-lock.yaml"
git push -fu origin ci/update-registry-dep
PR_TITLE="chore: update @hyperlane-xyz/registry to ${{ steps.get-version.outputs.registry }}"
PR_BODY="## Automated Dependency Update
This PR updates the @hyperlane-xyz/registry dependency to the latest version.
**Updated version:**
- \`@hyperlane-xyz/registry\`: \`${{ steps.get-version.outputs.registry }}\`
**Changes include:**
- Updated \`package.json\` files with latest registry version
- Updated \`pnpm-lock.yaml\` via \`pnpm install\`
---
🤖 This PR was automatically generated by the [update-registry-dep workflow](.github/workflows/update-registry-dep.yml)"
PR_EXISTS=$(gh pr list --base main --head ci/update-registry-dep --json number --jq length)
if [ "$PR_EXISTS" -eq "0" ]; then
gh pr create \
--base main \
--head ci/update-registry-dep \
--title "$PR_TITLE" \
--body "$PR_BODY"
else
echo "Pull request already exists. Updating title and description..."
gh pr edit ci/update-registry-dep \
--title "$PR_TITLE" \
--body "$PR_BODY"
fi
else
echo "No changes detected. Skipping PR creation."
fi