-
Notifications
You must be signed in to change notification settings - Fork 98
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #69 from luniehq/fabo/publish
Fabo/publish
- Loading branch information
Showing
5 changed files
with
53 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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}" |