From 832179affa9ff522323337a5ad91ce9088afbe35 Mon Sep 17 00:00:00 2001 From: BART! Date: Sun, 8 Dec 2019 12:22:52 +0100 Subject: [PATCH] chore(actions): release flow on push --- .github/workflows/release.yml | 39 +++++++++++++++++++++++++++++++++++ .nvmrc | 1 + config/webpack.prod.js | 37 ++++++++++++++++++++------------- 3 files changed, 63 insertions(+), 14 deletions(-) create mode 100644 .github/workflows/release.yml create mode 100644 .nvmrc diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..c654139 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,39 @@ +name: Release Chrome Web Store + +on: + push: + tags: + - v*.*.* + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@master + + - name: Use Node.js 13.x + uses: actions/setup-node@master + with: + node-version: 13.x + + # - name: Get the version tag + # id: get_version + # run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//} + + - name: Build extension for Chrome + run: | + npm install + npm run build:chrome + + - name: Deploy to Chrome Web Store + uses: trmcnvn/chrome-addon@v1 + with: + extension: kkoccljoocknljaljhpifcnkmillmilo + zip: zip/chrome.zip + client-id: ${{ secrets.CHROME_CLIENT_ID }} + client-secret: ${{ secrets.CHROME_CLIENT_SECRET }} + refresh-token: ${{ secrets.CHROME_REFRESH_TOKEN }} + env: + CI: true diff --git a/.nvmrc b/.nvmrc new file mode 100644 index 0000000..b1bd38b --- /dev/null +++ b/.nvmrc @@ -0,0 +1 @@ +13 diff --git a/config/webpack.prod.js b/config/webpack.prod.js index 9ff7eb9..05bf8b8 100755 --- a/config/webpack.prod.js +++ b/config/webpack.prod.js @@ -7,7 +7,7 @@ const commonConfig = require('./webpack.common.js'); const browserConfig = require('./browsers.manifest.json'); const version = process.env.npm_package_version; -module.exports = function (options) { +module.exports = options => { var target = options.target; if (target) { var browserSpecificProperties = browserConfig[target]; @@ -15,23 +15,26 @@ module.exports = function (options) { return webpackMerge(commonConfig(), { mode: 'production', optimization: { - minimize: false + minimize: false, }, plugins: [ new webpack.DefinePlugin({ - 'BROWSER': JSON.stringify(target) + BROWSER: JSON.stringify(target), }), new CopyWebpackPlugin([ { from: 'src/manifest-common.json', to: 'manifest.json', - transform: function (content, path) { + transform: (content, path) => { var manifest = JSON.parse(content.toString()); manifest.version = version; - var manifestObj = Object.assign(manifest, browserSpecificProperties); + var manifestObj = Object.assign( + manifest, + browserSpecificProperties + ); return JSON.stringify(manifestObj, null, 2); - } - } + }, + }, ]), new ZipPlugin({ // OPTIONAL: defaults to the Webpack output path (above) @@ -40,7 +43,7 @@ module.exports = function (options) { // OPTIONAL: defaults to the Webpack output filename (above) or, // if not present, the basename of the path - filename: target + '-v' + version + '.zip', + filename: target + '.zip', // OPTIONAL: defaults to 'zip' // the file extension to use instead of 'zip' @@ -52,7 +55,7 @@ module.exports = function (options) { // OPTIONAL: defaults to the identity function // a function mapping asset paths to new paths - pathMapper: function(assetPath) { + pathMapper: assetPath => { // put all pngs in an `images` subdir // if (assetPath.endsWith('.png')) // return path.join(path.dirname(assetPath), 'images', path.basename(assetPath)); @@ -82,8 +85,14 @@ module.exports = function (options) { zipOptions: { forceZip64Format: false, }, - }) - ] - }) -} - + }), + // Create build zip with version + new CopyWebpackPlugin([ + { + from: './zip/' + target + '.zip', + to: '../zip/' + target + '-v' + version + '.zip', + }, + ]), + ], + }); +};