# CI script for creating releases

create-release:
  stage: deploy
  image: registry.gitlab.com/gitlab-org/release-cli:latest
  rules:
    - if: $CI_COMMIT_TAG && $CI_PROJECT_PATH == "wine/wine"
  script:
    - VERSION=$(expr "$CI_COMMIT_TAG" ":" 'wine-\(.*\)')
    - URL=$(grep -o "https://dl.winehq.org/.*" ANNOUNCE)
    - FILEPATH=$(expr "$URL" ":" '.*\(/.*\)')
    - |
      sed -e '/^The source/,/^----------/d
      /^----------/,$d
      /^Bugs fixed/i--------
      s/^\*\*\*/###/' ANNOUNCE >announce.md
    - release-cli create
        --name "Wine $VERSION"
        --tag-name "$CI_COMMIT_TAG"
        --description announce.md
        --assets-link "{\"name\":\"Source code\",\"url\":\"$URL\",\"link_type\":\"other\",\"filepath\":\"$FILEPATH\"}"
