|
| 1 | +name: Update Dependent Repos |
| 2 | + |
| 3 | +on: |
| 4 | + release: |
| 5 | + types: published |
| 6 | + workflow_dispatch: |
| 7 | + inputs: |
| 8 | + version: |
| 9 | + description: "Release version to update dependents" |
| 10 | + required: true |
| 11 | + |
| 12 | +jobs: |
| 13 | + update-dependents: |
| 14 | + name: Update ${{ matrix.repo }} |
| 15 | + runs-on: ubuntu-latest |
| 16 | + strategy: |
| 17 | + fail-fast: false |
| 18 | + matrix: |
| 19 | + repo: |
| 20 | + - matlab-actions/run-command |
| 21 | + - matlab-actions/run-tests |
| 22 | + - matlab-actions/run-build |
| 23 | + steps: |
| 24 | + - name: Checkout dependent repo |
| 25 | + uses: actions/checkout@v6 |
| 26 | + with: |
| 27 | + repository: ${{ matrix.repo }} |
| 28 | + token: ${{ secrets.REPOS_ACCESS_TOKEN }} |
| 29 | + |
| 30 | + - uses: actions/setup-node@v6 |
| 31 | + with: |
| 32 | + node-version: 24 |
| 33 | + |
| 34 | + - name: Update common-utils dependency |
| 35 | + run: | |
| 36 | + NEW_VERSION="${{ github.event.release.tag_name || inputs.version }}" |
| 37 | +
|
| 38 | + # Update the dependency reference in package.json |
| 39 | + sed -i "s|\"common-utils\": \"github:matlab-actions/common-utils#.*\"|\"common-utils\": \"github:matlab-actions/common-utils#${NEW_VERSION}\"|" package.json |
| 40 | +
|
| 41 | + # Regenerate package-lock.json with the new version |
| 42 | + npm install --package-lock-only |
| 43 | +
|
| 44 | + - name: Commit and push changes |
| 45 | + run: | |
| 46 | + VERSION="${{ github.event.release.tag_name || inputs.version }}" |
| 47 | + BRANCH="update-common-utils-${VERSION}" |
| 48 | +
|
| 49 | + git config user.name "github-actions[bot]" |
| 50 | + git config user.email "github-actions[bot]@users.noreply.github.com" |
| 51 | + git checkout -b "${BRANCH}" |
| 52 | + git add package.json package-lock.json |
| 53 | + git commit -m "Bump common-utils to ${VERSION}" |
| 54 | + git push origin "${BRANCH}" |
| 55 | +
|
| 56 | + - name: Create pull request |
| 57 | + env: |
| 58 | + GH_TOKEN: ${{ secrets.REPOS_ACCESS_TOKEN }} |
| 59 | + run: | |
| 60 | + VERSION="${{ github.event.release.tag_name || inputs.version }}" |
| 61 | + BRANCH="update-common-utils-${VERSION}" |
| 62 | +
|
| 63 | + gh pr create \ |
| 64 | + --repo ${{ matrix.repo }} \ |
| 65 | + --base main \ |
| 66 | + --head "${BRANCH}" \ |
| 67 | + --title "Bump common-utils to ${VERSION}" \ |
| 68 | + --body "Automated PR to update \`common-utils\` dependency to [${VERSION}](https://github.com/matlab-actions/common-utils/releases/tag/${VERSION})." |
0 commit comments