#!/usr/bin/env bash

set -eo pipefail

rm -rf /tmp/release
mkdir -p /tmp/release
cp clj-kondo /tmp/release

VERSION=$(cat resources/CLJ_KONDO_VERSION)

if [[ "$CLJ_KONDO_PLATFORM" = "linux" && "$CLJ_KONDO_ARCH" = "amd64" ]]; then
    jar="target/clj-kondo-$VERSION-standalone.jar"
    bb release-artifact "$jar"
    cp "$jar" /tmp/release
fi

cd /tmp/release

## release binary as zip archive

archive="clj-kondo-$VERSION-$CLJ_KONDO_PLATFORM-${CLJ_KONDO_ARCH:-amd64}.zip"

zip "$archive" clj-kondo

cd -

bb release-artifact "/tmp/release/$archive"

## cleanup

cd /tmp/release
rm clj-kondo
