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

steps:
  - name: fping
    environment:
      PROJECT_NAME: fping
      PROJECT_PRETTY_NAME: fping
      PROJECT_VERSION: 5.2
      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:
      - TARBALL_URL="https://github.com/schweikert/fping/releases/download/v$PROJECT_VERSION/fping-$PROJECT_VERSION.tar.gz"
      - . ./scripts/environment.sh
      - . ./scripts/install_dashing.sh
      - . ./scripts/download_tarball.sh
      - . ./scripts/prepare_docs_directory.sh
      - pod2html --noindex --infile=../fping-$PROJECT_VERSION/doc/fping.pod --outfile=../docs/fping.html --title="fping man-page"
      - |
          cat << EOF > "$DOCS_DIRECTORY/dashing.json"
          {
              "name": "fping",
              "package": "fping",
              "index": "fping.html",
              "selectors": {
                  "title": "Guide",
                  "dl dt": "Option"
              },
              "allowJS": false
          }
          EOF
      - . ./scripts/build_dashing.sh
      - . ./scripts/create_docs_tarball.sh
      - . ./scripts/create_feed.sh
      - . ./scripts/publish.sh
