neovim/ci/snap/deploy.sh
dundargoc caa6992a10
chore: fix typos (#16361)
Co-authored-by: Brede Yabo Sherling Kristensen <bredeyabo@hotmail.com>
Co-authored-by: zeertzjq <zeertzjq@outlook.com>
Co-authored-by: István Donkó <istvan.donko@gmail.com>
Co-authored-by: Julian Berman <Julian@GrayVines.com>
Co-authored-by: bryant <bryant@users.noreply.github.com>
Co-authored-by: Michael Lingelbach <m.j.lbach@gmail.com>
Co-authored-by: nlueb <9465658+nlueb@users.noreply.github.com>
Co-authored-by: Leonhard Saam <leonhard.saam@yahoo.com>
Co-authored-by: Jesse Wertheim <jaawerth@gmail.com>
Co-authored-by: dm1try <me@dmitry.it>
Co-authored-by: Jakub Łuczyński <doubleloop@o2.pl>
Co-authored-by: Louis Lebrault <louis.lebrault@gmail.com>
Co-authored-by: Brede Yabo Sherling Kristensen <bredeyabo@hotmail.com>
Co-authored-by: zeertzjq <zeertzjq@outlook.com>
Co-authored-by: István Donkó <istvan.donko@gmail.com>
Co-authored-by: Julian Berman <Julian@GrayVines.com>
Co-authored-by: bryant <bryant@users.noreply.github.com>
Co-authored-by: Michael Lingelbach <m.j.lbach@gmail.com>
Co-authored-by: nlueb <9465658+nlueb@users.noreply.github.com>
Co-authored-by: Leonhard Saam <leonhard.saam@yahoo.com>
Co-authored-by: Jesse Wertheim <jaawerth@gmail.com>
Co-authored-by: dm1try <me@dmitry.it>
Co-authored-by: Jakub Łuczyński <doubleloop@o2.pl>
Co-authored-by: Louis Lebrault <louis.lebrault@gmail.com>
2021-11-27 11:10:48 -05:00

40 lines
1.1 KiB
Bash
Executable File

#!/usr/bin/env bash
set -e
set -o pipefail
SNAP_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
WEBHOOK_PAYLOAD="$(cat "${SNAP_DIR}/.snapcraft_payload")"
PAYLOAD_SIG="${SECRET_SNAP_SIG}"
snap_realease_needed() {
last_committed_tag="$(git tag -l --sort=refname|head -1)"
last_snap_release="$(snap info nvim | awk '$1 == "latest/edge:" { print $2 }' | perl -lpe 's/v\d.\d.\d-//g')"
git fetch -f --tags
git checkout "${last_committed_tag}" 2> /dev/null
last_git_release="$(git describe --first-parent 2> /dev/null | perl -lpe 's/v\d.\d.\d-//g')"
if [[ -z "$(echo $last_snap_release | perl -ne "print if /${last_git_release}.*/")" ]]; then
return 0
fi
return 1
}
trigger_snapcraft_webhook() {
[[ -n "${PAYLOAD_SIG}" ]] || exit
echo "Triggering new snap release via webhook..."
curl -X POST \
-H "Content-Type: application/json" \
-H "X-Hub-Signature: sha1=${PAYLOAD_SIG}" \
--data "${WEBHOOK_PAYLOAD}" \
https://snapcraft.io/nvim/webhook/notify
}
if $(snap_realease_needed); then
echo "New snap release required"
trigger_snapcraft_webhook
fi