for release management of Livingdocs
# GH_BUMP_TO e.g. v32.6.0
# GH_REPO_NAME e.g. livingdocs-editor
# GH_TOKEN e.g. 123f345f11234
GH_BUMP_TO=<bump-version> GH_REPO_NAME=<gh-repo-name> GH_TOKEN=<github token> npx <this url>
#!/usr/bin/env node | |
const octokit = require('@octokit/rest')() | |
const assert = require('assert') | |
assert(process.env.GH_TOKEN, 'missing environment variable GH_TOKEN e.g 11b22b33n4') | |
const token = process.env.GH_TOKEN | |
assert(process.env.GH_BUMP_TO, 'missing environment variable GH_BUMP_TO e.g v32.4.0') | |
const bumpTo = process.env.GH_BUMP_TO | |
assert(process.env.GH_REPO_NAME, 'missing environment variable GH_REPO_NAME e.g livingdocs-editor') | |
const repo = process.env.GH_REPO_NAME | |
octokit.authenticate({ | |
type: 'token', | |
token: token | |
}) | |
async function createPullRequest() { | |
return await octokit.pullRequests.create({ | |
owner: 'livingdocsIO', | |
repo: repo, | |
title: `Bump minor version to ${bumpTo} for release management`, | |
head: `bump-${bumpTo}`, | |
base: 'master', | |
body: `## Description | |
Bump minor version to ${bumpTo} for release management`, | |
maintainer_can_modify: true | |
}) | |
} | |
createPullRequest() | |
.then(response => { | |
console.log(`The PR for the release-management bump has been opened at ${response.data.html_url}`) | |
}) | |
.catch(e => { | |
console.log(e) | |
}) |
{ | |
"name": "create-bump-pr", | |
"version": "1.0.0", | |
"bin": "./create-bump-pr.js", | |
"dependencies": { | |
"@octokit/rest": "^15.9.4" | |
} | |
} |