#!/bin/sh

set -e

VERSION="$1"
OUTFILE="out/libtravel-status-de-dbris-perl_${VERSION}-1-1_all.deb"
DEBFILE="/var/www/html/deb/libtravel-status-de-dbris-perl_${VERSION}-1_all.deb"

test -n "${VERSION}"

git checkout main

git pull
git submodule update --init

git checkout "${VERSION}"

scripts/makedeb-docker

chmod 644 "${OUTFILE}"
mv "${OUTFILE}" "${DEBFILE}"
aptly repo add finalrewind "${DEBFILE}"
aptly publish update stable
chmod -R a+rX ~/.aptly/public
