Skip to content

Commit

Permalink
Screenshot and renames
Browse files Browse the repository at this point in the history
  • Loading branch information
toolmantim committed Jun 30, 2018
1 parent 25f88dc commit 33da509
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 10 deletions.
4 changes: 3 additions & 1 deletion README.md
Expand Up @@ -25,7 +25,9 @@ template: |
$CHANGES
```

As pull requests get merged to master, a draft release is kept up to date, ready for you to publish via GitHub when you're ready:
As pull requests are merged, a draft release is kept up to date listing the changes, ready to publish when you’re ready:

![Screenshot of generated draft release](desgin/screenshot.png)

## Template variables

Expand Down
Binary file added design/screenshot.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 6 additions & 6 deletions index.js
@@ -1,33 +1,33 @@
const getConfig = require('probot-config')
const { isRelevantBranch } = require('./lib/branch')
const { findReleases, generateBody } = require('./lib/releases')
const { isTriggerableBranch } = require('./lib/triggerable-branch')
const { findReleases, generateReleaseBody } = require('./lib/releases')
const { findMergedPullRequests } = require('./lib/pull-requests')

const configName = 'release-drafter.yml'

module.exports = app => {
app.on('push', async context => {
const config = await getConfig(context, configName) || {}
const { body: template } = config
const branch = context.payload.ref.replace(/^refs\/heads\//, '')

if (!template) {
if (!config.template) {
app.log(`No valid config found`)
return
}

if (!isRelevantBranch({ branch, app, context, config })) {
if (!isTriggerableBranch({ branch, app, context, config })) {
return
}

const { draftRelease, lastRelease } = await findReleases({ context })
const mergedPullRequests = await findMergedPullRequests({ app, context, branch, lastRelease })

const body = generateBody({ template, lastRelease, mergedPullRequests })
const body = generateReleaseBody({ config, lastRelease, mergedPullRequests })

if (!draftRelease) {
app.log(`Creating new draft release`)
await context.github.repos.createRelease(context.repo({
tag_name: '',
body: body,
draft: true
}))
Expand Down
4 changes: 2 additions & 2 deletions lib/releases.js
Expand Up @@ -16,8 +16,8 @@ module.exports.findReleases = async ({ context }) => {
}
}

module.exports.generateBody = ({ template, lastRelease, mergedPullRequests }) => {
let body = template
module.exports.generateReleaseBody = ({ config, lastRelease, mergedPullRequests }) => {
let body = config.template

if (lastRelease) {
body = body.replace('$PREVIOUS_TAG', lastRelease.tag_name)
Expand Down
2 changes: 1 addition & 1 deletion lib/branch.js → lib/triggerable-branch.js
@@ -1,4 +1,4 @@
module.exports.isRelevantBranch = ({ app, context, branch, config }) => {
module.exports.isTriggerableBranch = ({ app, context, branch, config }) => {
const validBranches = config.branches || [context.payload.repository.default_branch]
const relevant = validBranches.indexOf(branch) !== -1
if (!relevant) {
Expand Down

0 comments on commit 33da509

Please sign in to comment.