2018-12-14 23:10:16 +08:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
RELEASE_TYPE="${1:-}"
|
|
|
|
GPG_PASS="${2:-}"
|
2019-01-08 23:20:26 +08:00
|
|
|
RELEASE_TAG="${3:-}"
|
|
|
|
REPO="grafana"
|
2018-12-14 23:10:16 +08:00
|
|
|
|
|
|
|
if [ -z "$RELEASE_TYPE" -o -z "$GPG_PASS" ]; then
|
2018-12-17 18:09:35 +08:00
|
|
|
echo "Both RELEASE_TYPE (arg 1) and GPG_PASS (arg 2) has to be set"
|
2018-12-14 23:10:16 +08:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2019-01-08 23:20:26 +08:00
|
|
|
if [[ "$RELEASE_TYPE" != "oss" && "$RELEASE_TYPE" != "enterprise" ]]; then
|
|
|
|
echo "RELEASE_TYPE (arg 1) must be either oss or enterprise."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
if echo "$RELEASE_TAG" | grep -q "beta"; then
|
|
|
|
REPO="beta"
|
|
|
|
fi
|
|
|
|
|
2018-12-14 23:10:16 +08:00
|
|
|
set -e
|
|
|
|
|
|
|
|
# Setup environment
|
|
|
|
cp scripts/build/update_repo/aptly.conf /etc/aptly.conf
|
2019-01-04 23:35:17 +08:00
|
|
|
mkdir -p /deb-repo/db \
|
|
|
|
/deb-repo/repo \
|
|
|
|
/deb-repo/tmp
|
2018-12-14 23:10:16 +08:00
|
|
|
|
|
|
|
# Download the database
|
2019-01-04 17:18:44 +08:00
|
|
|
gsutil -m rsync -r "gs://grafana-aptly-db/$RELEASE_TYPE" /deb-repo/db
|
2018-12-14 23:10:16 +08:00
|
|
|
|
|
|
|
# Add the new release to the repo
|
2019-01-08 23:20:26 +08:00
|
|
|
aptly publish drop grafana filesystem:repo:grafana || true
|
|
|
|
aptly publish drop beta filesystem:repo:grafana || true
|
2018-12-18 22:30:51 +08:00
|
|
|
cp ./dist/*.deb /deb-repo/tmp
|
|
|
|
rm /deb-repo/tmp/grafana_latest*.deb || true
|
2019-01-08 23:20:26 +08:00
|
|
|
aptly repo add "$REPO" ./dist
|
2018-12-14 23:10:16 +08:00
|
|
|
|
|
|
|
# Setup signing and sign the repo
|
|
|
|
|
|
|
|
echo "allow-loopback-pinentry" > ~/.gnupg/gpg-agent.conf
|
|
|
|
echo "pinentry-mode loopback" > ~/.gnupg/gpg.conf
|
|
|
|
|
2019-01-09 18:17:21 +08:00
|
|
|
touch /tmp/sign-this
|
2019-01-08 23:20:26 +08:00
|
|
|
./scripts/build/update_repo/unlock-gpg-key.sh "$GPG_PASS"
|
2019-01-09 18:17:21 +08:00
|
|
|
rm /tmp/sign-this /tmp/sign-this.asc
|
2019-01-08 23:20:26 +08:00
|
|
|
|
|
|
|
aptly publish repo grafana filesystem:repo:grafana
|
|
|
|
aptly publish repo beta filesystem:repo:grafana
|
2018-12-14 23:10:16 +08:00
|
|
|
|
|
|
|
# Update the repo and db on gcp
|
2019-01-04 17:18:44 +08:00
|
|
|
gsutil -m rsync -r -d /deb-repo/db "gs://grafana-aptly-db/$RELEASE_TYPE"
|
2018-12-14 23:10:16 +08:00
|
|
|
gsutil -m rsync -r -d /deb-repo/repo/grafana "gs://grafana-repo/$RELEASE_TYPE/deb"
|
|
|
|
|
|
|
|
# usage:
|
2019-01-08 23:20:26 +08:00
|
|
|
#
|
2019-01-04 17:18:44 +08:00
|
|
|
# deb https://packages.grafana.com/oss/deb stable main
|