name: Release

on:
  push:
    branches:
      - main
  workflow_dispatch:
    # Allow manual triggering
  workflow_run:
    workflows: ["Update AWS SDK Dependencies"]
    types: ["completed"]

permissions:
  id-token: write  # Required for OIDC
  contents: read

jobs:
  release:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout code
        uses: actions/checkout@v4
        with:
          fetch-depth: 0

      - name: Setup Node.js
        uses: actions/setup-node@v4
        with:
          node-version: lts/*

          # This is necessary for publishing to work
          registry-url: 'https://registry.npmjs.org/'

      - name: Install dependencies
        run: yarn

      - name: Run build
        run: yarn build

      - name: Publish to NPM
        run: npm publish
