Skip to content

Instantly share code, notes, and snippets.

@faresd
Created January 16, 2018 09:35
Show Gist options
  • Save faresd/ff2b757f9c4975931d82429a6d3ecb81 to your computer and use it in GitHub Desktop.
Save faresd/ff2b757f9c4975931d82429a6d3ecb81 to your computer and use it in GitHub Desktop.
# In case of 'unlisted' target, only passing 'publishTarget' as a request header works
if [[ ${PUBLISH_TARGET} == 'unlisted' ]]; then
HTTP_CODE=$(curl \
-w %{http_code} \
-o api-response.json \
-H "Authorization: Bearer $ACCESS_TOKEN" \
-H "x-goog-api-version: 2" \
-H "Content-Length: 0" \
-H "publishTarget: $PUBLISH_TARGET" \
-X POST \
-v https://www.googleapis.com/chromewebstore/v1.1/items/${EXTENSION_ID}/publish)
# For other targets ('default' or 'trustedTesters') we must pass 'target' as request body in json format
else
HTTP_CODE=$(curl \
-w %{http_code} \
-o api-response.json \
-H "Authorization: Bearer $ACCESS_TOKEN" \
-H "x-goog-api-version: 2" \
-H "Content-Type: application/json" \
-d "{\"target\":\"$PUBLISH_TARGET\"}" \
-X POST \
-v https://www.googleapis.com/chromewebstore/v1.1/items/${EXTENSION_ID}/publish)
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment