---
# https://github.com/semantic-release/semantic-release#commit-message-format
# https://levelup.gitconnected.com/semantic-versioning-and-release-automation-on-gitlab-9ba16af0c21
include:
  - remote: https://jobs.just-ci.dev/v9.0.0/project-automation/generic.yaml

variables:
  SEMANTIC_RELEASE_RELEASERC: https://jobs.just-ci.dev/v9.0.0/project-automation/release/releaserc-default.cjs

semantic-release:
  extends: .release:rules
  image: registry.gitlab.com/just-ci/images/node:alpine
  stage: .post
  variables:
    NPM_PACKAGES:
      semantic-release @semantic-release/gitlab @semantic-release/git
      @semantic-release/changelog semantic-release-replace-plugin
      conventional-changelog-conventionalcommits js-yaml
  script:
    - !reference [".release:install", script]
    - !reference [".release:configure", script]
    - export GIT_AUTHOR_EMAIL="$(curl -s -X GET -H "PRIVATE-TOKEN:$GL_TOKEN"
      "${CI_API_V4_URL}/user" | jq -r '.email')"
    - export GIT_COMMITTER_EMAIL="${GIT_AUTHOR_EMAIL}"
    - semantic-release ${SEMANTIC_RELEASE_EXTRA_ARGS}

semantic-release:GL_TOKEN:
  extends: .fix:GL_TOKEN
  variables:
    JOB_NAME: semantic-release
