-
Notifications
You must be signed in to change notification settings - Fork 378
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: introduce GitHub release functionality (#85)
- Loading branch information
Showing
14 changed files
with
442 additions
and
14 deletions.
There are no files selected for viewing
File renamed without changes.
File renamed without changes.
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 |
---|---|---|
|
@@ -15,6 +15,8 @@ | |
|
||
set -e | ||
|
||
release-please candidate-issue --token=$GITHUB_TOKEN \ | ||
COMMAND = ${RELEASE_PLEASE_COMMAND:-candidate-issue} | ||
|
||
release-please $COMMAND --token=$GITHUB_TOKEN \ | ||
--repo-url="[email protected]:$GITHUB_REPOSITORY.git" \ | ||
--package-name=$PACKAGE_NAME |
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 |
---|---|---|
@@ -1,12 +1,13 @@ | ||
workflow "Candidate Issue" { | ||
on = "schedule(*/5 * * * *)" | ||
resolves = ["./.github/action/candidate-issue"] | ||
resolves = ["candidate-issue"] | ||
} | ||
|
||
action "./.github/action/candidate-issue" { | ||
uses = "googleapis/release-please/.github/action/candidate-issue@master" | ||
action "candidate-issue" { | ||
uses = "googleapis/release-please/.github/action/release-please@master" | ||
env = { | ||
PACKAGE_NAME = "release-please" | ||
RELEASE_PLEASE_COMMAND = "candidate-issue" | ||
} | ||
secrets = ["GITHUB_TOKEN"] | ||
} |
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,52 @@ | ||
exports['GitHubRelease extractLatestReleaseNotes handles CHANGELOG with new format entries 1'] = ` | ||
### Bug Fixes | ||
* candidate issue should only be updated every 15 minutes. ([#70](https://github.com/googleapis/release-please/issues/70)) ([edcd1f7](https://github.com/googleapis/release-please/commit/edcd1f7)) | ||
### Features | ||
* add GitHub action for generating candidate issue ([#69](https://github.com/googleapis/release-please/issues/69)) ([6373aed](https://github.com/googleapis/release-please/commit/6373aed)) | ||
* checkbox based releases ([#77](https://github.com/googleapis/release-please/issues/77)) ([1e4193c](https://github.com/googleapis/release-please/commit/1e4193c)) | ||
` | ||
|
||
exports['GitHubRelease extractLatestReleaseNotes handles CHANGELOG with old and new format entries 1'] = ` | ||
### Bug Fixes | ||
* **deps:** update dependency google-auth-library to v4 ([#79](https://github.com/googleapis/nodejs-rcloadenv/issues/79)) ([1386b78](https://github.com/googleapis/nodejs-rcloadenv/commit/1386b78)) | ||
### Build System | ||
* upgrade engines field to >=8.10.0 ([#71](https://github.com/googleapis/nodejs-rcloadenv/issues/71)) ([542f935](https://github.com/googleapis/nodejs-rcloadenv/commit/542f935)) | ||
### Miscellaneous Chores | ||
* **deps:** update dependency gts to v1 ([#68](https://github.com/googleapis/nodejs-rcloadenv/issues/68)) ([972b473](https://github.com/googleapis/nodejs-rcloadenv/commit/972b473)) | ||
### BREAKING CHANGES | ||
* **deps:** this will ship async/await with the generated code. | ||
* upgrade engines field to >=8.10.0 (#71) | ||
` | ||
|
||
exports['GitHubRelease extractLatestReleaseNotes handles CHANGELOG with old format entries 1'] = ` | ||
03-22-2019 10:34 PDT | ||
### New Features | ||
- feat: add additional entity types ([#220](https://github.com/googleapis/nodejs-language/pull/220)) | ||
### Internal / Testing Changes | ||
- chore: publish to npm using wombat ([#218](https://github.com/googleapis/nodejs-language/pull/218)) | ||
- build: use per-repo npm publish token ([#216](https://github.com/googleapis/nodejs-language/pull/216)) | ||
` |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,89 @@ | ||
/** | ||
* Copyright 2019 Google LLC. All Rights Reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
import chalk from 'chalk'; | ||
import {checkpoint, CheckpointType} from './checkpoint'; | ||
// import {ConventionalCommits} from './conventional-commits'; | ||
import {GitHub, GitHubReleasePR} from './github'; | ||
|
||
const parseGithubRepoUrl = require('parse-github-repo-url'); | ||
|
||
export interface GitHubReleaseOptions { | ||
label: string; | ||
repoUrl: string; | ||
token: string; | ||
} | ||
|
||
export class GitHubRelease { | ||
changelogPath: string; | ||
gh: GitHub; | ||
label: string; | ||
repoUrl: string; | ||
token: string|undefined; | ||
|
||
constructor(options: GitHubReleaseOptions) { | ||
this.label = options.label; | ||
this.repoUrl = options.repoUrl; | ||
this.token = options.token; | ||
|
||
this.changelogPath = 'CHANGELOG.md'; | ||
|
||
this.gh = this.gitHubInstance(); | ||
} | ||
|
||
async createRelease() { | ||
const gitHubReleasePR: GitHubReleasePR|undefined = | ||
await this.gh.latestReleasePR(this.label); | ||
if (gitHubReleasePR) { | ||
checkpoint( | ||
`found release branch ${chalk.green(gitHubReleasePR.version)} at ${ | ||
chalk.green(gitHubReleasePR.sha)}`, | ||
CheckpointType.Success); | ||
|
||
const changelogContents = | ||
await this.gh.getFileContents(this.changelogPath); | ||
const latestReleaseNotes = GitHubRelease.extractLatestReleaseNotes( | ||
changelogContents, gitHubReleasePR.version); | ||
checkpoint( | ||
`found release notes: \n---\n${ | ||
chalk.grey(latestReleaseNotes)}\n---\n`, | ||
CheckpointType.Success); | ||
|
||
await this.gh.createRelease( | ||
gitHubReleasePR.version, gitHubReleasePR.sha, latestReleaseNotes); | ||
await this.gh.removeLabel(this.label, gitHubReleasePR.number); | ||
} else { | ||
checkpoint('no recent release PRs found', CheckpointType.Failure); | ||
} | ||
} | ||
|
||
private gitHubInstance(): GitHub { | ||
const [owner, repo] = parseGithubRepoUrl(this.repoUrl); | ||
return new GitHub({token: this.token, owner, repo}); | ||
} | ||
|
||
static extractLatestReleaseNotes(changelogContents: string, version: string): | ||
string { | ||
version = version.replace(/^v/, ''); | ||
const latestRe = new RegExp( | ||
`## v?\\[?${version}[^\\n]*\\n(.*?)(\\n##\\s|($(?![\r\n])))`, 'ms'); | ||
const match = changelogContents.match(latestRe); | ||
if (!match) { | ||
throw Error('could not find changelog entry corresponding to release PR'); | ||
} | ||
return match[1]; | ||
} | ||
} |
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
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,18 @@ | ||
# Changelog | ||
|
||
[npm history][1] | ||
|
||
[1]: https://www.npmjs.com/package/release-please?activeTab=versions | ||
|
||
## [1.2.0](https://github.com/googleapis/release-please/compare/v1.1.0...v1.2.0) (2019-05-10) | ||
|
||
|
||
### Bug Fixes | ||
|
||
* candidate issue should only be updated every 15 minutes. ([#70](https://github.com/googleapis/release-please/issues/70)) ([edcd1f7](https://github.com/googleapis/release-please/commit/edcd1f7)) | ||
|
||
|
||
### Features | ||
|
||
* add GitHub action for generating candidate issue ([#69](https://github.com/googleapis/release-please/issues/69)) ([6373aed](https://github.com/googleapis/release-please/commit/6373aed)) | ||
* checkbox based releases ([#77](https://github.com/googleapis/release-please/issues/77)) ([1e4193c](https://github.com/googleapis/release-please/commit/1e4193c)) |
Oops, something went wrong.