stages:
  - release

semantic-release:
  stage: release
  image: node:lts-alpine
  id_tokens:
    NPM_ID_TOKEN:
      aud: "npm:registry.npmjs.org"
    SIGSTORE_ID_TOKEN:
      aud: sigstore
  before_script:
    - apk add git openssh
    - mkdir -p ~/.ssh
    - echo "$SSH_PRIVATE_KEY" > ~/.ssh/id_ed25519
    - ssh-keyscan -H gitlab.com >> ~/.ssh/known_hosts
    - chmod 600 ~/.ssh/id_ed25519
    - npm install
    - npm run build
  script:
    - npx semantic-release
  only:
    - main
