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

steps:
  - name: stunnel
    environment:
      PROJECT_NAME: stunnel
      PROJECT_PRETTY_NAME: stunnel
      PROJECT_VERSION: 5.74
      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://www.stunnel.org/downloads/stunnel-$PROJECT_VERSION.tar.gz"
      - . ./scripts/environment.sh
      - . ./scripts/install_dashing.sh
      - . ./scripts/download_tarball.sh
      - . ./scripts/prepare_docs_directory.sh
      - cd "$BASE_DIRECTORY/stunnel-$PROJECT_VERSION"
      - ./configure
      - cd doc
      - make
      - cp "stunnel.html" "$BASE_DIRECTORY/docs/"
      - cp "stunnel.pl.html" "$BASE_DIRECTORY/docs/"
      - |
          cat <<EOF > "$DOCS_DIRECTORY/dashing.json"
          {
              "name": "stunnel",
              "package": "stunnel",
              "index": "stunnel.html",
              "selectors": {
                  "title": "Package",
                  "dl dt b": "Option"
              },
              "allowJS": false
          }
          EOF
      - cd "$FEED_DIRECTORY"
      - . ./scripts/build_dashing.sh
      - . ./scripts/create_docs_tarball.sh
      - . ./scripts/create_feed.sh
      - . ./scripts/publish.sh
