From 70a960ddbc6412c9c5a4136cc1f7d11d7fb79837 Mon Sep 17 00:00:00 2001 From: Andrew Lisowski Date: Thu, 13 Dec 2018 20:38:36 -0800 Subject: [PATCH 1/6] create function for creating labels --- docs/pages/getting-started.md | 2 +- src/git.ts | 51 ++++++++++++++++++++++++++++++++++- src/github-release.ts | 49 ++++++++++++++++++++++++++++++--- tsconfig.json | 2 +- 4 files changed, 97 insertions(+), 7 deletions(-) diff --git a/docs/pages/getting-started.md b/docs/pages/getting-started.md index 325c1b5f6..7bf96028f 100644 --- a/docs/pages/getting-started.md +++ b/docs/pages/getting-started.md @@ -10,7 +10,7 @@ yarn add -D auto-release-cli To quickly configure most options run `auto init`. -If you do this you still must configure the environment variables and add the labels to your project. `auto init` cannot automate these steps. +If you do this you still must configure the environment variables. `auto init` cannot automate this step. ### Environment Variables diff --git a/src/git.ts b/src/git.ts index 62af18fcd..372ce6532 100644 --- a/src/git.ts +++ b/src/git.ts @@ -2,7 +2,11 @@ import GHub from '@octokit/rest'; import { ICommit, parseGit } from 'parse-git'; import { Memoize } from 'typescript-memoize'; -import { ILogger } from './github-release'; +import { + defaultLabelsDescriptions, + ILogger, + VersionLabel +} from './github-release'; import execPromise from './utils/exec-promise'; export interface IGithubOptions { @@ -145,6 +149,32 @@ export default class Github { } } + public async getProjectLabels() { + this.logger.verbose.info( + `Getting labels for project: ${this.options.repo}` + ); + + await this.authenticate(); + + const args = { + owner: this.options.owner, + repo: this.options.repo + }; + + try { + const labels = await this.ghub.issues.listLabelsForRepo(args); + this.logger.veryVerbose.info( + 'Got response for "listLabelsForRepo":\n', + labels + ); + this.logger.verbose.info('Found labels on project:\n', labels.data); + + return labels.data.map(l => l.name); + } catch (e) { + throw new GithubAPIError('listLabelsOnIssue', args, e); + } + } + public async getGitLog(start: string, end = 'HEAD'): Promise { const gitlog = await execPromise( `git log --name-status ${start.trim()}..${end.trim()}` @@ -214,6 +244,25 @@ export default class Github { return result; } + public async createLabel(label: VersionLabel, name: string) { + await this.authenticate(); + + this.logger.verbose.info(`Creating "${label}" label :\n${name}`); + + const result = await this.ghub.issues.createLabel({ + name, + owner: this.options.owner, + repo: this.options.repo, + color: Math.floor(Math.random() * 16777215).toString(16), + description: defaultLabelsDescriptions.get(label) + }); + + this.logger.veryVerbose.info('Got response from createLabel\n', result); + this.logger.verbose.info('Created label on Github.'); + + return result; + } + public async getProject() { this.logger.verbose.info('Getting project from Github'); diff --git a/src/github-release.ts b/src/github-release.ts index bc961342a..7de4565bb 100644 --- a/src/github-release.ts +++ b/src/github-release.ts @@ -9,14 +9,29 @@ import generateReleaseNotes, { IExtendedCommit, normalizeCommits } from './log-parse'; -import SEMVER, { calculateSemVerBump, ILabelMap } from './semver'; +import SEMVER, { calculateSemVerBump } from './semver'; import exec from './utils/exec-promise'; import getGithubToken from './utils/github-token'; import { dummyLog } from './utils/logger'; import getConfigFromPackageJson from './utils/package-config'; import postToSlack from './utils/slack'; -export const defaultLabels = { +export type VersionLabel = + | SEMVER.major + | SEMVER.minor + | SEMVER.patch + | 'no-release' + | 'release' + | 'prerelease'; +export interface ILabelMap { + [SEMVER.minor]: string; + [SEMVER.patch]: string; + 'no-release': string; + release: string; + prerelease: string; +} + +export const defaultLabels: ILabelMap = { [SEMVER.major]: 'major', [SEMVER.minor]: 'minor', [SEMVER.patch]: 'patch', @@ -33,6 +48,17 @@ export const defaultChangelogTitles = { documentation: '📝 Documentation' }; +export const defaultLabelsDescriptions = new Map(); +defaultLabelsDescriptions.set(SEMVER.major, 'create a major release'); +defaultLabelsDescriptions.set(SEMVER.minor, 'create a minor release'); +defaultLabelsDescriptions.set(SEMVER.patch, 'create a patch release'); +defaultLabelsDescriptions.set('no-release', 'do not create a release'); +defaultLabelsDescriptions.set( + 'release', + 'publish a release when this pr is merged' +); +defaultLabelsDescriptions.set('prerelease', 'create pre release'); + export interface ILogger { log: signale.Signale; verbose: signale.Signale; @@ -210,7 +236,7 @@ export default class GithubRelease { this.logger.veryVerbose.info('Got gitlog:\n', gitlog); - const commits = await this.addLabels(gitlog); + const commits = await this.addLabelsToCommits(gitlog); this.logger.veryVerbose.info('Added labels to commits:\n', commits); @@ -288,6 +314,21 @@ export default class GithubRelease { return client.createComment(message, pr, context); } + public async addLabelsToProject(labels: Map) { + const client = await this.github; + const oldLabels = await client.getProjectLabels(); + + await Promise.all( + [...labels.entries()].map(async ([versionLabel, customLabel]) => { + if (oldLabels.includes(customLabel)) { + return; + } + + await client.createLabel(versionLabel, customLabel); + }) + ); + } + public async getSemverBump( from: string, to = 'HEAD', @@ -340,7 +381,7 @@ export default class GithubRelease { return inc(lastTag, bump as ReleaseType); } - private async addLabels(commits: ICommit[]) { + private async addLabelsToCommits(commits: ICommit[]) { if (!commits) { return []; } diff --git a/tsconfig.json b/tsconfig.json index 7d762d5eb..e10c6505a 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -9,7 +9,7 @@ "allowSyntheticDefaultImports": true, "sourceMap": true, "declaration": true, - "lib": ["es6", "es2017"], + "lib": ["es6", "es2017", "es2017.object"], "esModuleInterop": true, "experimentalDecorators": true, "plugins": [ From 8f8bdfe750f01eeb53539b03dcf2c4b7e2fbc527 Mon Sep 17 00:00:00 2001 From: Andrew Lisowski Date: Fri, 14 Dec 2018 02:36:05 -0800 Subject: [PATCH 2/6] fixup types --- src/__tests__/github-release.test.ts | 13 ++++++----- src/__tests__/semver.test.ts | 10 +------- src/github-release.ts | 35 ++++++++++------------------ src/semver.ts | 24 +++++++------------ 4 files changed, 29 insertions(+), 53 deletions(-) diff --git a/src/__tests__/github-release.test.ts b/src/__tests__/github-release.test.ts index 8879ea677..657d8fb2f 100644 --- a/src/__tests__/github-release.test.ts +++ b/src/__tests__/github-release.test.ts @@ -415,14 +415,15 @@ describe('GithubRelease', () => { }); test('should be able to configure labels', async () => { + const labels = new Map(); + labels.set(SEMVER.major, 'Version: Major'); + labels.set(SEMVER.minor, 'Version: Minor'); + labels.set(SEMVER.patch, 'Version: Patch'); + labels.set('release', 'Deploy'); + const gh = new GithubRelease(undefined, { logger, - labels: { - major: 'Version: Major', - minor: 'Version: Minor', - patch: 'Version: Patch', - release: 'Deploy' - } + labels }); const commits = [ makeCommitFromMsg('First (#1234)'), diff --git a/src/__tests__/semver.test.ts b/src/__tests__/semver.test.ts index f3c365d92..9aad288d3 100644 --- a/src/__tests__/semver.test.ts +++ b/src/__tests__/semver.test.ts @@ -1,3 +1,4 @@ +import { defaultLabels } from '../github-release'; import SEMVER, { calculateSemVerBump, getHigherSemverTag } from '../semver'; test('ranks releases right', () => { @@ -6,15 +7,6 @@ test('ranks releases right', () => { expect(getHigherSemverTag('minor', 'patch')).toBe('minor'); }); -const defaultLabels = { - major: 'major', - minor: 'minor', - patch: 'patch', - 'no-release': 'no-release', - release: 'release', - prerelease: 'prerelease' -}; - describe('calculateSemVerBump', () => { test('publishes pre-releases', () => { expect(calculateSemVerBump([['minor', 'prerelease']], defaultLabels)).toBe( diff --git a/src/github-release.ts b/src/github-release.ts index 7de4565bb..799dd2cb4 100644 --- a/src/github-release.ts +++ b/src/github-release.ts @@ -9,7 +9,7 @@ import generateReleaseNotes, { IExtendedCommit, normalizeCommits } from './log-parse'; -import SEMVER, { calculateSemVerBump } from './semver'; +import SEMVER, { calculateSemVerBump, IVersionLabels } from './semver'; import exec from './utils/exec-promise'; import getGithubToken from './utils/github-token'; import { dummyLog } from './utils/logger'; @@ -23,22 +23,14 @@ export type VersionLabel = | 'no-release' | 'release' | 'prerelease'; -export interface ILabelMap { - [SEMVER.minor]: string; - [SEMVER.patch]: string; - 'no-release': string; - release: string; - prerelease: string; -} -export const defaultLabels: ILabelMap = { - [SEMVER.major]: 'major', - [SEMVER.minor]: 'minor', - [SEMVER.patch]: 'patch', - 'no-release': 'no-release', - release: 'release', - prerelease: 'prerelease' -}; +export const defaultLabels = new Map(); +defaultLabels.set(SEMVER.major, 'major'); +defaultLabels.set(SEMVER.minor, 'minor'); +defaultLabels.set(SEMVER.patch, 'patch'); +defaultLabels.set('no-release', 'no-release'); +defaultLabels.set('release', 'release'); +defaultLabels.set('prerelease', 'prerelease'); export const defaultChangelogTitles = { major: '💥 Breaking Change', @@ -66,7 +58,7 @@ export interface ILogger { } export interface IGithubReleaseOptions { - labels?: ILabelMap; + labels?: IVersionLabels; logger: ILogger; jira?: string; slack?: string; @@ -90,7 +82,7 @@ const writeFile = promisify(fs.writeFile); export default class GithubRelease { private readonly github: Promise; - private readonly userLabels: ILabelMap; + private readonly userLabels: IVersionLabels; private readonly changelogTitles: { [label: string]: string }; private readonly logger: ILogger; @@ -103,7 +95,7 @@ export default class GithubRelease { ) { this.jira = releaseOptions.jira; this.slack = releaseOptions.slack; - this.userLabels = releaseOptions.labels || {}; + this.userLabels = releaseOptions.labels || new Map(); this.changelogTitles = releaseOptions.changelogTitles || {}; this.logger = releaseOptions.logger; @@ -337,10 +329,7 @@ export default class GithubRelease { const commits = await this.getCommits(from, to); const labels = commits.map(commit => commit.labels); const options = { onlyPublishWithReleaseLabel }; - const versionLabels = { - ...defaultLabels, - ...this.userLabels - }; + const versionLabels = new Map([...defaultLabels, ...this.userLabels]); this.logger.verbose.info('Calculating SEMVER bump using:\n', { labels, diff --git a/src/semver.ts b/src/semver.ts index bb0957230..6bf22f1b0 100644 --- a/src/semver.ts +++ b/src/semver.ts @@ -1,3 +1,5 @@ +import { VersionLabel } from './github-release'; + enum SEMVER { major = 'major', premajor = 'premajor', @@ -8,6 +10,8 @@ enum SEMVER { noVersion = '' } +export type IVersionLabels = Map; + export default SEMVER; export function getHigherSemverTag(left: string, right: string): SEMVER { @@ -22,30 +26,20 @@ export function getHigherSemverTag(left: string, right: string): SEMVER { return SEMVER.patch; } -export interface ILabelMap { - major?: string; - minor?: string; - patch?: string; - 'no-release'?: string; - release?: string; - prerelease?: string; -} - interface ISemVerOptions { onlyPublishWithReleaseLabel?: boolean; } export function calculateSemVerBump( labels: string[][], - labelMap: ILabelMap, + labelMap: IVersionLabels, { onlyPublishWithReleaseLabel }: ISemVerOptions = {} ) { - const labelPairs = Object.entries(labelMap); const labelSet = new Set(); labels.map(pr => pr.forEach(label => { - const userLabel = labelPairs.find(pair => pair[1] === label); + const userLabel = [...labelMap.entries()].find(pair => pair[1] === label); labelSet.add(userLabel ? userLabel[0] : label); }) ); @@ -54,10 +48,10 @@ export function calculateSemVerBump( let isPrerelease = false; if (labels.length > 0 && labels[0].length > 0) { - isPrerelease = labels[0].includes(labelMap.prerelease!); + isPrerelease = labels[0].includes(labelMap.get('prerelease')!); noRelease = onlyPublishWithReleaseLabel - ? !labels[0].includes(labelMap.release!) - : labels[0].includes(labelMap['no-release']!); + ? !labels[0].includes(labelMap.get('release')!) + : labels[0].includes(labelMap.get('no-release')!); } const version = [...labelSet].reduce( From 2311d8826c792579bd0ac66a48e89fa1549c763e Mon Sep 17 00:00:00 2001 From: Andrew Lisowski Date: Fri, 14 Dec 2018 03:04:14 -0800 Subject: [PATCH 3/6] get init labels command working --- package.json | 10 +++++----- src/cli/args.ts | 1 + src/git.ts | 5 ++++- src/github-release.ts | 13 +++++++++++- src/main.ts | 7 +++++++ yarn.lock | 46 +++++++++++++++++++++---------------------- 6 files changed, 52 insertions(+), 30 deletions(-) diff --git a/package.json b/package.json index 24b3faadc..430b5d88d 100644 --- a/package.json +++ b/package.json @@ -35,7 +35,7 @@ "docs:publish": "ignite --publish" }, "dependencies": { - "@octokit/rest": "^16.1.0", + "@octokit/rest": "^16.2.0", "@types/argparse": "1.0.35", "@types/cosmiconfig": "5.0.3", "@types/node-fetch": "2.1.4", @@ -57,10 +57,10 @@ }, "devDependencies": { "@types/jest": "~23.3.10", - "@types/node": "~10.12.11", + "@types/node": "~10.12.15", "@types/url-join": "^0.8.2", "all-contributors-cli": "^5.4.1", - "husky": "^1.2.0", + "husky": "^1.2.1", "ignite": "^1.6.5", "jest": "~23.6.0", "lint-staged": "^8.1.0", @@ -69,8 +69,8 @@ "tslint": "~5.11.0", "tslint-config-prettier": "~1.17.0", "tslint-xo": "~0.10.0", - "typescript": "~3.2.1", - "typescript-tslint-plugin": "^0.1.2" + "typescript": "~3.2.2", + "typescript-tslint-plugin": "^0.2.0" }, "prettier": { "singleQuote": true diff --git a/src/cli/args.ts b/src/cli/args.ts index d877e4776..5d5a63751 100644 --- a/src/cli/args.ts +++ b/src/cli/args.ts @@ -233,6 +233,7 @@ export const PARSERS: [string, ParserFunction][] = [ ['version', addVersionParser], ['comment', addCommentParser], ['changelog', addChangelogParser], + ['init-labels', addLoggingParser], ['init', () => undefined], ['shipit', () => undefined] ]; diff --git a/src/git.ts b/src/git.ts index 372ce6532..77cabbdbe 100644 --- a/src/git.ts +++ b/src/git.ts @@ -54,7 +54,10 @@ export default class Github { `Initializing Github with: ${this.options.baseUrl}` ); this.ghub = new GHub({ - baseUrl: this.options.baseUrl + baseUrl: this.options.baseUrl, + headers: { + accept: 'application/vnd.github.symmetra-preview+json' + } }); } diff --git a/src/github-release.ts b/src/github-release.ts index 799dd2cb4..857cb6d88 100644 --- a/src/github-release.ts +++ b/src/github-release.ts @@ -306,7 +306,10 @@ export default class GithubRelease { return client.createComment(message, pr, context); } - public async addLabelsToProject(labels: Map) { + public async addLabelsToProject( + labels: Map, + onlyPublishWithReleaseLabel?: boolean + ) { const client = await this.github; const oldLabels = await client.getProjectLabels(); @@ -316,6 +319,14 @@ export default class GithubRelease { return; } + if (versionLabel === 'release' && !onlyPublishWithReleaseLabel) { + return; + } + + if (versionLabel === 'no-release' && onlyPublishWithReleaseLabel) { + return; + } + await client.createLabel(versionLabel, customLabel); }) ); diff --git a/src/main.ts b/src/main.ts index e37569b0f..66d8dc720 100644 --- a/src/main.ts +++ b/src/main.ts @@ -249,6 +249,13 @@ export async function run(args: ArgsType) { await init(); break; } + case 'init-labels': { + await githubRelease.addLabelsToProject( + semVerLabels, + args.onlyPublishWithReleaseLabel + ); + break; + } case 'shipit': { const version = await getVersion(githubRelease, args); diff --git a/yarn.lock b/yarn.lock index e1e21e2c4..a2eb302d2 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1052,10 +1052,10 @@ node-fetch "^2.3.0" universal-user-agent "^2.0.1" -"@octokit/rest@^16.1.0": - version "16.1.0" - resolved "https://registry.npmjs.intuit.com:443/artifactory/api/npm/npm-intuit/@octokit/rest/-/rest-16.1.0.tgz#43bee0f58821b6c6a4c9d63e14919a1fb67a71b5" - integrity sha1-Q77g9YghtsakydY+FJGaH7Z6cbU= +"@octokit/rest@^16.2.0": + version "16.2.0" + resolved "https://registry.yarnpkg.com/@octokit/rest/-/rest-16.2.0.tgz#790d4189e8befd61e5cfebc4a6171b274d0526cb" + integrity sha512-4OyWqvF0mZhSe0NEcsXboq4WJ3HC2pThHCKWeJNd/8M10zDu0q9/Ct8u0IBzHXdgmfpE2hrJJdkIBSF2NlyB9A== dependencies: "@octokit/request" "2.2.0" before-after-hook "^1.2.0" @@ -1149,10 +1149,10 @@ resolved "https://registry.yarnpkg.com/@types/node/-/node-8.10.38.tgz#e05c201a668492e534b48102aca0294898f449f6" integrity sha512-EibsnbJerd0hBFaDjJStFrVbVBAtOy4dgL8zZFw0uOvPqzBAX59Ci8cgjg3+RgJIWhsB5A4c+pi+D4P9tQQh/A== -"@types/node@~10.12.11": - version "10.12.11" - resolved "https://registry.npmjs.intuit.com:443/artifactory/api/npm/npm-intuit/@types/node/-/node-10.12.11.tgz#715c476c99a5f6898a1ae61caf9825e43c03912e" - integrity sha1-cVxHbJml9omKGuYcr5gl5DwDkS4= +"@types/node@~10.12.15": + version "10.12.15" + resolved "https://registry.yarnpkg.com/@types/node/-/node-10.12.15.tgz#20e85651b62fd86656e57c9c9bc771ab1570bc59" + integrity sha512-9kROxduaN98QghwwHmxXO2Xz3MaWf+I1sLVAA6KJDF5xix+IyXVhds0MAfdNwtcpSrzhaTsNB0/jnL86fgUhqA== "@types/parse-github-url@1.0.0": version "1.0.0" @@ -3476,7 +3476,7 @@ core-util-is@1.0.2, core-util-is@~1.0.0: resolved "https://registry.npmjs.intuit.com:443/artifactory/api/npm/npm-intuit/core-util-is/-/core-util-is-1.0.2.tgz#b5fd54220aa2bc5ab57aab7140c940754503c1a7" integrity sha1-tf1UIgqivFq1eqtxQMlAdUUDwac= -cosmiconfig@5.0.6, cosmiconfig@^5.0.6: +cosmiconfig@5.0.6: version "5.0.6" resolved "https://registry.npmjs.intuit.com:443/artifactory/api/npm/npm-intuit/cosmiconfig/-/cosmiconfig-5.0.6.tgz#dca6cf680a0bd03589aff684700858c81abeeb39" integrity sha1-3KbPaAoL0DWJr/aEcAhYyBq+6zk= @@ -3485,7 +3485,7 @@ cosmiconfig@5.0.6, cosmiconfig@^5.0.6: js-yaml "^3.9.0" parse-json "^4.0.0" -cosmiconfig@5.0.7, cosmiconfig@^5.0.0, cosmiconfig@^5.0.2: +cosmiconfig@5.0.7, cosmiconfig@^5.0.0, cosmiconfig@^5.0.2, cosmiconfig@^5.0.7: version "5.0.7" resolved "https://registry.npmjs.intuit.com:443/artifactory/api/npm/npm-intuit/cosmiconfig/-/cosmiconfig-5.0.7.tgz#39826b292ee0d78eda137dfa3173bd1c21a43b04" integrity sha1-OYJrKS7g147aE336MXO9HCGkOwQ= @@ -6056,12 +6056,12 @@ humanize-url@^1.0.0: normalize-url "^1.0.0" strip-url-auth "^1.0.0" -husky@^1.2.0: - version "1.2.0" - resolved "https://registry.npmjs.intuit.com:443/artifactory/api/npm/npm-intuit/husky/-/husky-1.2.0.tgz#d631dda1e4a9ee8ba69a10b0c51a0e2c66e711e5" - integrity sha1-1jHdoeSp7oummhCwxRoOLGbnEeU= +husky@^1.2.1: + version "1.2.1" + resolved "https://registry.yarnpkg.com/husky/-/husky-1.2.1.tgz#33628f7013e345c1790a4dbe4642ad047f772dee" + integrity sha512-4Ylal3HWhnDvIszuiyLoVrSGI7QLg/ogkNCoHE34c+yZYzb9kBZNrlTOsdw92cGi3cJT8pPb6CdVfxFkLnc8Dg== dependencies: - cosmiconfig "^5.0.6" + cosmiconfig "^5.0.7" execa "^1.0.0" find-up "^3.0.0" get-stdin "^6.0.0" @@ -12258,19 +12258,19 @@ typescript-memoize@^1.0.0-alpha.3: dependencies: core-js "2.4.1" -typescript-tslint-plugin@^0.1.2: - version "0.1.2" - resolved "https://registry.npmjs.intuit.com:443/artifactory/api/npm/npm-intuit/typescript-tslint-plugin/-/typescript-tslint-plugin-0.1.2.tgz#2523a003ad399eeaf8b0b97fe1f0d80614cc5ecd" - integrity sha1-JSOgA605nur4sLl/4fDYBhTMXs0= +typescript-tslint-plugin@^0.2.0: + version "0.2.0" + resolved "https://registry.yarnpkg.com/typescript-tslint-plugin/-/typescript-tslint-plugin-0.2.0.tgz#b2ca6771a50503245df3d64d19a3925a07ae1b0e" + integrity sha512-QzDopYibA4TDYVMY+r1pAHnVPz1qrYJSobT+J/jSZt7Qe8JwbGkU3q6b6nNqhRKc0/mslW0LX6F/GYc4+Z5W8g== dependencies: minimatch "^3.0.4" mock-require "^3.0.2" vscode-languageserver "^5.1.0" -typescript@~3.2.1: - version "3.2.1" - resolved "https://registry.npmjs.intuit.com:443/artifactory/api/npm/npm-intuit/typescript/-/typescript-3.2.1.tgz#0b7a04b8cf3868188de914d9568bd030f0c56192" - integrity sha1-C3oEuM84aBiN6RTZVovQMPDFYZI= +typescript@~3.2.2: + version "3.2.2" + resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.2.2.tgz#fe8101c46aa123f8353523ebdcf5730c2ae493e5" + integrity sha512-VCj5UiSyHBjwfYacmDuc/NOk4QQixbE+Wn7MFJuS0nRuPQbof132Pw4u53dm264O8LPc2MVsc7RJNml5szurkg== uc.micro@^1.0.1, uc.micro@^1.0.5: version "1.0.5" From 0a40d00521da841b20775f6567392c8b71ee4ff1 Mon Sep 17 00:00:00 2001 From: Andrew Lisowski Date: Fri, 14 Dec 2018 11:18:54 -0800 Subject: [PATCH 4/6] getting started overhaul --- docs/pages/getting-started.md | 60 +++++++++++++++++++---------------- 1 file changed, 32 insertions(+), 28 deletions(-) diff --git a/docs/pages/getting-started.md b/docs/pages/getting-started.md index 7bf96028f..dbcafa07b 100644 --- a/docs/pages/getting-started.md +++ b/docs/pages/getting-started.md @@ -6,46 +6,54 @@ Before we do anything we must first install `auto-release-cli` as a dev dependen yarn add -D auto-release-cli ``` +## Enterprise + +If you are using enterprise github `auto-release` lets you configure the github API URL that it uses. You can configure this by using the CLI option `--githubApi`, by setting the value in your [.autorc](./autorc.md#githubApi), or during `auto init`. + ## Configuration -To quickly configure most options run `auto init`. +Getting started with `auto-release` is super easy. -If you do this you still must configure the environment variables. `auto init` cannot automate this step. +1. `auto init` (optional) +2. `auto init-labels` +3. Configure environment variables +4. Set up script -### Environment Variables +### 1. Initialize Options -You must configure some environment variables for publishing and releasing. +Initialize all options and configure label text. If this is not run then `auto-release` will use the default configuration. -- `GH_TOKEN` - Used for updating the changelog and publishing the GitHub release -- `NPM_TOKEN` - Used to publish to npm. +### 2. Labels -If you are publishing from the CI you must inject the `NPM_TOKEN` into your `.npmrc`. +After that, you need to set up the labels on your github project. The types of labels that `auto-release` uses are: + +- Versioning Labels - used to calculate version numbers and make releases. To change them refer to [this](./autorc.md#versioning-labels). +- Changelog Labels - These labels do not effect the version calculation but they will change the section the PR displays in the changelog. These are customizable too, and you can even add your own sections. Read more [here](./autorc.md#changelog-titles) + +To create the labels for your project on Github, run the following command. ```sh -echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc +auto init-labels ``` -### Labels +### 3. Environment Variables -After that, set up the labels on your github project. The following labels are the defaults. To change them refer to [this](./autorc.md#versioning-labels). +You must configure some environment variables for publishing and releasing to work properly. -#### Versioning Labels: +- `GH_TOKEN` - Used for updating the changelog and publishing the GitHub release +- `NPM_TOKEN` - Used to publish to npm. -- `major` - create a major release -- `minor` - create a minor release -- `patch` - create a patch release -- `no-release` - do not create a release -- `release` (optional) - only used with `onlyPublishWithReleaseLabel` -- `prerelease` (optional) - create pre release +If you are publishing from the CI you must inject the `NPM_TOKEN` into your `.npmrc`. -#### Changelog Labels +```sh +echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc +``` -These labels do not effect the version calculation but they will change the section the PR displays in the changelog. These are customizable too, and you can even add your own sections. Read more [here](./autorc.md#changelog-titles) +### 4. Script -- `internal` - the changes do not effect the code and is more about tooling -- `documentation` - the changes effect the documentation +`auto-release` is written so that each tool it exposes is useful in isolation. It also provides workflows for those who don't care about the details of each tool and just want their code release. -## Quick Setup +#### Quick Setup To version, changelog, publish and release your code all at the same time, we've included the `shipit` tool. This tool takes the default `auto` workflow and puts it into one command. @@ -57,7 +65,7 @@ To version, changelog, publish and release your code all at the same time, we've } ``` -## Detailed Setup +#### Detailed Setup The simplest workflow to get set up in just the `package.json` is by adding the following to your `package.json`. With this setup your application will not be able to use the `no-release` flag, but everything else will work just fine @@ -71,7 +79,7 @@ The simplest workflow to get set up in just the `package.json` is by adding the } ``` -### Enabling `no-release` label +##### Enabling `no-release` label To use the `no-release` label you have to get a little more involved and use a shell script. We could do the `if` checks in the `package.json`, but this would get messy and hard to read very quickly. @@ -118,7 +126,3 @@ if [ ! -z "$VERSION" ]; then auto release fi ``` - -## Enterprise - -If you are using enterprise github `auto-release` lets you configure the github API URL that it uses. You can configure this by using the CLI option `--githubApi` or by setting the value in your [.autorc](./autorc.md#githubApi). From 364972ca3d16a2375f0842a11279fc9c43a5f0b2 Mon Sep 17 00:00:00 2001 From: Andrew Lisowski Date: Fri, 14 Dec 2018 11:50:40 -0800 Subject: [PATCH 5/6] better favicon --- docs/favicon.png | Bin 2257 -> 3493 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/docs/favicon.png b/docs/favicon.png index a5ec05f63d7348e00640c58c41f2a327dae1192d..e5114b8e05848acb981934ba76d9c102640e3ea5 100644 GIT binary patch delta 1683 zcma)7dr(wm6km2(Tv|uaf>p^}R!7vl?0xNh;W9`-V1mGcyfpSczAJ0{a`!?wH3O+A zU}DZCQ!$Sv+LsxYJKcJ#-NULy8Vn_$_Jv%hP@!u>M_xZJ;h|Kc7+hh zA%=k1n2=#c5@GX01XMeQkjRiRgviZK`6!|f21}&Llz(igCPt;%HOG{ zjQkx`FEbGWj*=M4Ln6wt5H5%`MBx|;(H4T>S(Jcjd8205Q~_oQmPQ1KCvX5+2poqv zgr^|@XjmXoiY7@Q|E!r>!@+_81ek&>uo4AFFaqLW3P1?OBP4>u6bkbuW2hKrzRv;N z5-T}8ZmS7-;4IDuevh+q*h!+Wa?D8R`v5Qbf4q!&gcrIUlGTKojG+cGFL|6EpUuni zV2EtUm+Pno&f+wO3%LD5S>TkC$0MlZF-SIt7o|U4eSRsuN@8BG07_*jj8G6VQWje7 z(aw=0wV9Jyuh;3|hgx8+atn#9;Nd``x56WN{1qOrT&hh<v%IF95XLLhk* zU@&i?6>jus=Ew5BH(kgZL~5`fQ91%!uzy{wOQ0SWm0Ruk`WR{@^{1f%Hl zxQtI~N47RI{mBE%i4Unp3ZS&(u^Rk_YL_=Vn@JnaE+fQ0yoO7|W1y$)l(MRfAh&Ab zA($0;k`k4@pb1vlAsmCKkcHtQh5(X8f^>9eJ`S8<*F~+Z)PR*cHHhQ9)PsQ1;h?<NuW?pmy;@iQk z1Lb_ zEW>^HBonm2kpmjn`n<}T>*Z57NzD^a=?o16NwrZ;?REuQ!6o``X0wyF%ZIUip~f`<-P zEohjnt8Wgp>Q#9uR-!NAPS|0;xO)FUw`x+!3ij`H_6?uM-TGkj@x6s0&_eedzjj4D zouQ*f{i0e@yCArzX@`{@T-s!(lLw2Azm~FOLaY7&h`VBre>Vm5cI`5Ey%CJ*tG`%d ckNiT_w&-$k;KdB1^8Bc>(sR=GrrMYP1Fqv!j{pDw delta 906 zcmZ1~eNk|NBnJ}%1H*)g8D0I%Y-KXpidl&Z$TYJu zF}E_cn4HF}jLe;ejXpm$vxsF9e*~rAy(ljyILf6PB z5on%)v4w6@vO%J*NwS5hky)~_S!(j+8rE{)(}@W}#PGLyx*ZR>Rul@Bv8Fll?bIEH9Uteq5}F)2~x*!l12^Yga3 z6ngP_Do0gL{4vpa^0u$-QR1wJy9HDPS{?58Ug`De=J{k6adFyK>BX*MIy~+QGfFq! zTIO^zt5f09QMG2tsViqM@7BNH5qSRW!#&Tx+dPliBckNw{ z&lb70b6V_@sw*uEI~2`lPTSbORsCJve~pC_EDU$pJ~GtQ)@H4)Tb6%EIbltJ(e!1X zFTbDid*{Ap=cLlo*`~|^7fx-vR&_03w63P&r}6$3JMBN;p3r}0?YTXZHbg8oIdecX zt-tT3%!aLTIS*O4{XYHdjn4M))m*Vl_l26ty_IIKZ-|>)l=D$-do)k|>e%(-{ZUe@ z=QBJw@SCZ4p6#A}A0!#JOit#XXDiZuRBLKi;t9S5yLMH%yPLne!^V)Y^~I^ls$vfikOGckMVa_)|fj*k^{3jCG} zTd&&dv1TT_wsO5Q&+*mVcdwcseRFd2a?8HUufKA&D$Vp^YPkOTX{8*)th3Lae(2?K zO;_3Npf{bnveTvM32XB~4;80dAzG>iK`TXS?B-wiVAKD9!qFr_iRq_Vmj-ppye->Z zeo3ysok3e$yP-o^Soq1w3==rd%G-OyWeufr From f6ccf3700d3a15040fb47b1e31b6bc998e727df6 Mon Sep 17 00:00:00 2001 From: Andrew Lisowski Date: Fri, 14 Dec 2018 11:50:52 -0800 Subject: [PATCH 6/6] add init docs --- docs/index.md | 3 +++ docs/pages/auto-init.md | 37 +++++++++++++++++++++++++++++++++++ docs/pages/getting-started.md | 4 ++-- package.json | 2 +- yarn.lock | 8 ++++---- 5 files changed, 47 insertions(+), 7 deletions(-) create mode 100644 docs/pages/auto-init.md diff --git a/docs/index.md b/docs/index.md index e6444cd30..cc3c43d91 100644 --- a/docs/index.md +++ b/docs/index.md @@ -7,6 +7,9 @@ :hammer: Tool APIs :wrench: +- [Setup](pages/auto-init.md) + - [auto init](pages/auto-init.md#auto-init) + - [auto init-labels](pages/auto-init.md#auto-init-labels) - [Publishing](pages/publishing.md) - [auto version](pages/auto-version.md) - [auto changelog](pages/auto-changelog.md) diff --git a/docs/pages/auto-init.md b/docs/pages/auto-init.md new file mode 100644 index 000000000..7c61082f2 --- /dev/null +++ b/docs/pages/auto-init.md @@ -0,0 +1,37 @@ +# Initialization + +`auto-release` provides some tools to quickly set up your project. If you do not want to use the interactive experience all these options can be configured via the [.autorc](./autorc.md) and most can be configure via CLI options. + +## `auto init` + +Interactive setup for most configurable options. + +```sh +$ auto init --help + +usage: auto.js init [-h] + +Optional arguments: + -h, --help Show this help message and exit. +``` + +## `auto init-labels` + +Create your projects labels on github. + +```sh +$ auto init-labels --help + +usage: auto.js init-labels [-h] [-v] [-vv] [--githubApi GITHUBAPI] + +Optional arguments: + -h, --help Show this help message and exit. + -v, --verbose Show some more logs + -vv, --very-verbose Show a lot more logs + --githubApi GITHUBAPI + Github API to use +``` + +::: message is-warning +:warning: For this to work you must have a `GH_TOKEN` set, ex: `GH_TOKEN=YOUR_TOKEN auto init-labels` +::: diff --git a/docs/pages/getting-started.md b/docs/pages/getting-started.md index dbcafa07b..962d1943b 100644 --- a/docs/pages/getting-started.md +++ b/docs/pages/getting-started.md @@ -30,10 +30,10 @@ After that, you need to set up the labels on your github project. The types of l - Versioning Labels - used to calculate version numbers and make releases. To change them refer to [this](./autorc.md#versioning-labels). - Changelog Labels - These labels do not effect the version calculation but they will change the section the PR displays in the changelog. These are customizable too, and you can even add your own sections. Read more [here](./autorc.md#changelog-titles) -To create the labels for your project on Github, run the following command. +To create the labels for your project on Github, run the following command with your `GH_TOKEN`. ```sh -auto init-labels +GH_TOKEN=YOUR_TOKEN auto init-labels ``` ### 3. Environment Variables diff --git a/package.json b/package.json index 430b5d88d..7ca778245 100644 --- a/package.json +++ b/package.json @@ -61,7 +61,7 @@ "@types/url-join": "^0.8.2", "all-contributors-cli": "^5.4.1", "husky": "^1.2.1", - "ignite": "^1.6.5", + "ignite": "^1.6.6", "jest": "~23.6.0", "lint-staged": "^8.1.0", "prettier": "^1.15.3", diff --git a/yarn.lock b/yarn.lock index a2eb302d2..fd652f8af 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6108,10 +6108,10 @@ iferr@^0.1.5: resolved "https://registry.yarnpkg.com/iferr/-/iferr-0.1.5.tgz#c60eed69e6d8fdb6b3104a1fcbca1c192dc5b501" integrity sha1-xg7taebY/bazEEofy8ocGS3FtQE= -ignite@^1.6.5: - version "1.6.5" - resolved "https://registry.yarnpkg.com/ignite/-/ignite-1.6.5.tgz#bd0d2f58496e20f44879bfec116a77166d6f2e84" - integrity sha512-cSiEwRcTdUSkRP1PvyXkJKm9lIV1jFWxiMnr3GVb1r2cXPwz4CqorXDKwe60WHFWMKhUc6Orh6lo4Mj7+SWRmQ== +ignite@^1.6.6: + version "1.6.6" + resolved "https://registry.yarnpkg.com/ignite/-/ignite-1.6.6.tgz#7ad49bddf8dfc1b964197c7aac8b6c779a2b85eb" + integrity sha512-kaHhSvWm1LfVXAJKjgPFFYw3s1RTuwAr1ibid1xji1jr53XcyPsw0YgfjcUmEA/YCc0f2G7wp4hVLgH89p2Auw== dependencies: "@babel/cli" "7.0.0" "@babel/core" "7.0.0"