name: Publish @hugo-fixit/encrypt

on:
  push:
    tags:
      - 'encrypt-v*.*.*'
  workflow_dispatch:

permissions:
  contents: read
  id-token: write

concurrency:
  group: publish-encrypt-${{ github.ref }}
  cancel-in-progress: false

jobs:
  publish:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout repository
        uses: actions/checkout@v7

      - uses: pnpm/action-setup@v6
      - name: Setup Node.js
        uses: actions/setup-node@v7
        with:
          node-version-file: .nvmrc
          registry-url: 'https://registry.npmjs.org'
          cache: pnpm
          scope: '@hugo-fixit'

      - name: Update npm
        run: npm install -g npm@latest
      - name: Install dependencies
        run: pnpm install --frozen-lockfile

      - name: Build package
        run: pnpm -F encrypt build

      - name: Publish package to npm
        working-directory: packages/encrypt
        run: npm publish --access public --provenance
