diff --git a/.circleci/config.yml b/.circleci/config.yml index 73ecc11bf9..968865be11 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -29,7 +29,7 @@ jobs: steps: - checkout - run: yarn add simsala - - run: node node_modules/simsala/src/cli.js check + - run: node node_modules/simsala/src/cli.js check lint: docker: @@ -130,6 +130,19 @@ jobs: git merge origin/master git push + # publish to the Chrome Web Store + publish: + docker: + - image: circleci/node:10.15.3 + steps: + - checkout + - yarn-install + - run: | + npm run initiate-submodule + npm run build + npm run build-zip + ./scripts/publish.sh ./dist-zip/lunie-browser-extension.zip + workflows: version: 2 build-and-deploy: @@ -175,3 +188,9 @@ workflows: filters: branches: only: master + publish: + jobs: + - publish: + filters: + branches: + only: master diff --git a/package.json b/package.json index 8e0d60902d..d84984e56d 100644 --- a/package.json +++ b/package.json @@ -1,8 +1,8 @@ { - "name": "lunie-signer-x", + "name": "lunie-browser-extension", "version": "1.0.0", - "description": "A Vue.js web extension", - "author": "fabian@lunie.io", + "description": "A browser extension to securely manage accounts and addresses, for use with Lunie.io.", + "author": "Lunie (https://lunie.io)", "licenses": [ { "type": "Apache-2" diff --git a/pending/fabo_publish b/pending/fabo_publish new file mode 100644 index 0000000000..3928631c2b --- /dev/null +++ b/pending/fabo_publish @@ -0,0 +1 @@ +[Repository] [#63](https://github.com/cosmos/lunie/issues/63) Automatic releases @faboweb \ No newline at end of file diff --git a/scripts/build-zip.js b/scripts/build-zip.js index 71605d818f..0f474cca49 100644 --- a/scripts/build-zip.js +++ b/scripts/build-zip.js @@ -1,53 +1,53 @@ #!/usr/bin/env node -const fs = require('fs'); -const path = require('path'); -const archiver = require('archiver'); +const fs = require('fs') +const path = require('path') +const archiver = require('archiver') -const DEST_DIR = path.join(__dirname, '../dist'); -const DEST_ZIP_DIR = path.join(__dirname, '../dist-zip'); +const DEST_DIR = path.join(__dirname, '../dist') +const DEST_ZIP_DIR = path.join(__dirname, '../dist-zip') const extractExtensionData = () => { - const extPackageJson = require('../package.json'); + const extPackageJson = require('../package.json') return { name: extPackageJson.name, - version: extPackageJson.version, - }; -}; + version: extPackageJson.version + } +} const makeDestZipDirIfNotExists = () => { if (!fs.existsSync(DEST_ZIP_DIR)) { - fs.mkdirSync(DEST_ZIP_DIR); + fs.mkdirSync(DEST_ZIP_DIR) } -}; +} const buildZip = (src, dist, zipFilename) => { - console.info(`Building ${zipFilename}...`); + console.info(`Building ${zipFilename}...`) - const archive = archiver('zip', { zlib: { level: 9 } }); - const stream = fs.createWriteStream(path.join(dist, zipFilename)); + const archive = archiver('zip', { zlib: { level: 9 } }) + const stream = fs.createWriteStream(path.join(dist, zipFilename)) return new Promise((resolve, reject) => { archive .directory(src, false) .on('error', err => reject(err)) - .pipe(stream); + .pipe(stream) - stream.on('close', () => resolve()); - archive.finalize(); - }); -}; + stream.on('close', () => resolve()) + archive.finalize() + }) +} const main = () => { - const { name, version } = extractExtensionData(); - const zipFilename = `${name}-v${version}.zip`; + const { name } = extractExtensionData() + const zipFilename = `${name}.zip` - makeDestZipDirIfNotExists(); + makeDestZipDirIfNotExists() buildZip(DEST_DIR, DEST_ZIP_DIR, zipFilename) .then(() => console.info('OK')) - .catch(console.err); -}; + .catch(console.err) +} -main(); +main() diff --git a/scripts/publish.sh b/scripts/publish.sh new file mode 100755 index 0000000000..7cae142646 --- /dev/null +++ b/scripts/publish.sh @@ -0,0 +1,4 @@ +#!/bin/sh + +ACCESS_TOKEN=$(curl "https://www.googleapis.com/oauth2/v4/token" -d "client_id=${GAPI_CLIENT_ID}&client_secret=${GAPI_CLIENT_SECRET}&refresh_token=${GAPI_REFRESH_TOKEN}&grant_type=refresh_token" | jq -r .access_token) +curl -H "Authorization: Bearer ${ACCESS_TOKEN}" -H "x-goog-api-version: 2" -X PUT -T $1 -v "https://www.googleapis.com/upload/chromewebstore/v1.1/items/${APP_ID}" \ No newline at end of file