#!/bin/bash

# root 권한 체크
if [ "$EUID" -ne 0 ]; then
  echo "Error: 이 스크립트는 root 권한으로 실행해야 합니다." >&2
  exit 1
fi

#https://lindevs.com/install-git-cliff-on-ubuntu

GIT_CLIFF_VERSION=$(curl -s "https://api.github.com/repos/orhun/git-cliff/releases/latest" | grep -Po '"tag_name": "v\K[0-9.]+')
wget -qO git-cliff.tar.gz "https://github.com/orhun/git-cliff/releases/latest/download/git-cliff-$GIT_CLIFF_VERSION-$(arch)-unknown-linux-gnu.tar.gz"
mkdir git-cliff-temp
tar xf git-cliff.tar.gz --strip-components=1 -C git-cliff-temp

mv git-cliff-temp/git-cliff /usr/local/bin
git cliff --version
rm -rf git-cliff.tar.gz git-cliff-temp
