1
0
mirror of https://github.com/joaquinjsb/gitea-release-please-action synced 2026-05-12 19:31:31 +02:00

feat: add additional outputs (#106)

Opening a release PR now outputs a release #. Creating a GitHub release outputs
SemVer major/minor/patch values
This commit is contained in:
Benjamin E. Coe
2020-11-25 15:34:05 -05:00
committed by GitHub
parent dda9b7b3c4
commit c0f7d24cd0
6 changed files with 114 additions and 30 deletions

View File

@@ -20,7 +20,7 @@ Automate releases with Conventional Commit Messages.
release-please: release-please:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: GoogleCloudPlatform/release-please-action@v2.7.0 - uses: GoogleCloudPlatform/release-please-action@v2.8.0
with: with:
token: ${{ secrets.GITHUB_TOKEN }} token: ${{ secrets.GITHUB_TOKEN }}
release-type: node release-type: node
@@ -44,14 +44,22 @@ Automate releases with Conventional Commit Messages.
| `monorepo-tags` | add prefix to tags and branches, allowing multiple libraries to be released from the same repository. | | `monorepo-tags` | add prefix to tags and branches, allowing multiple libraries to be released from the same repository. |
| `changelog-types` | A JSON formatted String containing to override the outputted changlog sections | | `changelog-types` | A JSON formatted String containing to override the outputted changlog sections |
| `version-file` | provide a path to a version file to increment (used by ruby releaser) | | `version-file` | provide a path to a version file to increment (used by ruby releaser) |
| `fork` | Should the PR be created from a fork (does not work with `secrets.GITHUB_TOKEN`) |
| `clean` | Should stale release PRs be closed post release? Default `true` |
| `command` | release-please command to run, either `github-release`, or `release-pr` (_defaults to running both_) |
| output | description | | output | description |
|:---:|---| |:---:|---|
| `release_created` | `true` if the release was created, `false` otherwise | | `release_created` | `true` if the release was created, `false` otherwise |
| `upload_url` | Directly related to [**Create a release**](https://developer.github.com/v3/repos/releases/#response-4) API | | `upload_url` | Directly related to [**Create a release**](https://developer.github.com/v3/repos/releases/#response-4) API |
| `html_url` | Directly related to [**Create a release**](https://developer.github.com/v3/repos/releases/#response-4) API |
| `tag_name` | Directly related to [**Create a release**](https://developer.github.com/v3/repos/releases/#response-4) API | | `tag_name` | Directly related to [**Create a release**](https://developer.github.com/v3/repos/releases/#response-4) API |
| `fork` | Should the PR be created from a fork (does not work with `secrets.GITHUB_TOKEN`) | | `major` | Number representing major semver value |
| `command` | release-please command to run, either `github-release`, or `release-pr` (_defaults to running both_) | | `minor` | Number representing minor semver value |
| `patch` | Number representing patch semver value |
| `sha` | sha that a GitHub release was tagged at |
| `pr` | The PR number of an opened release (undefined if no release created) |
### Release types supported ### Release types supported
@@ -108,7 +116,7 @@ To output more commit information in the changelog, a JSON formatted String can
release-please: release-please:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: GoogleCloudPlatform/release-please-action@v2.7.0 - uses: GoogleCloudPlatform/release-please-action@v2.8.0
with: with:
token: ${{ secrets.GITHUB_TOKEN }} token: ${{ secrets.GITHUB_TOKEN }}
release-type: node release-type: node
@@ -131,7 +139,7 @@ jobs:
release-please: release-please:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: GoogleCloudPlatform/release-please-action@v2.7.0 - uses: GoogleCloudPlatform/release-please-action@v2.8.0
id: release id: release
with: with:
token: ${{ secrets.GITHUB_TOKEN }} token: ${{ secrets.GITHUB_TOKEN }}

View File

@@ -8,6 +8,9 @@ inputs:
fork: fork:
description: 'should the PR be proposed from a fork (does not work with secrets.GITHUB_TOKEN)' description: 'should the PR be proposed from a fork (does not work with secrets.GITHUB_TOKEN)'
required: false required: false
clean:
description: 'Should stale release PRs be closed post release? Defaults to true'
required: false
package-name: package-name:
description: 'name of the distributions releases are being created for, e.g., "name" in package.json, or "setup.py"' description: 'name of the distributions releases are being created for, e.g., "name" in package.json, or "setup.py"'
required: true required: true

View File

@@ -6,6 +6,7 @@ const RELEASE_LABEL = 'autorelease: pending'
async function main () { async function main () {
const bumpMinorPreMajor = Boolean(core.getInput('bump-minor-pre-major')) const bumpMinorPreMajor = Boolean(core.getInput('bump-minor-pre-major'))
const clean = core.getInput('clean') ? true : undefined
const monorepoTags = Boolean(core.getInput('monorepo-tags')) const monorepoTags = Boolean(core.getInput('monorepo-tags'))
const packageName = core.getInput('package-name') const packageName = core.getInput('package-name')
const path = core.getInput('path') ? core.getInput('path') : undefined const path = core.getInput('path') ? core.getInput('path') : undefined
@@ -35,11 +36,10 @@ async function main () {
}) })
const releaseCreated = await gr.createRelease() const releaseCreated = await gr.createRelease()
if (releaseCreated) { if (releaseCreated) {
// eslint-disable-next-line
const { upload_url, tag_name } = releaseCreated
core.setOutput('release_created', true) core.setOutput('release_created', true)
core.setOutput('upload_url', upload_url) for (const key of Object.keys(releaseCreated)) {
core.setOutput('tag_name', tag_name) core.setOutput(key, releaseCreated[key])
}
} }
} }
@@ -47,6 +47,7 @@ async function main () {
// release PR: // release PR:
if (!command || command === 'release-pr') { if (!command || command === 'release-pr') {
const release = releasePlease.getReleasePRFactory().buildStatic(releaseType, { const release = releasePlease.getReleasePRFactory().buildStatic(releaseType, {
clean,
monorepoTags, monorepoTags,
packageName, packageName,
path, path,
@@ -59,7 +60,8 @@ async function main () {
changelogSections, changelogSections,
versionFile versionFile
}) })
await release.run() const pr = await release.run()
core.setOutput('pr', pr)
} }
} }

32
package-lock.json generated
View File

@@ -265,9 +265,9 @@
"integrity": "sha512-fZQQafSREFyuZcdWFAExYjBiCL7AUCdgsk80iO0q4yihYYdcIiH28CcuPTGFgLOCC8RlW49GSQxdHwZP+I7CNg==" "integrity": "sha512-fZQQafSREFyuZcdWFAExYjBiCL7AUCdgsk80iO0q4yihYYdcIiH28CcuPTGFgLOCC8RlW49GSQxdHwZP+I7CNg=="
}, },
"@types/node": { "@types/node": {
"version": "14.14.7", "version": "14.14.10",
"resolved": "https://registry.npmjs.org/@types/node/-/node-14.14.7.tgz", "resolved": "https://registry.npmjs.org/@types/node/-/node-14.14.10.tgz",
"integrity": "sha512-Zw1vhUSQZYw+7u5dAwNbIA9TuTotpzY/OF7sJM9FqPOF3SPjKnxrjoTktXDZgUjybf4cWVBP7O8wvKdSaGHweg==" "integrity": "sha512-J32dgx2hw8vXrSbu4ZlVhn1Nm3GbeCFNw2FWL8S5QKucHGY0cyNwjdQdO+KMBZ4wpmC7KhLCiNsdk1RFRIYUQQ=="
}, },
"@types/normalize-package-data": { "@types/normalize-package-data": {
"version": "2.4.0", "version": "2.4.0",
@@ -275,9 +275,9 @@
"integrity": "sha512-f5j5b/Gf71L+dbqxIpQ4Z2WlmI/mPJ0fOkGGmFgtb6sAu97EPczzbS3/tJKxmcYDj55OX6ssqwDAWOHIYDRDGA==" "integrity": "sha512-f5j5b/Gf71L+dbqxIpQ4Z2WlmI/mPJ0fOkGGmFgtb6sAu97EPczzbS3/tJKxmcYDj55OX6ssqwDAWOHIYDRDGA=="
}, },
"@types/yargs": { "@types/yargs": {
"version": "15.0.9", "version": "15.0.10",
"resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-15.0.9.tgz", "resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-15.0.10.tgz",
"integrity": "sha512-HmU8SeIRhZCWcnRskCs36Q1Q00KBV6Cqh/ora8WN1+22dY07AZdn6Gel8QZ3t26XYPImtcL8WV/eqjhVmMEw4g==", "integrity": "sha512-z8PNtlhrj7eJNLmrAivM7rjBESG6JwC5xP3RVk12i/8HVP7Xnx/sEmERnRImyEuUaJfO942X0qMOYsoupaJbZQ==",
"requires": { "requires": {
"@types/yargs-parser": "*" "@types/yargs-parser": "*"
} }
@@ -3083,9 +3083,9 @@
"dev": true "dev": true
}, },
"release-please": { "release-please": {
"version": "6.9.0", "version": "7.0.0-candidate.1",
"resolved": "https://registry.npmjs.org/release-please/-/release-please-6.9.0.tgz", "resolved": "https://registry.npmjs.org/release-please/-/release-please-7.0.0-candidate.1.tgz",
"integrity": "sha512-oyOLBu2Q7RPk57tem2RPAiAI0nrmvQapBWMcAVTcEMCKW9x7yyyA8O9QHZ4kuKw3mpHr3TSkNvWlcjzkAiRRaA==", "integrity": "sha512-Q6SPRStRhY3gCxn6LW1DA1ozA8obmgtqJ9c4fP2a9QlMaRGYKx/bQmBSU3GNfNQHqFc8qxtZ7KWCPOv7KyMaNw==",
"requires": { "requires": {
"@octokit/graphql": "^4.3.1", "@octokit/graphql": "^4.3.1",
"@octokit/request": "^5.3.4", "@octokit/request": "^5.3.4",
@@ -3100,7 +3100,7 @@
"figures": "^3.0.0", "figures": "^3.0.0",
"parse-github-repo-url": "^1.4.1", "parse-github-repo-url": "^1.4.1",
"semver": "^7.0.0", "semver": "^7.0.0",
"type-fest": "^0.19.0", "type-fest": "^0.20.0",
"yargs": "^16.0.0" "yargs": "^16.0.0"
} }
}, },
@@ -3656,9 +3656,9 @@
"dev": true "dev": true
}, },
"type-fest": { "type-fest": {
"version": "0.19.0", "version": "0.20.1",
"resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.19.0.tgz", "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.20.1.tgz",
"integrity": "sha512-6lN0zC9ItzVv3jq9NicSaqo7PUjTNnmxGBECiJbz8Vv2TWaGW15mJTBS2BHZUlEKRsclzZzp8gHnBe4kzQRNfg==" "integrity": "sha512-o2p2tnFu/jjUK7tFWLXCJtv/C0wZFuXESqJXuuOifJKRwKZWnTrZw6bs7WOtcAvMRjtXgdjZnh+nVqqvm8jqxA=="
}, },
"typedarray": { "typedarray": {
"version": "0.0.6", "version": "0.0.6",
@@ -3666,9 +3666,9 @@
"integrity": "sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=" "integrity": "sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c="
}, },
"uglify-js": { "uglify-js": {
"version": "3.11.6", "version": "3.12.0",
"resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.11.6.tgz", "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.12.0.tgz",
"integrity": "sha512-oASI1FOJ7BBFkSCNDZ446EgkSuHkOZBuqRFrwXIKWCoXw8ZXQETooTQjkAcBS03Acab7ubCKsXnwuV2svy061g==", "integrity": "sha512-8lBMSkFZuAK7gGF8LswsXmir8eX8d2AAMOnxSDWjKBx/fBR6MypQjs78m6ML9zQVp1/hD4TBdfeMZMC7nW1TAA==",
"optional": true "optional": true
}, },
"uniq": { "uniq": {

View File

@@ -26,7 +26,7 @@
"homepage": "https://github.com/bcoe/release-please-action#readme", "homepage": "https://github.com/bcoe/release-please-action#readme",
"dependencies": { "dependencies": {
"@actions/core": "^1.2.6", "@actions/core": "^1.2.6",
"release-please": "^6.9.0" "release-please": "^7.0.0-candidate.1"
}, },
"devDependencies": { "devDependencies": {
"@zeit/ncc": "^0.22.3", "@zeit/ncc": "^0.22.3",

View File

@@ -41,11 +41,12 @@ describe('release-please-action', () => {
assert.deepStrictEqual(output, { assert.deepStrictEqual(output, {
release_created: true, release_created: true,
upload_url: 'http://example.com', upload_url: 'http://example.com',
tag_name: 'v1.0.0' tag_name: 'v1.0.0',
pr: undefined
}) })
}) })
it('only opens PRs if, command set to release-pr', async () => { it('only opens PR, if command set to release-pr', async () => {
const output = {} const output = {}
core.setOutput = (name, value) => { core.setOutput = (name, value) => {
output[name] = value output[name] = value
@@ -81,7 +82,7 @@ describe('release-please-action', () => {
sinon.assert.calledOnce(releasePR) sinon.assert.calledOnce(releasePR)
}) })
it('only opens tags releases, if command set to github-release', async () => { it('only creates GitHub release, if command set to github-release', async () => {
const output = {} const output = {}
core.setOutput = (name, value) => { core.setOutput = (name, value) => {
output[name] = value output[name] = value
@@ -116,4 +117,74 @@ describe('release-please-action', () => {
sinon.assert.calledOnce(githubRelease) sinon.assert.calledOnce(githubRelease)
sinon.assert.notCalled(releasePR) sinon.assert.notCalled(releasePR)
}) })
it('sets approprite outputs when GitHub release created', async () => {
const expected = {
release_created: true,
upload_url: 'http://example.com',
html_url: 'http://example2.com',
tag_name: 'v1.0.0',
major: 1,
minor: 2,
patch: 3,
version: 'v1.2.3',
sha: 'abc123',
pr: 33
}
const output = {}
core.setOutput = (name, value) => {
output[name] = value
}
const input = {
'release-type': 'node',
command: 'github-release'
}
core.getInput = (name) => {
return input[name]
}
const githubRelease = sinon.stub().returns(expected)
action.getGitHubRelease = () => {
class Release {}
Release.prototype.createRelease = githubRelease
return Release
}
const releasePR = sinon.stub()
action.getReleasePRFactory = () => {
return {
buildStatic: () => {
return {
run: releasePR
}
}
}
}
await action.main()
assert.deepStrictEqual(output, expected)
})
it('sets appropriate outputs when release PR opened', async () => {
const output = {}
core.setOutput = (name, value) => {
output[name] = value
}
const input = {
'release-type': 'node',
command: 'release-pr'
}
core.getInput = (name) => {
return input[name]
}
const releasePR = sinon.stub().returns(95)
action.getReleasePRFactory = () => {
return {
buildStatic: () => {
return {
run: releasePR
}
}
}
}
await action.main()
assert.strictEqual(output.pr, 95)
})
}) })