update-deb.sh 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. #!/usr/bin/env bash
  2. RELEASE_TYPE="${1:-}"
  3. GPG_PASS="${2:-}"
  4. RELEASE_TAG="${3:-}"
  5. REPO="grafana"
  6. if [ -z "$RELEASE_TYPE" -o -z "$GPG_PASS" ]; then
  7. echo "Both RELEASE_TYPE (arg 1) and GPG_PASS (arg 2) has to be set"
  8. exit 1
  9. fi
  10. if [[ "$RELEASE_TYPE" != "oss" && "$RELEASE_TYPE" != "enterprise" ]]; then
  11. echo "RELEASE_TYPE (arg 1) must be either oss or enterprise."
  12. exit 1
  13. fi
  14. if echo "$RELEASE_TAG" | grep -q "beta"; then
  15. REPO="beta"
  16. fi
  17. set -e
  18. # Setup environment
  19. cp scripts/build/update_repo/aptly.conf /etc/aptly.conf
  20. mkdir -p /deb-repo/db \
  21. /deb-repo/repo \
  22. /deb-repo/tmp
  23. # Download the database
  24. gsutil -m rsync -r "gs://grafana-aptly-db/$RELEASE_TYPE" /deb-repo/db
  25. # Add the new release to the repo
  26. aptly publish drop grafana filesystem:repo:grafana || true
  27. aptly publish drop beta filesystem:repo:grafana || true
  28. cp ./dist/*.deb /deb-repo/tmp
  29. rm /deb-repo/tmp/grafana_latest*.deb || true
  30. aptly repo add "$REPO" ./dist
  31. # Setup signing and sign the repo
  32. echo "allow-loopback-pinentry" > ~/.gnupg/gpg-agent.conf
  33. echo "pinentry-mode loopback" > ~/.gnupg/gpg.conf
  34. ./scripts/build/update_repo/unlock-gpg-key.sh "$GPG_PASS"
  35. aptly publish repo grafana filesystem:repo:grafana
  36. aptly publish repo beta filesystem:repo:grafana
  37. # Update the repo and db on gcp
  38. gsutil -m rsync -r -d /deb-repo/db "gs://grafana-aptly-db/$RELEASE_TYPE"
  39. gsutil -m rsync -r -d /deb-repo/repo/grafana "gs://grafana-repo/$RELEASE_TYPE/deb"
  40. # usage:
  41. #
  42. # deb https://packages.grafana.com/oss/deb stable main