#!/bin/bash

DISTRO=debian
CODENAME=stretch

VERSION="$1"
REPO="flb-$DISTRO-$CODENAME"
PACKAGE=~/apt/${DISTRO}/${CODENAME}/td-agent-bit_${VERSION}_*.deb

if [ -z $1 ]; then
    echo "Usage: ./publish  new_version"
    echo "                       |      "
    echo "                     -----    "
    echo "                     1.6.0    "
    echo
    exit 1
fi

aptly repo add ${REPO} ~/apt/${DISTRO}/${CODENAME}/td-agent-bit_${VERSION}_*.deb

aptly snapshot create fluent-bit-${DISTRO}-${CODENAME}-${VERSION} from repo ${REPO}

# Second time publishing
aptly publish switch \
      ${CODENAME} filesystem:${DISTRO}/${CODENAME}: fluent-bit-${DISTRO}-${CODENAME}-${VERSION}
