pipeline:
  audit:
    image: dbrgn/cargo-audit
    commands:
        - cargo audit

  build:
    image: sebastian/apt-decoder-ci
    commands:
        - export CARGO_HOME=/root/.cargo
        - cargo build --release
        - mkdir -p ./cargo-home-cache
        - cp -r $CARGO_HOME/* ./cargo-home-cache

  build_appimage:
    image: sebastian/apt-decoder-ci
    group: build_release_files
    commands:
        - export CARGO_HOME=/root/.cargo
        - cp -r ./cargo-home-cache/* $CARGO_HOME/
        - cargo appimage
        - mkdir -p release
        - cp *.AppImage release/

  build_windows:
    image: sebastian/apt-decoder-ci
    group: build_release_files
    commands:
        - export CARGO_HOME=/root/.cargo
        - cp -r ./cargo-home-cache/* $CARGO_HOME/
        - cargo build --target x86_64-pc-windows-gnu --release
        - mkdir -p release
        - cp target/x86_64-pc-windows-gnu/release/apt-decoder.exe release/
        - cd release && zip apt-decoder-win.zip apt-decoder.exe && rm apt-decoder.exe

  release:
    image: plugins/gitea-release
    settings:
      files: release/*
      api_key:
        from_secret: api_key
      base_url:
        from_secret: base_url
    secrets: [api_key, base_url]
    when:
      event: tag
