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

steps:
  - name: scapy
    environment:
      PROJECT_NAME: scapy
      PROJECT_PRETTY_NAME: Scapy
      PROJECT_VERSION: 2.6.1
      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="v$PROJECT_VERSION"
      - GIT_URL="https://github.com/secdev/scapy.git"
      - . ./scripts/environment.sh
      - pipx install tox
      - . ./scripts/install_doc2dash.sh
      # Build scapy docs
      - . ./scripts/download_from_git.sh
      - cd "$BASE_DIRECTORY/scapy/doc/scapy/"
      - tox -e docs
      - doc2dash _build/html
      # Build icons
      # old style
      - convert -resize 16x16 ../scapy_logo.png Scapy.docset/icon.png
      - convert -resize 32x32 ../scapy_logo.png Scapy.docset/icon@2x.png
      # new style
      # - magick ../scapy_logo.png -resize 16x16 Scapy.docset/icon.png
      # - magick ../scapy_logo.png -resize 32x32 Scapy.docset/icon@2x.png
      # Build tgz
      - tar czf "$BASE_DIRECTORY/Scapy.docset.tgz" Scapy.docset
      - cd "$FEED_DIRECTORY"
      - . ./scripts/create_feed.sh
      - . ./scripts/publish.sh
