diff --git a/README.md b/README.md index cab8e9c..7ad3018 100644 --- a/README.md +++ b/README.md @@ -126,3 +126,39 @@ jobs: refresh-token: ${{ secrets.REFRESH_TOKEN }} publish: false ``` + + +Example with `publish-target` for publishing to `trustedTesters`: + +```yaml +name: Test + +on: + push: + tags: + - '*' + +jobs: + build: + name: Publish webextension + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v1 + - uses: actions/setup-node@v1 + with: + node-version: 12 + - name: Build + run: | + npm ci + npm run build + - name: Upload & release + uses: mnao305/chrome-extension-upload@2.1.0 + with: + file-path: dist/file.zip + extension-id: hogefuga(extension id) + client-id: ${{ secrets.CLIENT_ID }} + refresh-token: ${{ secrets.REFRESH_TOKEN }} + publish-target: trustedTesters + +``` diff --git a/action.yml b/action.yml index aaee44d..b4fb04c 100644 --- a/action.yml +++ b/action.yml @@ -23,6 +23,10 @@ inputs: publish: description: 'if true package will be automatically published' default: true + publish-target: + required: false + description: 'target of publish (`default` or `trustedTesters`)' + default: "default" runs: using: 'node12' main: 'dist/index.js' diff --git a/dist/index.js b/dist/index.js index 431e819..c16d06f 100644 --- a/dist/index.js +++ b/dist/index.js @@ -3753,7 +3753,7 @@ const core = __importStar(__webpack_require__(470)); const fs_1 = __importDefault(__webpack_require__(747)); const glob_1 = __importDefault(__webpack_require__(402)); const chrome_webstore_upload_1 = __importDefault(__webpack_require__(673)); -function uploadFile(webStore, filePath, publishFlg) { +function uploadFile(webStore, filePath, publishFlg, publishTarget) { const myZipFile = fs_1.default.createReadStream(filePath); webStore .uploadExisting(myZipFile) @@ -3762,7 +3762,7 @@ function uploadFile(webStore, filePath, publishFlg) { core.debug(uploadRes); if (publishFlg === 'true') { webStore - .publish() + .publish(publishTarget) .then((publishRes) => { core.debug(publishRes); }) @@ -3787,6 +3787,7 @@ function run() { const refreshToken = core.getInput('refresh-token', { required: true }); const globFlg = core.getInput('glob'); const publishFlg = core.getInput('publish'); + const publishTarget = core.getInput('publish-target'); const webStore = chrome_webstore_upload_1.default({ extensionId, clientId, @@ -3795,14 +3796,14 @@ function run() { if (globFlg === 'true') { const files = glob_1.default.sync(filePath); if (files.length > 0) { - uploadFile(webStore, files[0], publishFlg); + uploadFile(webStore, files[0], publishFlg, publishTarget); } else { core.setFailed('No files to match.'); } } else { - uploadFile(webStore, filePath, publishFlg); + uploadFile(webStore, filePath, publishFlg, publishTarget); } } catch (error) { diff --git a/src/main.ts b/src/main.ts index 085d816..06f39ca 100644 --- a/src/main.ts +++ b/src/main.ts @@ -3,7 +3,12 @@ import fs from 'fs' import glob from 'glob' import chromeWebstoreUpload from 'chrome-webstore-upload' -function uploadFile(webStore: any, filePath: string, publishFlg: string): void { +function uploadFile( + webStore: any, + filePath: string, + publishFlg: string, + publishTarget: string +): void { const myZipFile = fs.createReadStream(filePath) webStore .uploadExisting(myZipFile) @@ -12,7 +17,7 @@ function uploadFile(webStore: any, filePath: string, publishFlg: string): void { core.debug(uploadRes) if (publishFlg === 'true') { webStore - .publish() + .publish(publishTarget) .then((publishRes: any) => { core.debug(publishRes) }) @@ -41,6 +46,7 @@ async function run(): Promise { const refreshToken = core.getInput('refresh-token', {required: true}) const globFlg = core.getInput('glob') as 'true' | 'false' const publishFlg = core.getInput('publish') as 'true' | 'false' + const publishTarget = core.getInput('publish-target') const webStore = chromeWebstoreUpload({ extensionId, @@ -51,12 +57,12 @@ async function run(): Promise { if (globFlg === 'true') { const files = glob.sync(filePath) if (files.length > 0) { - uploadFile(webStore, files[0], publishFlg) + uploadFile(webStore, files[0], publishFlg, publishTarget) } else { core.setFailed('No files to match.') } } else { - uploadFile(webStore, filePath, publishFlg) + uploadFile(webStore, filePath, publishFlg, publishTarget) } } catch (error) { core.setFailed((error as Error).message)