name: GitHub release

on:
  push:
    tags:
      - "*"

jobs:
  tagged-release:
    runs-on: ubuntu-latest

    steps:
      # Checkout the exact commit tagged on the release.
      - name: Checkout repository
        uses: actions/checkout@v4
        with:
          ref: ${{ github.event.release.target_commitish }}

      - name: Use NodeJS
        uses: actions/setup-node@v4
        with:
          node-version: 22.x

      # If we can't build the release will be canceled.
      - name: Install dependencies and build
        run: |
          npm install
          npm run build

      - uses: marvinpinto/action-automatic-releases@latest
        with:
          repo_token: ${{ secrets.GITHUB_TOKEN }}
          prerelease: false
