distributable:
  url: https://github.com/tramhao/termusic/archive/refs/tags/{{ version.tag }}.tar.gz
  strip-components: 1

provides:
  - bin/termusic
  - bin/termusic-server

versions:
  github: tramhao/termusic

dependencies:
  linux:
    alsa-project.org/alsa-lib: '*'
    freedesktop.org/dbus: '*'

companions:
  yt-dlp.org: '*' # download from youtube

build:
  dependencies:
    rust-lang.org: '>=1.75'
    rust-lang.org/cargo: '*'
    protobuf.dev: '*'
  script:
    # otherwise, it uses git sha for versioning
    - rm {tui,server}/build.rs
    - cargo build --release --all
    - run:
        - mkdir -p {{prefix}}/bin
        - install termusic {{prefix}}/bin/
        - install termusic-server {{prefix}}/bin/
      working-directory: target/release
  env:
    TERMUSIC_VERSION: v{{version}}[pkgx]

test:
  - termusic --version | grep {{version}}
  - termusic-server --version | grep {{version}}
  - run: termusic import $FIXTURE > out
    fixture:
      extname: opml
      content: |
        <opml version="2.0">
          <head>
            <title>Termusic Podcast Feeds</title>
            <dateCreated>Tue, 2 Jul 2024 18:27:17 +0000</dateCreated>
          </head>
          <body>
            <outline text="Revolutions" type="rss" xmlUrl="https://revolutionspodcast.libsyn.com/rss" title="Revolutions"/>
          </body>
        </opml>
  - grep 'Importing 1 podcasts...' out
  - grep 'Added Revolutions' out
  - grep 'Import successful.' out
