arch-pkgbuilder/plugins/github-tag

77 lines
2.1 KiB
Plaintext
Raw Normal View History

2023-01-13 22:04:14 +00:00
#!/bin/bash
plugin_isupdatable() {
return 0
}
plugin_isbumpable() {
return 0
}
plugin_getpkgfiles() {
echo "${PKGDIR}/${PKGNAME}/files"
}
plugin_bump() {
2023-01-13 23:24:36 +00:00
local -r PKGREL=$(readSetting "${PKGBUILD}" "pkgrel" 0)
sed -i "s/pkgrel=.*/pkgrel=$((PKGREL+1))/" "${PKGBUILD}"
2023-01-13 22:04:14 +00:00
}
plugin_getlatestversion() {
local -r GITHUBUSER=$(readSetting "${PKGSETTINGS}" "githubuser" "")
local -r GITHUBREPO=$(readSetting "${PKGSETTINGS}" "githubrepo" "")
local GITHUBTAGNAME=""
if ! GITHUBTAGNAME=$(curl -sL "https://api.github.com/repos/${GITHUBUSER}/${GITHUBREPO}/tags" | jq -r ".[0].name"); then
echo "Error in Github API"
return 1
fi
if [ "${GITHUBTAGNAME}" == "" ]; then
echo "Error in Github API"
return 1
fi
local -r GITHUBVERSION=${GITHUBTAGNAME//[[:alpha:]]/}
if [ "${GITHUBVERSION}" == "" ]; then
echo "Error in Github API"
return 1
fi
local -r PKGVERSION=$(readSetting "${PKGSETTINGS}" "pkgver" "0")
if [[ "${PKGVERSION}" == "${GITHUBVERSION}" ]]; then
readSetting "${PKGSETTINGS}" "version" "0"
else
echo "${GITHUBVERSION}-1"
fi
}
plugin_update() {
local -r GITHUBUSER=$(readSetting "${PKGSETTINGS}" "githubuser" "")
local -r GITHUBREPO=$(readSetting "${PKGSETTINGS}" "githubrepo" "")
local GITHUBTAGNAME=""
if ! GITHUBTAGNAME=$(curl -sL "https://api.github.com/repos/${GITHUBUSER}/${GITHUBREPO}/tags" | jq -r ".[0].name"); then
echo "Error in Github API"
return 1
fi
if [ "${GITHUBTAGNAME}" == "" ]; then
echo "Error in Github API"
return 1
fi
local -r GITHUBVERSION=${GITHUBTAGNAME//[[:alpha:]]/}
if [ "${GITHUBVERSION}" == "" ]; then
echo "Error in Github API"
return 1
fi
local -r PKGVERSION=$(readSetting "${PKGSETTINGS}" "pkgver" "0")
if [[ "${PKGVERSION}" == "${GITHUBVERSION}" ]]; then
return 0
fi
writeSetting "${PKGSETTINGS}" "pkgrel" "1"
writeSetting "${PKGBUILD}" "_githubuser" "${GITHUBUSER}"
writeSetting "${PKGBUILD}" "_githubrepo" "${GITHUBREPO}"
writeSetting "${PKGBUILD}" "_pkgtagname" "${GITHUBTAGNAME}"
writeSetting "${PKGBUILD}" "pkgname" "${PKGNAME}"
writeSetting "${PKGBUILD}" "pkgrel" "1"
writeSetting "${PKGBUILD}" "pkgver" "${GITHUBVERSION}"
2023-01-13 23:24:36 +00:00
updatePkgSums "${PKGDIR}"/"${PKGNAME}"/files
2023-01-13 22:04:14 +00:00
}