Skip to content

Commit

Permalink
iron out the publishing workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
mmomtchev committed Dec 24, 2021
1 parent 5172cf2 commit 01620cb
Show file tree
Hide file tree
Showing 3 changed files with 127 additions and 37 deletions.
155 changes: 122 additions & 33 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"main": "lib/binding.js",
"dependencies": {
"@mapbox/node-pre-gyp": "^1.0.8",
"@mmomtchev/node-pre-gyp-github": "^2.0.3",
"node-addon-api": "^1.1.0"
},
"scripts": {
Expand Down
8 changes: 4 additions & 4 deletions scripts/publish-packages.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ const pkg = {
const version = package_json.version;
let workflowPublishId;
const workflowPublishMatch = /publish/;
const workflowPublish = { ...pkg, workflow_id: workflowPublishId, ref: `v${version}` };

(async () => {
const branch = (await exec('git branch --show-current')).stdout.trim();
Expand All @@ -23,15 +22,16 @@ const workflowPublish = { ...pkg, workflow_id: workflowPublishId, ref: `v${versi
const workflows = await octokit.request('GET /repos/{owner}/{repo}/actions/workflows', pkg);
for (const w of workflows.data.workflows) {
if (w.name.match(workflowPublishMatch)) {
process.stdout.write(` found ${w.id}:${w.name}\n`);
workflowPublishId = w.id;
break;
}
}
if (workflowPublishId) process.stdout.write('found ${id}\n');
else {
process.stdout.write('no publishing workflow found\n');
if (!workflowPublishId) {
process.stdout.write(' no publishing workflow found\n');
return;
}
const workflowPublish = { ...pkg, workflow_id: workflowPublishId, ref: `v${version}` };

process.stdout.write(`launching Github actions build on branch ${branch} for ${version}, tag ${workflowPublish.ref}`);
await octokit.request('POST /repos/{owner}/{repo}/actions/workflows/{workflow_id}/dispatches', workflowPublish);
Expand Down

0 comments on commit 01620cb

Please sign in to comment.