name: Remove tag
on:
  workflow_dispatch:
    inputs:
      tag:
        description: The tag to remove
        required: true
        type: string
      message:
        description: Deprecation message
        required: false
        type: string
jobs:
  removal:
    runs-on: ubuntu-latest
    if: github.repository_owner == 'discordjs'
    strategy:
      matrix:
        package:
          - '@discordjs/brokers'
          - '@discordjs/builders'
          - '@discordjs/collection'
          - '@discordjs/core'
          - 'create-discord-app'
          - 'create-discord-bot'
          - '@discordjs/formatters'
          - 'discord.js'
          - '@discordjs/next'
          - '@discordjs/proxy'
          - '@discordjs/rest'
          - '@discordjs/structures'
          - '@discordjs/util'
          - '@discordjs/voice'
          - '@discordjs/ws'
      fail-fast: false
    steps:
      - name: Checkout repository
        uses: actions/checkout@v6

      - name: Install Node.js
        uses: actions/setup-node@v6
        with:
          node-version: 24
          registry-url: 'https://registry.npmjs.org'

      - name: Install dependencies
        uses: ./packages/actions/src/pnpmCache

      - name: Remove tag
        run: pnpm dist-tag rm "${{ matrix.package }}" "${{ inputs.tag }}"
        env:
          NODE_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}

      - name: Deprecate version
        uses: ./packages/actions/src/deprecateVersion
        with:
          package: ${{ matrix.package }}
          version: '*-${{ inputs.tag }}.*'
          message: ${{ inputs.message }}
          node-auth-token: ${{ secrets.NPM_PUBLISH_TOKEN }}
