Skip to content

Commit

Permalink
Chrome MV3 Beta channel (#1469)
Browse files Browse the repository at this point in the history
* Create mv3 beta build

* Prepare release 2022.10.24

* CI: Publish Chrome MV3 beta

* Bump action versions

* Prepare release

* Push changes to a new branch

Prevents error when we might try to push to a protected branch (develop)
  • Loading branch information
sammacbeth committed Oct 26, 2022
1 parent 87b6c58 commit a206dc1
Show file tree
Hide file tree
Showing 10 changed files with 2,100 additions and 135 deletions.
53 changes: 53 additions & 0 deletions .github/workflows/beta.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Beta Release

on:
workflow_dispatch:

jobs:
chrome_mv3_beta:
runs-on: ubuntu-20.04

steps:
- uses: actions/checkout@v3
- name: Use Node.js 16
uses: actions/setup-node@v3
with:
node-version: 16.x

- name: Restore npm artifact from cache
uses: actions/cache@v3
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Install dependencies
run: |
npm run install-ci
- name: Fetch config and update version
run: |
npm run bundle-config
node scripts/bumpVersion.js $(date "+%Y.%m.%d")
echo "VERSION=$(jq -r .version ./browser/chrome-mv3/manifest.json)" >> $GITHUB_ENV
- name: Commit config and version updates
uses: stefanzweifel/git-auto-commit-action@f6f7a9c351bb990cab0093f66c0d443d3a108a6f
with:
commit_message: "Prepare release ${{ env.VERSION }}"
tagging_message: ${{ env.VERSION }}
create_branch: true
branch: "release/beta/${{ env.VERSION }}"

- name: Build Chrome MV3 Beta
run: |
npm run beta-chrome-mv3
- name: Publish to Chrome Store
env:
CWS_CLIENT_ID: ${{ secrets.CWS_CLIENT_ID }}
CWS_CLIENT_SECRET: ${{ secrets.CWS_CLIENT_SECRET }}
CWS_REFRESH_TOKEN: ${{ secrets.CWS_REFRESH_TOKEN }}
run: |
bash ./scripts/chrome-store-publish.sh ${{ secrets.CWS_BETA_EXTENSION_ID }} ./build/chrome-mv3/release/chrome-release-*.zip
13 changes: 12 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ release: npm setup-build-dir grunt moveout fonts web-resources
dev: setup-build-dir moveout fonts web-resources grunt-dev

npm:
npm ci
npm install-ci

grunt:
grunt build --browser=$(browser) --type=$(type)
Expand All @@ -31,6 +31,17 @@ chrome-release-zip:
rm -f build/chrome/release/chrome-release-*.zip
cd build/chrome/release/ && zip -rq chrome-release-$(shell date +"%Y%m%d_%H%M%S").zip *

chrome-mv3-release-zip:
rm -f build/chrome-mv3/release/chrome-release-*.zip
cd build/chrome-mv3/release/ && zip -rq chrome-release-$(shell date +"%Y%m%d_%H%M%S").zip *

chrome-mv3-beta-zip: rename-chrome-beta chrome-mv3-release-zip

rename-chrome-beta:
sed 's/__MSG_appName__/DuckDuckGo Privacy Essentials MV3 Beta/' ./browsers/chrome-mv3/manifest.json > build/chrome-mv3/release/manifest.json

chrome-mv3-beta: release chrome-mv3-beta-zip

fonts:
mkdir -p build/$(browser)/$(type)/public
cp -r shared/font build/$(browser)/$(type)/public/
Expand Down
28 changes: 16 additions & 12 deletions browsers/chrome-mv3/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "__MSG_appName__",
"description": "__MSG_appDesc__",
"default_locale": "en",
"version": "2022.4.26",
"version": "2022.10.26",
"icons": {
"16": "img/icon_16.png",
"48": "img/icon_48.png",
Expand Down Expand Up @@ -74,17 +74,21 @@
"host_permissions": [
"*://*/*"
],
"web_accessible_resources": [{
"resources": [
"/web_accessible_resources/*",
"/img/logo-small.svg",
"/public/css/autofill.css",
"/public/font/*"
],
"use_dynamic_url": true,
"matches": ["<all_urls>"]
}],
"web_accessible_resources": [
{
"resources": [
"/web_accessible_resources/*",
"/img/logo-small.svg",
"/public/css/autofill.css",
"/public/font/*"
],
"use_dynamic_url": true,
"matches": [
"<all_urls>"
]
}
],
"storage": {
"managed_schema": "managed-schema.json"
}
}
}
2 changes: 1 addition & 1 deletion browsers/chrome/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "__MSG_appName__",
"description": "__MSG_appDesc__",
"default_locale": "en",
"version": "2022.8.25",
"version": "2022.10.26",
"minimum_chrome_version": "92.0",
"icons": {
"16": "img/icon_16.png",
Expand Down
2 changes: 1 addition & 1 deletion browsers/firefox/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"strict_min_version": "91.0"
}
},
"version": "2022.8.25",
"version": "2022.10.26",
"description": "Privacy, simplified. Protect your data as you search and browse: tracker blocking, smarter encryption, private search, and more.",
"icons": {
"16": "img/icon_16.png",
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@
"dev-chrome-mv3": "make dev browser=chrome-mv3 type=dev watch=1",
"beta-firefox": "make beta-firefox browser=firefox type=release",
"release-chrome": "make browser=chrome type=release && make chrome-release-zip",
"release-chrome-mv3": "make browser=chrome-mv3 type=release && make chrome-mv3-release-zip"
"release-chrome-mv3": "make browser=chrome-mv3 type=release && make chrome-mv3-release-zip",
"beta-chrome-mv3": "make chrome-mv3-beta browser=chrome-mv3 type=release"
},
"devDependencies": {
"@babel/cli": "^7.19.3",
Expand Down
2 changes: 1 addition & 1 deletion scripts/bumpVersion.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const fs = require('fs')

const newVersion = process.argv[2]

for (const browser of ['chrome', 'firefox']) {
for (const browser of ['chrome', 'firefox', 'chrome-mv3']) {
const manifest = fs.readFileSync(`browsers/${browser}/manifest.json`, 'utf8')
const manifestData = JSON.parse(manifest)
manifestData.version = newVersion
Expand Down
26 changes: 26 additions & 0 deletions scripts/chrome-store-publish.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/bash
set -e

# Publish a Chrome extension zip to the chrome store for a given extension ID.
# Args: <Extension Item ID> <Path to zip>
ITEM_ID=$1
FILE_NAME=$2

# Get an access token
ACCESS_TOKEN=$(curl "https://accounts.google.com/o/oauth2/token" \
-d "client_id=$CWS_CLIENT_ID&client_secret=$CWS_CLIENT_SECRET&refresh_token=$CWS_REFRESH_TOKEN&grant_type=refresh_token&redirect_uri=urn:ietf:wg:oauth:2.0:oob" | jq -r .access_token)

# Upload release zip
curl \
-H "Authorization: Bearer $ACCESS_TOKEN" \
-H "x-goog-api-version: 2" \
-X PUT \
-T $FILE_NAME \
https://www.googleapis.com/upload/chromewebstore/v1.1/items/$ITEM_ID

# Publish the item
curl \
-H "Authorization: Bearer $ACCESS_TOKEN" \
-H "x-goog-api-version: 2" \
-d "{\"target\": \"default\"}" \
https://www.googleapis.com/chromewebstore/v1.1/items/$ITEM_ID/publish

0 comments on commit a206dc1

Please sign in to comment.