arch-pkgbuilder/plugins/github-release

81 lines
2.2 KiB
Plaintext
Raw Permalink Normal View History

2023-01-13 22:04:14 +00:00
#!/bin/bash
plugin_isupdatable() {
return 0
}
plugin_isbumpable() {
return 0
}
2023-01-14 14:55:17 +00:00
plugin_ispushabletoaur() {
return 0
}
2023-01-13 22:04:14 +00:00
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}/releases/latest" | jq -r ".tag_name"); then
echo "Error in Github API"
return 1
fi
if [ "${GITHUBTAGNAME}" == "" ]; then
echo "Error in Github API"
return 1
fi
2023-07-15 23:57:33 +00:00
local -r GITHUBVERSION=${GITHUBTAGNAME//[[:alpha:]-]/}
2023-01-13 22:04:14 +00:00
if [ "${GITHUBVERSION}" == "" ]; then
echo "Error in Github API"
return 1
fi
local -r PKGVERSION=$(readSetting "${PKGBUILD}" "pkgver" "0")
2023-01-13 22:04:14 +00:00
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}/releases/latest" | jq -r ".tag_name"); then
echo "Error in Github API"
return 1
fi
if [ "${GITHUBTAGNAME}" == "" ]; then
echo "Error in Github API"
return 1
fi
2023-07-15 23:57:33 +00:00
local -r GITHUBVERSION=${GITHUBTAGNAME//[[:alpha:]-]/}
2023-01-13 22:04:14 +00:00
if [ "${GITHUBVERSION}" == "" ]; then
echo "Error in Github API"
return 1
fi
local -r PKGVERSION=$(readSetting "${PKGBUILD}" "pkgver" "0")
2023-01-13 22:04:14 +00:00
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
}