Skip to content

Commit

Permalink
add publish
Browse files Browse the repository at this point in the history
  • Loading branch information
greggman committed May 17, 2024
1 parent 731d170 commit 75281a7
Show file tree
Hide file tree
Showing 3 changed files with 499 additions and 2 deletions.
38 changes: 38 additions & 0 deletions build/publish.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import { Octokit } from 'octokit';
import path from 'path';
import fs from 'fs';

const octokit = new Octokit({ });

const owner = 'greggman';
const repo = 'tintd-bundler';

function execute(cmd, args) {
console.log(cmd, args.join(' '));
}

async function downloadFile(name, url, filepath) {
const res = await fetch(url);
const data = await res.arrayBuffer();
const filename = path.join(filepath, name);
console.log('download:', filename);
fs.writeFileSync(filepath, new Uint8Array(data));
return filename;
}

async function main() {
const latest = await octokit.rest.repos.getLatestRelease({
owner,
repo,
});
const vsixFilenames = await Promise.all(
latest.data.assets
.filter(({name}) => name?.endsWith('.vsix'))
.map(({name, browser_download_url}) => downloadFile(name, browser_download_url, 'dist'))
);
for (const filename of vsixFilenames) {
execute('./node_modules/.bin/vsce', ['publish', '--packagePath', filename]);
}
}

main();
Loading

0 comments on commit 75281a7

Please sign in to comment.