Skip to content

Commit

Permalink
mv3 push to edge
Browse files Browse the repository at this point in the history
  • Loading branch information
june07 committed Mar 25, 2024
1 parent e2e90ad commit 63428a3
Show file tree
Hide file tree
Showing 3 changed files with 86 additions and 10 deletions.
82 changes: 75 additions & 7 deletions .github/workflows/extension.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-nodejs

# MPC_PRODUCT_ID (v3) c5bd8ac5-4b9b-4aa2-8cdb-dd91b6e22a5d, (v2) 2eb9e4aa-4247-4a90-8f11-39c25390f701

name: extension

on:
Expand Down Expand Up @@ -169,7 +171,73 @@ jobs:
- name: Set zip name
run: echo "ZIP_NAME=$(echo $GITHUB_SHA | cut -c 1-6)" >> $GITHUB_ENV

- name: Publish using Microsoft Partner Center Publish API
- name: Publish using Microsoft Partner Center Publish API (V2)
run: |
certificationNotes=$(echo "{
\"notes\": \"Submitted via GitHub Actions. $(git log -1 HEAD)\"
}")
ls -laR /tmp/artifact
response=$(curl https://login.microsoftonline.com/5c9eedce-81bc-42f3-8823-48ba6258b391/oauth2/v2.0/token \
-H "Content-Type: application/x-www-form-urlencoded" \
-d "client_id=${{ vars.MPC_CLIENT_ID }}" \
-d "scope=https://api.addons.microsoftedge.microsoft.com/.default" \
-d "client_secret=${{ secrets.MPC_CLIENT_SECRET }}" \
-d "grant_type=client_credentials")
token=$(echo $response | jq -r '.access_token')
# Uploading a package to update an existing submission
echo "Uploading a package to update an existing submission"
response=$(curl -s -i -D /tmp/headers -w 'status: %{response_code}\n' -X POST https://api.addons.microsoftedge.microsoft.com/v1/products/${{ vars.MPC_PRODUCT_ID_V2 }}/submissions/draft/package \
-H "Authorization: Bearer $token" \
-H 'Content-Type: application/zip' \
-T /tmp/artifact/${{ env.ZIP_NAME }}.zip)
if [ -n "$(echo $response | egrep "status:\s*202")" ]; then
operationID=$(cat /tmp/headers | egrep -i "location:\s*" | cut -f2 -d":" | awk '{$1=$1};1' | tr -d '\r')
# Checking the status of a package upload
echo "Checking the status of a package upload"
response=$(curl -s -w 'status: %{response_code}\n' -o /dev/null https://api.addons.microsoftedge.microsoft.com/v1/products/${{ vars.MPC_PRODUCT_ID_V2 }}/submissions/draft/package/operations/$operationID \
-H "Authorization: Bearer $token")
echo $response
retries=0
while [ -z $(echo $response | egrep "status:\s*200")]; do
if [ $retries -gt 10 ]; then
echo "Exiting (Checking the status of a package upload) after 10 retries!"
exit 1
fi
sleep 5
response=$(curl -w 'status: %{response_code}\n' -v https://api.addons.microsoftedge.microsoft.com/v1/products/${{ vars.MPC_PRODUCT_ID_V2 }}/submissions/draft/package/operations/$operationID \
-H "Authorization: Bearer $token")
retries=$(($retries+1))
done
# Publishing the submission
echo "Publishing the submission"
response=$(curl -s -i -D /tmp/headers2 -w 'status: %{response_code}\n' -o /dev/null https://api.addons.microsoftedge.microsoft.com/v1/products/${{ vars.MPC_PRODUCT_ID_V2 }}/submissions \
-H "Authorization: Bearer $token" \
-d "$certificationNotes")
if [ -n "$(echo $response | egrep "status:\s*202")" ]; then
operationID=$(cat /tmp/headers2 | egrep -i "location:\s*" | cut -f2 -d":" | awk '{$1=$1};1' | tr -d '\r')
# Checking the publishing status
response=$(curl -s -w 'status: %{response_code}\n' -o /dev/null https://api.addons.microsoftedge.microsoft.com/v1/products/${{ vars.MPC_PRODUCT_ID_V2 }}/submissions/operations/$operationID \
-H "Authorization: Bearer $token")
retries=0
while [ -z $(echo $response | egrep "status:\s*200")]; do
if [ $retries -gt 10 ]; then
echo "Exiting (Checking the publishing status) after 10 retries!"
exit 1
fi
sleep 5
response=$(curl -w 'status: %{response_code}\n' -v https://api.addons.microsoftedge.microsoft.com/v1/products/${{ vars.MPC_PRODUCT_ID_V2 }}/submissions/operations/$operationID \
-H "Authorization: Bearer $token")
retries=$(($retries+1))
done
fi
fi
exit 0
shell: bash
- name: Publish using Microsoft Partner Center Publish API (V3)
run: |
certificationNotes=$(echo "{
\"notes\": \"Submitted via GitHub Actions. $(git log -1 HEAD)\"
Expand All @@ -188,15 +256,15 @@ jobs:
# Uploading a package to update an existing submission
echo "Uploading a package to update an existing submission"
response=$(curl -s -i -D /tmp/headers -w 'status: %{response_code}\n' -X POST https://api.addons.microsoftedge.microsoft.com/v1/products/${{ vars.MPC_PRODUCT_ID }}/submissions/draft/package \
response=$(curl -s -i -D /tmp/headers -w 'status: %{response_code}\n' -X POST https://api.addons.microsoftedge.microsoft.com/v1/products/${{ vars.MPC_PRODUCT_ID_V3 }}/submissions/draft/package \
-H "Authorization: Bearer $token" \
-H 'Content-Type: application/zip' \
-T /tmp/artifact/${{ env.ZIP_NAME }}.zip)
if [ -n "$(echo $response | egrep "status:\s*202")" ]; then
operationID=$(cat /tmp/headers | egrep -i "location:\s*" | cut -f2 -d":" | awk '{$1=$1};1' | tr -d '\r')
# Checking the status of a package upload
echo "Checking the status of a package upload"
response=$(curl -s -w 'status: %{response_code}\n' -o /dev/null https://api.addons.microsoftedge.microsoft.com/v1/products/${{ vars.MPC_PRODUCT_ID }}/submissions/draft/package/operations/$operationID \
response=$(curl -s -w 'status: %{response_code}\n' -o /dev/null https://api.addons.microsoftedge.microsoft.com/v1/products/${{ vars.MPC_PRODUCT_ID_V3 }}/submissions/draft/package/operations/$operationID \
-H "Authorization: Bearer $token")
echo $response
retries=0
Expand All @@ -206,19 +274,19 @@ jobs:
exit 1
fi
sleep 5
response=$(curl -w 'status: %{response_code}\n' -v https://api.addons.microsoftedge.microsoft.com/v1/products/${{ vars.MPC_PRODUCT_ID }}/submissions/draft/package/operations/$operationID \
response=$(curl -w 'status: %{response_code}\n' -v https://api.addons.microsoftedge.microsoft.com/v1/products/${{ vars.MPC_PRODUCT_ID_V3 }}/submissions/draft/package/operations/$operationID \
-H "Authorization: Bearer $token")
retries=$(($retries+1))
done
# Publishing the submission
echo "Publishing the submission"
response=$(curl -s -i -D /tmp/headers2 -w 'status: %{response_code}\n' -o /dev/null https://api.addons.microsoftedge.microsoft.com/v1/products/${{ vars.MPC_PRODUCT_ID }}/submissions \
response=$(curl -s -i -D /tmp/headers2 -w 'status: %{response_code}\n' -o /dev/null https://api.addons.microsoftedge.microsoft.com/v1/products/${{ vars.MPC_PRODUCT_ID_V3 }}/submissions \
-H "Authorization: Bearer $token" \
-d "$certificationNotes")
if [ -n "$(echo $response | egrep "status:\s*202")" ]; then
operationID=$(cat /tmp/headers2 | egrep -i "location:\s*" | cut -f2 -d":" | awk '{$1=$1};1' | tr -d '\r')
# Checking the publishing status
response=$(curl -s -w 'status: %{response_code}\n' -o /dev/null https://api.addons.microsoftedge.microsoft.com/v1/products/${{ vars.MPC_PRODUCT_ID }}/submissions/operations/$operationID \
response=$(curl -s -w 'status: %{response_code}\n' -o /dev/null https://api.addons.microsoftedge.microsoft.com/v1/products/${{ vars.MPC_PRODUCT_ID_V3 }}/submissions/operations/$operationID \
-H "Authorization: Bearer $token")
retries=0
while [ -z $(echo $response | egrep "status:\s*200")]; do
Expand All @@ -227,7 +295,7 @@ jobs:
exit 1
fi
sleep 5
response=$(curl -w 'status: %{response_code}\n' -v https://api.addons.microsoftedge.microsoft.com/v1/products/${{ vars.MPC_PRODUCT_ID }}/submissions/operations/$operationID \
response=$(curl -w 'status: %{response_code}\n' -v https://api.addons.microsoftedge.microsoft.com/v1/products/${{ vars.MPC_PRODUCT_ID_V3 }}/submissions/operations/$operationID \
-H "Authorization: Bearer $token")
retries=$(($retries+1))
done
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "nimv3",
"version": "3.6.1",
"version": "3.6.2",
"scripts": {
"dev": "vite --host",
"dev:extension": "npm-run-all --parallel build:dev watch:rollup:deps",
Expand All @@ -10,7 +10,7 @@
"build:deps": "cross-env NODE_ENV=production node utils/watch-rollup.js",
"watch:rollup:deps": "node utils/watch-rollup.js",
"preview": "vite preview",
"test": "playwright test --project \"chrome@latest@localhost\" --workers 5 --retries 3",
"test": "playwright test --project \"edge@latest@localhost\" \"chrome@latest@localhost\" --workers 5 --retries 3",
"test:local": "playwright test --project \"edge@latest@localhost\" \"chrome@latest@localhost\" --workers 1",
"test:post": "playwright test --project \"edge@latest@localhost\" \"chrome@latest@localhost\" --workers 5 --retries 3"
},
Expand Down
10 changes: 9 additions & 1 deletion src/ui/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,13 @@
</v-main>
<v-footer :color="theme === 'light' ? 'grey-lighten-4' : undefined" app class="pa-4 d-flex align-center">
<a id="site-href" target="_blank" rel="noopener" style="text-decoration: none" href="https://june07.com">
<div class="text-h6 text-green-darken-4 ml-2"><span style="font-family: sans-serif; font-size: smaller">©</span> 2016-2023 June07</div>
<div class="text-h6 text-green-darken-4 ml-2"><span style="font-family: sans-serif; font-size: smaller">©</span> 2016-2024 June07</div>
</a>
<v-spacer></v-spacer>
<div v-if="upgradeFromV2" class="text-body-1">
NiM has been upgraded to manifest v3 <a href="https://june07.com/nim-v3-manifest-v3-update-2/" target="_blank" rel="noopener">(read more)</a>.
</div>
<v-spacer></v-spacer>
<v-btn variant="flat" class="mx-2 text-white rounded-xl" color="green-lighten-2" @click="overlayHandler('donation', true)">
<span class="material-icons mr-2">toll</span>donate
</v-btn>
Expand Down Expand Up @@ -66,6 +70,9 @@
</style>
<script setup>
const { VITE_ENV, VITE_EXTENSION_ID } = import.meta.env
const CHROME_V2_ID = 'gnhhdgbaldcilmgcpfddgdbkhjohddkj'
const EDGE_V2_ID = 'injfmegnapmoakbmnmnecjabigpdjeme'
const v2RegExp = new RegExp(`${CHROME_V2_ID}|${EDGE_V2_ID}`)
import { version } from '../../package.json'
import amplitude from 'amplitude-js'
Expand All @@ -83,6 +90,7 @@ amplitude.getInstance().init("0475f970e02a8182591c0491760d680a")
provide('amplitude', amplitude)
const extensionId = chrome?.runtime?.id || VITE_EXTENSION_ID
const upgradeFromV2 = computed(() => !v2RegExp.test(extensionId))
const i18nString = inject("i18nString")
const settings = inject("settings")
const updateSetting = inject("updateSetting")
Expand Down

0 comments on commit 63428a3

Please sign in to comment.