name: Release

permissions:
  id-token: write
  contents: write

on:
  schedule:
    - cron: "0 */24 * * *"
  workflow_dispatch: {}

jobs:
  release:
    name: release
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v6
      - uses: actions/setup-node@v6
        with:
          node-version: '24'
      - name: Update npm
        run: npm install -g npm@latest
      - name: Update and Publish
        run: |
          git config --global user.name "github-actions"
          git config --global user.email "github-actions@users.noreply.github.com"

          npm update all-the-package-repos
          npm run build
          npm test
          
          # bail if no changes are present
          [[ `git status --porcelain` ]] || exit 0

          git add .
          # bump the version, commit, and create a tag
          npm version patch -f -m "Update all-the-package-types to %s"

          git push origin master --follow-tags
          npm publish
