github.com/pquerna/agent@v2.1.8+incompatible/scripts/utils/publish-debian-package.sh (about) 1 #!/bin/bash 2 3 set -o errexit 4 5 if [[ ${#} -ne 2 ]] 6 then 7 echo "Usage: ${0} [debian-package] [codename]" >&2 8 exit 1 9 fi 10 11 function info { 12 echo -e "\033[35m$1\033[0m" 13 } 14 15 PACKAGE=${1} 16 CODENAME=${2} 17 COMPONENT="main" 18 19 # Some validations 20 if [ -z "$GPG_SIGNING_KEY" ]; then 21 echo "Error: Missing ENV variable $GPG_SIGNING_KEY" 22 exit 1 23 fi 24 25 if [ -z "$GPG_PASSPHRASE_PASSWORD" ]; then 26 echo "Error: Missing ENV variable $GPG_PASSPHRASE_PASSWORD" 27 exit 1 28 fi 29 30 if [ -z "$GPG_PASSPHRASE_PATH" ]; then 31 echo "Error: Missing ENV variable $GPG_PASSPHRASE_PATH" 32 exit 1 33 fi 34 35 if [ -z "$DEB_S3_BUCKET" ]; then 36 echo "Error: Missing ENV variable DEB_S3_BUCKET" 37 exit 1 38 fi 39 40 if [ -z "$DEB_S3_ACCESS_KEY_ID" ]; then 41 echo "Error: Missing ENV variable DEB_S3_ACCESS_KEY_ID" 42 exit 1 43 fi 44 45 if [ -z "$DEB_S3_SECRET_ACCESS_KEY_ID" ]; then 46 echo "Error: Missing ENV variable DEB_S3_SECRET_ACCESS_KEY_ID" 47 exit 1 48 fi 49 50 info "Uploading $PACKAGE to $DEB_S3_BUCKET ($CODENAME $COMPONENT)" 51 52 # Decrpyt the GPG_PASSPHRASE with our GPG_PASSPHRASE_PASSWORD 53 GPG_PASSPHRASE=`openssl aes-256-cbc -k "$GPG_PASSPHRASE_PASSWORD" -in "$GPG_PASSPHRASE_PATH" -d` 54 55 # Uploads to s3 and signs with the default key on the system 56 57 bundle exec deb-s3 upload \ 58 --preserve-versions \ 59 --sign $GPG_SIGNING_KEY \ 60 --gpg-options "\-\-passphrase $GPG_PASSPHRASE" \ 61 --bucket $DEB_S3_BUCKET \ 62 --codename $CODENAME \ 63 --component $COMPONENT \ 64 --access-key-id=$DEB_S3_ACCESS_KEY_ID \ 65 --secret-access-key=$DEB_S3_SECRET_ACCESS_KEY_ID \ 66 $PACKAGE 67 68 echo "✅ All done! To install this package:" 69 echo "" 70 echo " # Login as root" 71 echo " $ sudo su" 72 echo "" 73 echo " # Add the repository to your APT sources" 74 echo " $ echo deb http://$DEB_S3_BUCKET $CODENAME $COMPONENT > /etc/apt/sources.list.d/buildkite-agent.list" 75 echo "" 76 echo " # Then import the repository key" 77 echo " $ apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 32A37959C2FA5C3C99EFBC32A79206696452D198" 78 echo "" 79 echo " # Install the agent" 80 echo " $ apt-get update" 81 echo " $ apt-get install -y buildkite-agent" 82 echo ""