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

steps:
  - name: socat
    environment:
      PROJECT_NAME: socat
      PROJECT_PRETTY_NAME: socat
      PROJECT_VERSION: 1.8.0.1
      FEED_REVISION: 2

      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:
      - TARBALL_URL="http://www.dest-unreach.org/socat/download/socat-$PROJECT_VERSION.tar.gz"
      - . ./scripts/environment.sh
      - . ./scripts/install_dashing.sh
      - . ./scripts/download_tarball.sh
      - . ./scripts/prepare_docs_directory.sh
      - cp "$BASE_DIRECTORY/socat-$PROJECT_VERSION/doc/"*.html "$DOCS_DIRECTORY"
      - cp "$BASE_DIRECTORY/socat-$PROJECT_VERSION/doc/"*.css "$DOCS_DIRECTORY"
      - |
          cat << EOF > "$DOCS_DIRECTORY/dashing.json"
          {
              "name": "socat",
              "package": "socat",
              "index": "socat.html",
              "selectors": {
                  "dl dt strong strong code": "Option",
                  "h2": "Section",
                  "title": "Guide"
              },
              "ignore": ["", "<strong>socat</strong>"],
              "allowJS": false
          }
          EOF
      - . ./scripts/build_dashing.sh
      - . ./scripts/create_docs_tarball.sh
      - . ./scripts/create_feed.sh
      - . ./scripts/publish.sh
