update-deb.sh 1.8 KB

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