1
0
mirror of https://github.com/joaquinjsb/gitea-release-please-action synced 2026-05-11 16:11:35 +02:00

feat: manifest based releaser https://git.io/JmVD4 (#273)

This commit is contained in:
Joel Dodge
2021-03-24 14:59:21 -07:00
committed by GitHub
parent 3428959728
commit 45c32ccd24
3 changed files with 102 additions and 7 deletions

View File

@@ -1,6 +1,9 @@
const core = require('@actions/core')
const { factory } = require('release-please/build/src')
const CONFIG_FILE = 'release-please-config.json'
const MANIFEST_FILE = '.release-please-manifest.json'
const MANIFEST_COMMAND = 'manifest'
const RELEASE_LABEL = 'autorelease: pending'
const GITHUB_RELEASE_COMMAND = 'github-release'
const GITHUB_RELEASE_PR_COMMAND = 'release-pr'
@@ -14,20 +17,62 @@ function getBooleanInput (input) {
throw TypeError(`Wrong boolean value of the input '${input}'`)
}
function getGitHubInput () {
return {
fork: getBooleanInput('fork'),
defaultBranch: core.getInput('default-branch') || undefined,
repoUrl: process.env.GITHUB_REPOSITORY,
apiUrl: 'https://api.github.com',
token: core.getInput('token', { required: true })
}
}
function getManifestInput () {
return {
configFile: core.getInput('config-file') || CONFIG_FILE,
manifestFile: core.getInput('manifest-file') || MANIFEST_FILE
}
}
async function runManifest () {
const githubOpts = getGitHubInput()
const manifestOpts = { ...githubOpts, ...getManifestInput() }
const pr = await factory.runCommand('manifest-pr', manifestOpts)
if (pr) {
core.setOutput('pr', pr)
}
const releasesCreated = await factory.runCommand('manifest-release', manifestOpts)
if (releasesCreated) {
core.setOutput('releases_created', true)
for (const [path, release] of Object.entries(releasesCreated)) {
if (!release) {
continue
}
for (const [key, val] of Object.entries(release)) {
core.setOutput(`${path}--${key}`, val)
}
}
}
}
async function main () {
const command = core.getInput('command') || undefined
if (command === MANIFEST_COMMAND) {
return await runManifest()
}
const { token, fork, defaultBranch, apiUrl, repoUrl } = getGitHubInput()
const bumpMinorPreMajor = getBooleanInput('bump-minor-pre-major')
const monorepoTags = getBooleanInput('monorepo-tags')
const packageName = core.getInput('package-name')
const path = core.getInput('path') || undefined
const releaseType = core.getInput('release-type', { required: true })
const token = core.getInput('token', { required: true })
const fork = getBooleanInput('fork')
const changelogPath = core.getInput('changelog-path') || undefined
const changelogTypes = core.getInput('changelog-types') || undefined
const changelogSections = changelogTypes && JSON.parse(changelogTypes)
const command = core.getInput('command') || undefined
const versionFile = core.getInput('version-file') || undefined
const defaultBranch = core.getInput('default-branch') || undefined
const pullRequestTitlePattern = core.getInput('pull-request-title-pattern') || undefined
// First we check for any merged release PRs (PRs merged with the label
@@ -62,10 +107,10 @@ async function main () {
monorepoTags,
packageName,
path,
apiUrl: 'https://api.github.com',
repoUrl: process.env.GITHUB_REPOSITORY,
apiUrl,
repoUrl,
fork,
token: token,
token,
label: RELEASE_LABEL,
bumpMinorPreMajor,
changelogSections,