Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
369 changes: 185 additions & 184 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -105536,190 +105536,191 @@ var __webpack_exports__ = {};
(() => {
"use strict";
var exports = __webpack_exports__;

// Copyright 2023 Google LLC
//
// 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
//
// https://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.
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.main = void 0;
const core = __nccwpck_require__(42186);
const release_please_1 = __nccwpck_require__(24363);
const DEFAULT_CONFIG_FILE = 'release-please-config.json';
const DEFAULT_MANIFEST_FILE = '.release-please-manifest.json';
const DEFAULT_GITHUB_API_URL = 'https://api.github.com';
const DEFAULT_GITHUB_GRAPHQL_URL = 'https://api.github.com';
const DEFAULT_GITHUB_SERVER_URL = 'https://github.com';
function parseInputs() {
const inputs = {
token: core.getInput('token', { required: true }),
releaseType: getOptionalInput('release-type'),
path: getOptionalInput('path'),
repoUrl: core.getInput('repo-url') || process.env.GITHUB_REPOSITORY || '',
targetBranch: getOptionalInput('target-branch'),
configFile: core.getInput('config-file') || DEFAULT_CONFIG_FILE,
manifestFile: core.getInput('manifest-file') || DEFAULT_MANIFEST_FILE,
githubApiUrl: core.getInput('github-api-url') || DEFAULT_GITHUB_API_URL,
githubGraphqlUrl: (core.getInput('github-graphql-url') || '').replace(/\/graphql$/, '') ||
DEFAULT_GITHUB_GRAPHQL_URL,
proxyServer: getOptionalInput('proxy-server'),
skipGitHubRelease: getOptionalBooleanInput('skip-github-release'),
skipGitHubPullRequest: getOptionalBooleanInput('skip-github-pull-request'),
skipLabeling: getOptionalBooleanInput('skip-labeling'),
fork: getOptionalBooleanInput('fork'),
includeComponentInTag: getOptionalBooleanInput('include-component-in-tag'),
changelogHost: core.getInput('changelog-host') || DEFAULT_GITHUB_SERVER_URL,
versioningStrategy: getOptionalInput('versioning-strategy'),
releaseAs: getOptionalInput('release-as'),
};
return inputs;
}
function getOptionalInput(name) {
return core.getInput(name) || undefined;
}
function getOptionalBooleanInput(name) {
const val = core.getInput(name);
if (val === '' || val === undefined) {
return undefined;
}
return core.getBooleanInput(name);
}
function loadOrBuildManifest(github, inputs) {
if (inputs.releaseType) {
core.debug('Building manifest from config');
return release_please_1.Manifest.fromConfig(github, github.repository.defaultBranch, {
releaseType: inputs.releaseType,
includeComponentInTag: inputs.includeComponentInTag,
changelogHost: inputs.changelogHost,
versioning: inputs.versioningStrategy,
releaseAs: inputs.releaseAs,
}, {
fork: inputs.fork,
skipLabeling: inputs.skipLabeling,
}, inputs.path);
}
const manifestOverrides = inputs.fork || inputs.skipLabeling
? {
fork: inputs.fork,
skipLabeling: inputs.skipLabeling,
}
: {};
core.debug('Loading manifest from config file');
return release_please_1.Manifest.fromManifest(github, github.repository.defaultBranch, inputs.configFile, inputs.manifestFile, manifestOverrides).then(manifest => {
// Override changelogHost for all paths if provided as action input and different from default
if (inputs.changelogHost && inputs.changelogHost !== DEFAULT_GITHUB_SERVER_URL) {
core.debug(`Overriding changelogHost to: ${inputs.changelogHost}`);
for (const path in manifest.repositoryConfig) {
manifest.repositoryConfig[path].changelogHost = inputs.changelogHost;
}
}
return manifest;
});
}
async function main(fetchOverride) {
core.info(`Running release-please version: ${release_please_1.VERSION}`);
const inputs = parseInputs();
const github = await getGitHubInstance(inputs, fetchOverride);
if (!inputs.skipGitHubRelease) {
const manifest = await loadOrBuildManifest(github, inputs);
core.debug('Creating releases');
outputReleases(await manifest.createReleases());
}
if (!inputs.skipGitHubPullRequest) {
const manifest = await loadOrBuildManifest(github, inputs);
core.debug('Creating pull requests');
outputPRs(await manifest.createPullRequests());
}
}
exports.main = main;
function getGitHubInstance(inputs, fetchOverride) {
const [owner, repo] = inputs.repoUrl.split('/');
let proxy = undefined;
if (inputs.proxyServer) {
const [host, port] = inputs.proxyServer.split(':');
proxy = {
host,
port: parseInt(port),
};
}
const githubCreateOpts = {
proxy,
owner,
repo,
apiUrl: inputs.githubApiUrl,
graphqlUrl: inputs.githubGraphqlUrl,
token: inputs.token,
defaultBranch: inputs.targetBranch,
fetch: fetchOverride,
};
return release_please_1.GitHub.create(githubCreateOpts);
}
function setPathOutput(path, key, value) {
if (path === '.') {
core.setOutput(key, value);
}
else {
core.setOutput(`${path}--${key}`, value);
}
}
function outputReleases(releases) {
releases = releases.filter(release => release !== undefined);
const pathsReleased = [];
core.setOutput('releases_created', releases.length > 0);
if (releases.length) {
for (const release of releases) {
if (!release) {
continue;
}
const path = release.path || '.';
if (path) {
pathsReleased.push(path);
// If the special root release is set (representing project root)
// and this is explicitly a manifest release, set the release_created boolean.
setPathOutput(path, 'release_created', true);
}
for (const [rawKey, value] of Object.entries(release)) {
let key = rawKey;
// Historically tagName was output as tag_name, keep this
// consistent to avoid breaking change:
if (key === 'tagName')
key = 'tag_name';
if (key === 'uploadUrl')
key = 'upload_url';
if (key === 'notes')
key = 'body';
if (key === 'url')
key = 'html_url';
setPathOutput(path, key, value);
}
}
}
// Paths of all releases that were created, so that they can be passed
// to matrix in next step:
core.setOutput('paths_released', JSON.stringify(pathsReleased));
}
function outputPRs(prs) {
prs = prs.filter(pr => pr !== undefined);
core.setOutput('prs_created', prs.length > 0);
if (prs.length) {
core.setOutput('pr', prs[0]);
core.setOutput('prs', JSON.stringify(prs));
}
}
if (require.main === require.cache[eval('__filename')]) {
main().catch(err => {
core.setFailed(`release-please failed: ${err.message}`);
});
}

// Copyright 2023 Google LLC
//
// 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
//
// https://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.
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.main = void 0;
const core = __nccwpck_require__(42186);
const release_please_1 = __nccwpck_require__(24363);
const DEFAULT_CONFIG_FILE = 'release-please-config.json';
const DEFAULT_MANIFEST_FILE = '.release-please-manifest.json';
const DEFAULT_GITHUB_API_URL = 'https://api.github.com';
const DEFAULT_GITHUB_GRAPHQL_URL = 'https://api.github.com';
const DEFAULT_GITHUB_SERVER_URL = 'https://github.com';
function parseInputs() {
const inputs = {
token: core.getInput('token', { required: true }),
releaseType: getOptionalInput('release-type'),
path: getOptionalInput('path'),
repoUrl: core.getInput('repo-url') || process.env.GITHUB_REPOSITORY || '',
targetBranch: getOptionalInput('target-branch'),
configFile: core.getInput('config-file') || DEFAULT_CONFIG_FILE,
manifestFile: core.getInput('manifest-file') || DEFAULT_MANIFEST_FILE,
githubApiUrl: core.getInput('github-api-url') || DEFAULT_GITHUB_API_URL,
githubGraphqlUrl: (core.getInput('github-graphql-url') || '').replace(/\/graphql$/, '') ||
DEFAULT_GITHUB_GRAPHQL_URL,
proxyServer: getOptionalInput('proxy-server'),
skipGitHubRelease: getOptionalBooleanInput('skip-github-release'),
skipGitHubPullRequest: getOptionalBooleanInput('skip-github-pull-request'),
skipLabeling: getOptionalBooleanInput('skip-labeling'),
fork: getOptionalBooleanInput('fork'),
includeComponentInTag: getOptionalBooleanInput('include-component-in-tag'),
changelogHost: core.getInput('changelog-host') || DEFAULT_GITHUB_SERVER_URL,
versioningStrategy: getOptionalInput('versioning-strategy'),
releaseAs: getOptionalInput('release-as'),
};
return inputs;
}
function getOptionalInput(name) {
return core.getInput(name) || undefined;
}
function getOptionalBooleanInput(name) {
const val = core.getInput(name);
if (val === '' || val === undefined) {
return undefined;
}
return core.getBooleanInput(name);
}
function loadOrBuildManifest(github, inputs) {
if (inputs.releaseType) {
core.debug('Building manifest from config');
return release_please_1.Manifest.fromConfig(github, github.repository.defaultBranch, {
releaseType: inputs.releaseType,
includeComponentInTag: inputs.includeComponentInTag,
changelogHost: inputs.changelogHost,
versioning: inputs.versioningStrategy,
releaseAs: inputs.releaseAs,
}, {
fork: inputs.fork,
skipLabeling: inputs.skipLabeling,
}, inputs.path);
}
const manifestOverrides = inputs.fork || inputs.skipLabeling
? {
fork: inputs.fork,
skipLabeling: inputs.skipLabeling,
}
: {};
core.debug('Loading manifest from config file');
return release_please_1.Manifest.fromManifest(github, github.repository.defaultBranch, inputs.configFile, inputs.manifestFile, manifestOverrides).then(manifest => {
// Override changelogHost for all paths if provided as action input and different from default
if (inputs.changelogHost && inputs.changelogHost !== DEFAULT_GITHUB_SERVER_URL) {
core.debug(`Overriding changelogHost to: ${inputs.changelogHost}`);
for (const path in manifest.repositoryConfig) {
manifest.repositoryConfig[path].changelogHost = inputs.changelogHost;
}
}
return manifest;
});
}
async function main(fetchOverride) {
core.info(`Running release-please version: ${release_please_1.VERSION}`);
const inputs = parseInputs();
const github = await getGitHubInstance(inputs, fetchOverride);
// Build the manifest once and reuse for both operations to avoid
// redundant API calls to fetch config and release history.
const manifest = await loadOrBuildManifest(github, inputs);
if (!inputs.skipGitHubRelease) {
core.debug('Creating releases');
outputReleases(await manifest.createReleases());
}
if (!inputs.skipGitHubPullRequest) {
core.debug('Creating pull requests');
outputPRs(await manifest.createPullRequests());
}
}
exports.main = main;
function getGitHubInstance(inputs, fetchOverride) {
const [owner, repo] = inputs.repoUrl.split('/');
let proxy = undefined;
if (inputs.proxyServer) {
const [host, port] = inputs.proxyServer.split(':');
proxy = {
host,
port: parseInt(port),
};
}
const githubCreateOpts = {
proxy,
owner,
repo,
apiUrl: inputs.githubApiUrl,
graphqlUrl: inputs.githubGraphqlUrl,
token: inputs.token,
defaultBranch: inputs.targetBranch,
fetch: fetchOverride,
};
return release_please_1.GitHub.create(githubCreateOpts);
}
function setPathOutput(path, key, value) {
if (path === '.') {
core.setOutput(key, value);
}
else {
core.setOutput(`${path}--${key}`, value);
}
}
function outputReleases(releases) {
releases = releases.filter(release => release !== undefined);
const pathsReleased = [];
core.setOutput('releases_created', releases.length > 0);
if (releases.length) {
for (const release of releases) {
if (!release) {
continue;
}
const path = release.path || '.';
if (path) {
pathsReleased.push(path);
// If the special root release is set (representing project root)
// and this is explicitly a manifest release, set the release_created boolean.
setPathOutput(path, 'release_created', true);
}
for (const [rawKey, value] of Object.entries(release)) {
let key = rawKey;
// Historically tagName was output as tag_name, keep this
// consistent to avoid breaking change:
if (key === 'tagName')
key = 'tag_name';
if (key === 'uploadUrl')
key = 'upload_url';
if (key === 'notes')
key = 'body';
if (key === 'url')
key = 'html_url';
setPathOutput(path, key, value);
}
}
}
// Paths of all releases that were created, so that they can be passed
// to matrix in next step:
core.setOutput('paths_released', JSON.stringify(pathsReleased));
}
function outputPRs(prs) {
prs = prs.filter(pr => pr !== undefined);
core.setOutput('prs_created', prs.length > 0);
if (prs.length) {
core.setOutput('pr', prs[0]);
core.setOutput('prs', JSON.stringify(prs));
}
}
if (require.main === require.cache[eval('__filename')]) {
main().catch(err => {
core.setFailed(`release-please failed: ${err.message}`);
});
}

})();

Expand Down
Loading