upload-artifact.sh 737 B

12345678910111213141516171819202122232425
  1. #!/usr/bin/env bash
  2. set -exuo pipefail
  3. RESPONSE=$(curl -X POST "$URL" \
  4. -H "Authorization: Bearer $AUTH" \
  5. -H "Content-Type: application/json")
  6. SIGNED_URL=$(echo "$RESPONSE" | jq -r '.url')
  7. if [[ "$SIGNED_URL" == "null" ]]; then
  8. echo -e "\033[31mFailed to get signed URL.\033[0m"
  9. exit 1
  10. fi
  11. UPLOAD_RESPONSE=$(tar -cz dist | curl -v -X PUT \
  12. -H "Content-Type: application/gzip" \
  13. --data-binary @- "$SIGNED_URL" 2>&1)
  14. if echo "$UPLOAD_RESPONSE" | grep -q "HTTP/[0-9.]* 200"; then
  15. echo -e "\033[32mUploaded build to Stainless storage.\033[0m"
  16. echo -e "\033[32mInstallation: npm install 'https://pkg.stainless.com/s/opencode-typescript/$SHA'\033[0m"
  17. else
  18. echo -e "\033[31mFailed to upload artifact.\033[0m"
  19. exit 1
  20. fi