Skip to content

Commit 5762bb5

Browse files
authored
feat: add include-pre-releases to action inputs (#1525)
1 parent 47b390e commit 5762bb5

6 files changed

Lines changed: 127 additions & 2 deletions

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -411,6 +411,7 @@ The Release Drafter GitHub Action accepts a number of optional inputs directly i
411411
| `publish` | A boolean indicating whether the release being created or updated should be immediately published. This may be useful if the output of a previous workflow step determines that a new version of your project has been (or will be) released, as with [`salsify/action-detect-and-tag-new-version`](https://github.com/salsify/action-detect-and-tag-new-version). |
412412
| `prerelease` | Whether to draft a prerelease, with changes since another prerelease (if applicable). Default `false`. |
413413
| `prerelease-identifier` | A string indicating an identifier (alpha, beta, rc, etc), to increment the prerelease version. This automatically enables `prerelease` if not already set to `true`. Default `''`. |
414+
| `include-pre-releases` | When looking for the last published release to scan changes up-to, include pre-releases. Has no effect if using `prerelease: true` (already enabled). Default `false`. |
414415
| `latest` | A string indicating whether the release being created or updated should be marked as latest. |
415416
| `commitish` | A string specifying the target branch for the release being created. |
416417
| `header` | A string that would be added before the template body. |

action.yml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,17 @@ inputs:
4040
default: ''
4141
prerelease:
4242
description: |
43-
A boolean indicating whether the release being created or updated is a prerelease.
43+
Whether to draft a prerelease, with changes since another prerelease (if applicable).
4444
required: false
4545
default: ''
4646
prerelease-identifier:
4747
description: |
48-
A string indicating an identifier (alpha, beta, rc, etc), to increment the prerelease version.
48+
A string indicating an identifier (alpha, beta, rc, etc), to increment the prerelease version. This automatically enables `prerelease` if not already set to `true`.
49+
required: false
50+
default: ''
51+
include-pre-releases:
52+
description: |
53+
When looking for the last published release to scan changes up-to, include pre-releases. Has no effect if using `prerelease: true` (already enabled).
4954
required: false
5055
default: ''
5156
commitish:

dist/index.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189995,6 +189995,10 @@ function getInput() {
189995189995
? core.getInput('prerelease').toLowerCase() === 'true'
189996189996
: undefined,
189997189997
preReleaseIdentifier: core.getInput('prerelease-identifier') || undefined,
189998+
includePreReleases:
189999+
core.getInput('include-pre-releases') !== ''
190000+
? core.getInput('include-pre-releases').toLowerCase() === 'true'
190001+
: undefined,
189998190002
latest: core.getInput('latest')?.toLowerCase() || undefined,
189999190003
commitsSince: core.getInput('initial-commits-since') || undefined,
190000190004
}
@@ -190036,6 +190040,10 @@ function updateConfigFromInput(config, input) {
190036190040
if (input.commitsSince) {
190037190041
config['initial-commits-since'] = input.commitsSince
190038190042
}
190043+
190044+
if (input.includePreReleases !== undefined) {
190045+
config['include-pre-releases'] = input.includePreReleases
190046+
}
190039190047
}
190040190048

190041190049
function setActionOutput(

index.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,10 @@ function getInput() {
248248
? core.getInput('prerelease').toLowerCase() === 'true'
249249
: undefined,
250250
preReleaseIdentifier: core.getInput('prerelease-identifier') || undefined,
251+
includePreReleases:
252+
core.getInput('include-pre-releases') !== ''
253+
? core.getInput('include-pre-releases').toLowerCase() === 'true'
254+
: undefined,
251255
latest: core.getInput('latest')?.toLowerCase() || undefined,
252256
commitsSince: core.getInput('initial-commits-since') || undefined,
253257
}
@@ -289,6 +293,10 @@ function updateConfigFromInput(config, input) {
289293
if (input.commitsSince) {
290294
config['initial-commits-since'] = input.commitsSince
291295
}
296+
297+
if (input.includePreReleases !== undefined) {
298+
config['include-pre-releases'] = input.includePreReleases
299+
}
292300
}
293301

294302
function setActionOutput(
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
name-template: 'v$RESOLVED_VERSION'
2+
tag-template: 'v$RESOLVED_VERSION'
3+
template: |
4+
# What's Changed
5+
6+
$CHANGES
7+
include-pre-releases: false

test/index.test.js

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1329,6 +1329,102 @@ describe('release-drafter', () => {
13291329
})
13301330
})
13311331

1332+
describe('with include-pre-releases input override', () => {
1333+
it('includes pre releases when the input is true', async () => {
1334+
const restoreEnvironment = mockedEnv({
1335+
'INPUT_INCLUDE-PRE-RELEASES': 'true',
1336+
})
1337+
1338+
getConfigMock('config-with-include-pre-releases-false.yml')
1339+
1340+
nock('https://api.github.com')
1341+
.get('/repos/toolmantim/release-drafter-test-project/releases')
1342+
.query(true)
1343+
.reply(200, [release2Payload, preReleasePayload])
1344+
1345+
nock('https://api.github.com')
1346+
.post('/graphql', (body) =>
1347+
body.query.includes('query findCommitsWithAssociatedPullRequests')
1348+
)
1349+
.reply(200, graphqlCommitsMergeCommit)
1350+
1351+
nock('https://api.github.com')
1352+
.post(
1353+
'/repos/toolmantim/release-drafter-test-project/releases',
1354+
(body) => {
1355+
expect(body).toMatchInlineSnapshot(`
1356+
Object {
1357+
"body": "# What's Changed
1358+
1359+
* Add documentation (#5) @TimonVS
1360+
* Update dependencies (#4) @TimonVS
1361+
* Bug fixes (#3) @TimonVS
1362+
* Add big feature (#2) @TimonVS
1363+
* 👽 Add alien technology (#1) @TimonVS
1364+
",
1365+
"draft": true,
1366+
"make_latest": "true",
1367+
"name": "v1.5.0",
1368+
"prerelease": false,
1369+
"tag_name": "v1.5.0",
1370+
"target_commitish": "refs/heads/master",
1371+
}
1372+
`)
1373+
return true
1374+
}
1375+
)
1376+
.reply(200, preReleasePayload)
1377+
1378+
await probot.receive({
1379+
name: 'push',
1380+
payload: pushPayload,
1381+
})
1382+
1383+
expect.assertions(1)
1384+
1385+
restoreEnvironment()
1386+
})
1387+
1388+
it('does not include pre releases when the input is false', async () => {
1389+
const restoreEnvironment = mockedEnv({
1390+
'INPUT_INCLUDE-PRE-RELEASES': 'false',
1391+
})
1392+
1393+
getConfigMock('config-with-include-pre-releases-true.yml')
1394+
1395+
nock('https://api.github.com')
1396+
.get('/repos/toolmantim/release-drafter-test-project/releases')
1397+
.query(true)
1398+
.reply(200, [release2Payload, preReleasePayload])
1399+
1400+
nock('https://api.github.com')
1401+
.post('/graphql', (body) =>
1402+
body.query.includes('query findCommitsWithAssociatedPullRequests')
1403+
)
1404+
.reply(200, graphqlCommitsMergeCommit)
1405+
1406+
nock('https://api.github.com')
1407+
.post(
1408+
'/repos/toolmantim/release-drafter-test-project/releases',
1409+
(body) => {
1410+
expect(body.name).not.toBe('v1.5.0')
1411+
expect(body.tag_name).not.toBe('v1.5.0')
1412+
return true
1413+
}
1414+
)
1415+
.reply(200, preReleasePayload)
1416+
1417+
await probot.receive({
1418+
name: 'push',
1419+
payload: pushPayload,
1420+
})
1421+
1422+
expect.assertions(2)
1423+
1424+
restoreEnvironment()
1425+
})
1426+
})
1427+
13321428
describe('with exclude-labels config', () => {
13331429
it('excludes pull requests', async () => {
13341430
getConfigMock('config-with-exclude-labels.yml')

0 commit comments

Comments
 (0)