-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci: implement extension autopublish (#40)
- Loading branch information
1 parent
2ce0a22
commit 00dda7c
Showing
13 changed files
with
323 additions
and
466 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
name: Publish Extension | ||
on: | ||
workflow_dispatch: | ||
# release: | ||
# types: [published] | ||
|
||
jobs: | ||
build-and-publish: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Create .env file | ||
uses: SpicyPizza/[email protected] | ||
with: | ||
envkey_CREDENTIALS: ${{ secrets.CREDENTIALS }} | ||
- name: Setup pnpm | ||
uses: pnpm/[email protected] | ||
with: | ||
version: latest | ||
- name: Install deps | ||
run: pnpm i --frozen-lockfile | ||
- name: Build extension | ||
run: pnpm run build | ||
- name: Publish extension with Plasmo | ||
uses: PlasmoHQ/bpp@v2 | ||
with: | ||
keys: ${{ secrets.BPP_KEYS }} |
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 |
---|---|---|
|
@@ -127,7 +127,7 @@ dist | |
.pnp.* | ||
|
||
# credentials | ||
credentials* | ||
credentials/ | ||
|
||
# temp files on local machine | ||
tmp/ |
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,66 @@ | ||
/* | ||
* Copyright (C) 2022 Elijah Olmos | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License as | ||
* published by the Free Software Foundation, version 3. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
import { bold, green } from 'colorette'; | ||
import { strToU8, zip as zipCb } from 'fflate'; | ||
import filesize from 'filesize'; | ||
import { mkdir, readFile, writeFile } from 'node:fs/promises'; | ||
import { relative } from 'node:path'; | ||
import { promisify } from 'node:util'; | ||
import { OutputOptions } from 'rollup'; | ||
|
||
/** | ||
* @typedef ZipConfigOptions | ||
* @type {object} | ||
* @property {string} fileName - name of output zip file | ||
* @property {string} [dir] - Output directory, defaults to rollup output directory | ||
*/ | ||
|
||
/** | ||
* @param {ZipConfigOptions} options | ||
*/ | ||
export default function zip(options) { | ||
return { | ||
name: 'zip', | ||
/** | ||
* @param {OutputOptions} options | ||
* @param {Object.<string, {source: string | Uint8Array}>} bundle | ||
*/ | ||
writeBundle: async function (_options, bundle) { | ||
const dir = options?.dir ?? _options?.dir ?? process.cwd(); | ||
const { fileName } = options; | ||
|
||
const data = await promisify(zipCb)( | ||
await Object.entries(bundle).reduce( | ||
async (acc, [name, { type, source }]) => ({ | ||
...(await acc), | ||
[name]: | ||
type === 'asset' | ||
? typeof source === 'string' | ||
? strToU8(source) | ||
: source | ||
: await readFile(`${_options?.dir}/${name}`), | ||
}), | ||
{} | ||
) | ||
); | ||
//create dir if it does not exist | ||
await mkdir(`./${relative(process.cwd(), dir)}`, { recursive: true }); | ||
await writeFile(`./${relative(process.cwd(), dir)}/${fileName}`, data); | ||
console.log(green(`zipped to ${bold(`${dir}/${fileName}`)} (${filesize(data.byteLength)})`)); | ||
}, | ||
}; | ||
} |
Oops, something went wrong.