Skip to content

Commit

Permalink
Merge pull request #69 from luniehq/fabo/publish
Browse files Browse the repository at this point in the history
Fabo/publish
  • Loading branch information
faboweb authored Jul 18, 2019
2 parents 01b6506 + 20e039b commit afe21e5
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 29 deletions.
21 changes: 20 additions & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -175,3 +188,9 @@ workflows:
filters:
branches:
only: master
publish:
jobs:
- publish:
filters:
branches:
only: master
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -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 <hello@lunie.io> (https://lunie.io)",
"licenses": [
{
"type": "Apache-2"
Expand Down
1 change: 1 addition & 0 deletions pending/fabo_publish
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[Repository] [#63](https://github.com/cosmos/lunie/issues/63) Automatic releases @faboweb
50 changes: 25 additions & 25 deletions scripts/build-zip.js
Original file line number Diff line number Diff line change
@@ -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()
4 changes: 4 additions & 0 deletions scripts/publish.sh
Original file line number Diff line number Diff line change
@@ -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}"

0 comments on commit afe21e5

Please sign in to comment.