when:
  - event: manual
    branch: main
  - event: push
    branch: main
    path: '.woodpecker/xca.yaml'

steps:
  - name: xca
    environment:
      PROJECT_NAME: xca
      PROJECT_PRETTY_NAME: xca
      PROJECT_VERSION: 2.8.0
      FEED_REVISION: 1

      CODEBERG_GIT_USERNAME:
        from_secret: codeberg_git_username
      CODEBERG_GIT_PASSWORD:
        from_secret: codeberg_git_password
    image: codeberg.org/mark22k/ci:latest
    pull: true
    commands:
      - GIT_BRANCH="RELEASE.$PROJECT_VERSION"
      - GIT_URL="https://github.com/chris2511/xca.git"
      - . ./scripts/environment.sh
      # Install python tools
      - . ./scripts/install_doc2dash.sh
      - . ./scripts/install_sphinx.sh
      - pipx inject sphinx sphinxcontrib-qthelp
      # Build xca docs
      - . ./scripts/download_from_git.sh
      - cd "$BASE_DIRECTORY/xca/"
      - cmake -DCMAKE_BUILD_TYPE=Release -B build
      - cmake --build build -t sphinx-html
      - doc2dash build/doc/html
      # Build icons
      # old style
      - convert -resize 16x16 img/xca-icons.iconset/icon_16x16.png xca.docset/icon.png
      - convert -resize 32x32 img/xca-icons.iconset/icon_32x32.png xca.docset/icon@2x.png
      # new style
      # - magick img/xca-icons.iconset/icon_16x16.png -resize 16x16 xca.docset/icon.png
      # - magick img/xca-icons.iconset/icon_32x32.png -resize 32x32 xca.docset/icon@2x.png
      # Build tgz
      - tar czf "$BASE_DIRECTORY/xca.docset.tgz" xca.docset
      - cd "$FEED_DIRECTORY"
      - . ./scripts/create_feed.sh
      - . ./scripts/publish.sh
