build/changelog.sh
nyyu a138eb6a0d
Some checks failed
ci/woodpecker/push/sync Pipeline was successful
ci/woodpecker/manual/sync Pipeline failed
ci/woodpecker/manual/build-wifi unknown status
ci/woodpecker/manual/build-lte unknown status
ci/woodpecker/manual/changelog unknown status
ci/woodpecker/manual/copy unknown status
fix: gen changelog only after successful build
2023-05-20 08:06:57 +02:00

41 lines
1.2 KiB
Bash

#!/bin/bash -e
# shellcheck disable=SC2154,SC2207,SC2016,SC2086,SC2250,SC2312,SC2162
TOPDIR=$(pwd)
changelog=${TOPDIR}/changelog-${device}-${version}.md
declare -A before
if [[ -f gitstate-${device}-${version}.txt ]]
then
read -a tmp < gitstate-${device}-${version}.txt
else
tmp=($(repo forall -c 'echo "${REPO_PATH}:$(git rev-parse --short HEAD)"'))
fi
for i in "${tmp[@]}"; do
IFS=: read -r folder commit <<<"${i}"
before[${folder}]=${commit}
done
echo -e "# Build $(date '+%Y-%m-%d %H:%M:%S %Z')\n" >>"${changelog}"
tmp=($(repo forall -c 'echo "${REPO_PATH}:$(git rev-parse --short HEAD)"'))
for i in "${tmp[@]}"; do
IFS=: read -r folder commit <<<"${i}"
if [[ "${folder}" != lineage/* && "${before[${folder}]}" != "${commit}" ]]; then
cd "${folder}" || continue
log=$(git --no-pager log --pretty=format:"- %s" "${before[${folder}]}".."${commit}")
if [[ $(echo -n "$log" | wc -c) != 0 ]]; then
{
echo "## ${folder} ${before[${folder}]}..${commit}"
echo "$log"
echo
} >>"${changelog}"
fi
cd "${TOPDIR}" || continue
fi
done
cat "${changelog}"
echo "${tmp[@]}" > gitstate-${device}-${version}.txt