This repository has been archived by the owner on Nov 7, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.sh
executable file
·57 lines (45 loc) · 2.02 KB
/
build.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/bin/sh
# This script creates a ZIP archive of this extension
# and uploads it to the Chrome Web Store.
# it requires environment variables: APP_ID, CLIENT_ID, and CLIENT_SECRET
# (see https://developer.chrome.com/webstore/using_webstore_api)
source .env
VERSION=$(jq --raw-output .version manifest.json)
echo "Packing v$VERSION ..."
FILEPATH="contacts-for-google-inbox-v$VERSION.zip"
rm $FILEPATH &>/dev/null
zip $FILEPATH * --no-dir-entries --exclude *.sh *.zip
echo "=> Built package for Chrome Web Store, to: $FILEPATH"
echo ""
echo "Auth: getting access token from Chrome Web Store API ..."
open "https://accounts.google.com/o/oauth2/auth?response_type=code&scope=https://www.googleapis.com/auth/chromewebstore&client_id=$CLIENT_ID&redirect_uri=urn:ietf:wg:oauth:2.0:oob"
echo "Enter the auth code provided by Google:"
read CODE
RESPONSE=$(curl --silent "https://accounts.google.com/o/oauth2/token" -d "client_id=$CLIENT_ID&client_secret=$CLIENT_SECRET&code=$CODE&grant_type=authorization_code&redirect_uri=urn:ietf:wg:oauth:2.0:oob")
ACCESS_TOKEN=$(echo $RESPONSE | jq --raw-output .access_token)
echo "=> access token: $ACCESS_TOKEN"
echo ""
echo "Uploading archive to Chrome Web Store ..."
curl \
-H "Authorization: Bearer $ACCESS_TOKEN" \
-H "x-goog-api-version: 2" \
-X PUT \
-T $FILEPATH \
--silent \
https://www.googleapis.com/upload/chromewebstore/v1.1/items/$APP_ID
echo ""
echo "=> done. :-)"
echo ""
echo "Now, update the description field (e.g. changelog), then publish changes on:"
echo " https://chrome.google.com/webstore/developer/edit/$APP_ID"
open https://chrome.google.com/webstore/developer/edit/$APP_ID
# TODO: find a way to automatically update changelog in extension's description field,
# (https://developer.chrome.com/webstore/api_index) then publish with this:
# echo "Publishing update ..."
# curl \
# -H "Authorization: Bearer $ACCESS_TOKEN" \
# -H "x-goog-api-version: 2" \
# -H "Content-Length: 0" \
# -X POST \
# -v \
# https://www.googleapis.com/chromewebstore/v1.1/items/$APP_ID/publish