diff --git a/.github/workflows/namespace_declarations.yml b/.github/workflows/namespace_declarations.yml index 730717522d51..3281bc63a614 100644 --- a/.github/workflows/namespace_declarations.yml +++ b/.github/workflows/namespace_declarations.yml @@ -83,11 +83,6 @@ jobs: make install-node-modules || make install-node-modules || make install-node-modules timeout-minutes: 15 - # Update namespace Typescript declarations: - - name: 'Update declarations' - run: | - make list-pkgs-namespaces | node lib/node_modules/@stdlib/_tools/scripts/create_namespace_types.js - # Disable Git hooks: - name: 'Disable Git hooks' run: | @@ -103,44 +98,56 @@ jobs: git_user_signingkey: true git_commit_gpgsign: true - # Create a pull request with the updated declarations: - - name: 'Create pull request' - id: cpr - # Pin action to full length commit SHA - uses: peter-evans/create-pull-request@271a8d0340265f705b14b6d32b9829c1cb33d45e # v7.0.8 - with: - title: 'feat: update namespace TypeScript declarations' - body: | - This PR - - - updates namespace TypeScript declarations - - ## Reviewer Checklist - - - [ ] **Check the scope of the changes** (following [Conventional Commits](https://www.conventionalcommits.org)): - - Are these **new APIs**? Then this is a `feat`. - - Are these **changes to existing APIs** that could break compatibility? Then this is a `feat!` (i.e., a breaking change). - - Are these **only documentation** changes to existing APIs? Then this is `docs`. - - [ ] Update the PR title to align with the change type (`feat`, `feat!`, or `docs`). - - [ ] Approve the PR once you are confident about the classification and changes made. - - commit-message: 'feat: update namespace TypeScript declarations' - committer: 'stdlib-bot <82920195+stdlib-bot@users.noreply.github.com>' - signoff: true - token: ${{ secrets.STDLIB_BOT_PAT_REPO_WRITE }} - labels: | - documentation - automated-pr - team-reviewers: | - reviewers - branch: update-namespace-declarations - delete-branch: true - - # Create Markdown summary of the pull request: - - name: 'Create summary' + # Update namespace Typescript declarations and create PRs: + - name: 'Update declarations and create PRs' run: | - echo "# :tada: Pull Request created! :tada:" >> $GITHUB_STEP_SUMMARY - echo "" >> $GITHUB_STEP_SUMMARY - echo "Pull request ${{ steps.cpr.outputs.pull-request-number }} was successfully ${{ steps.cpr.outputs.pull-request-operation }}." - echo ":link: [${{ steps.cpr.outputs.pull-request-url }}](${{ steps.cpr.outputs.pull-request-url }})." >> $GITHUB_STEP_SUMMARY - echo "Head SHA: [${{ steps.cpr.outputs.pull-request-head-sha }}](${{ steps.cpr.outputs.pull-request-url }}/commits/${{ steps.cpr.outputs.pull-request-head-sha }})." >> $GITHUB_STEP_SUMMARY + # Create a temporary file to store the list of namespaces: + make list-pkgs-namespaces > namespaces.txt + + # Process each namespace: + while IFS= read -r namespace; do + if [ -n "$namespace" ] && [[ $namespace != *"_tools"* ]]; then + branch_name="update-$(echo "$namespace" | sed 's/@stdlib\///' | sed 's/\//-/g')-declarations" + git checkout -b "$branch_name" + + # Generate declarations for this namespace: + echo "$namespace" | node lib/node_modules/@stdlib/_tools/scripts/create_namespace_types.js + + # Check if there are changes: + if ! git diff --quiet -- lib/node_modules/@stdlib; then + # Stage only changes in the stdlib directory: + git add lib/node_modules/@stdlib + + # Commit changes: + git commit -m "feat: update \`${namespace}\` TypeScript declarations" --signoff + + # Push branch and create PR: + git push origin "$branch_name" + + gh pr create \ + --title "feat: update \`${namespace}\` TypeScript declarations" \ + --body "This PR updates TypeScript declarations for the \`${namespace}\` namespace. + + ## Reviewer Checklist + + - [ ] **Check the scope of the changes** (following [Conventional Commits](https://www.conventionalcommits.org)): + - Are these **new APIs**? Then this is a \`feat\`. + - Are these **changes to existing APIs** that could break compatibility? Then this is a \`feat!\` (i.e., a breaking change). + - Are these **only documentation** changes to existing APIs? Then this is \`docs\`. + - [ ] Update the PR title to align with the change type (\`feat\`, \`feat!\`, or \`docs\`). + - [ ] Approve the PR once you are confident about the classification and changes made." \ + --label "Documentation" \ + --label "automated-pr" \ + --reviewer "reviewers" \ + --base develop \ + --head "$branch_name" + fi + + git checkout develop + fi + done < namespaces.txt + + # Clean up temporary file: + rm namespaces.txt + env: + GITHUB_TOKEN: ${{ secrets.STDLIB_BOT_PAT_REPO_WRITE }}