@@ -24711,7 +24711,7 @@ module.exports = {
24711
24711
"use strict";
24712
24712
__nccwpck_require__.a(module, async (__webpack_handle_async_dependencies__, __webpack_async_result__) => { try {
24713
24713
__nccwpck_require__.r(__webpack_exports__);
24714
- /* harmony import */ var _create_release_branch__WEBPACK_IMPORTED_MODULE_0__ = __nccwpck_require__(1712 );
24714
+ /* harmony import */ var _create_release_branch__WEBPACK_IMPORTED_MODULE_0__ = __nccwpck_require__(6210 );
24715
24715
24716
24716
await (0,_create_release_branch__WEBPACK_IMPORTED_MODULE_0__/* .main */ .DH)((0,_create_release_branch__WEBPACK_IMPORTED_MODULE_0__/* .setup */ .cY)());
24717
24717
@@ -24720,7 +24720,7 @@ __webpack_async_result__();
24720
24720
24721
24721
/***/ }),
24722
24722
24723
- /***/ 1712 :
24723
+ /***/ 6210 :
24724
24724
/***/ ((__unused_webpack_module, __webpack_exports__, __nccwpck_require__) => {
24725
24725
24726
24726
"use strict";
@@ -24743,7 +24743,7 @@ const external_child_process_namespaceObject = require("child_process");
24743
24743
24744
24744
24745
24745
const MAX_BUFFER = 10 * 1024 * 1024;
24746
- function sh (cmd, options) {
24746
+ function command_sh (cmd, options) {
24747
24747
options = options != null ? options : {};
24748
24748
options.env = options.env != null ? options.env : {};
24749
24749
options.cwd = options.cwd != null ? options.cwd : ".";
@@ -24816,21 +24816,42 @@ function exec(program, args, options) {
24816
24816
return returns.stdout;
24817
24817
}
24818
24818
24819
+ ;// CONCATENATED MODULE: ./src/git.ts
24820
+
24821
+ function cloneFromGitHub(repo, options) {
24822
+ const remote = options.token == undefined ? `https://github.com/${repo}.git` : `https://${options.token}@github.com/${repo}.git`;
24823
+ const command = ["git", "clone", "--recursive", "--single-branch"];
24824
+ if (options.branch != undefined) {
24825
+ command.push("--branch", options.branch);
24826
+ }
24827
+ command.push(remote);
24828
+ if (options.path != undefined) {
24829
+ command.push(options.path);
24830
+ }
24831
+ command_sh(command.join(" "));
24832
+ }
24833
+ function describe(path = process.cwd()) {
24834
+ return sh("git describe", { cwd: path }).trim();
24835
+ }
24836
+
24819
24837
;// CONCATENATED MODULE: ./src/create-release-branch.ts
24820
24838
24821
24839
24822
24840
24841
+
24823
24842
const DEFAULT_DRY_RUN_HISTORY_SIZE = 5;
24824
24843
function setup() {
24825
24844
const version = lib_core.getInput("version");
24826
24845
const liveRun = lib_core.getBooleanInput("live-run", { required: true });
24846
+ const dryRunHistorySize = lib_core.getInput("dry-run-history-size", { required: false });
24827
24847
const repo = lib_core.getInput("repo", { required: true });
24848
+ const branch = lib_core.getInput("branch", { required: false });
24828
24849
const githubToken = lib_core.getInput("github-token", { required: true });
24829
- const dryRunHistorySize = lib_core.getInput("dry-run-history-size");
24830
24850
return {
24831
24851
version: version === "" ? undefined : version,
24832
24852
liveRun,
24833
24853
repo,
24854
+ branch,
24834
24855
githubToken,
24835
24856
dryRunHistorySize: dryRunHistorySize == "" ? DEFAULT_DRY_RUN_HISTORY_SIZE : Number(dryRunHistorySize),
24836
24857
};
@@ -24839,8 +24860,8 @@ async function main(input) {
24839
24860
try {
24840
24861
const repo = input.repo.split("/")[1];
24841
24862
const remote = `https://${input.githubToken}@github.com/${input.repo}.git`;
24842
- sh(`git clone --recursive ${remote}` );
24843
- const version = input.version ?? sh ("git describe", { cwd: repo }).trimEnd();
24863
+ cloneFromGitHub(input.repo, { token: input.githubToken, branch: input.branch } );
24864
+ const version = input.version ?? command_sh ("git describe", { cwd: repo }).trimEnd();
24844
24865
lib_core.setOutput("version", version);
24845
24866
let branch;
24846
24867
if (input.liveRun) {
@@ -24853,17 +24874,17 @@ async function main(input) {
24853
24874
const refsPattern = "refs/remotes/origin/release/dry-run";
24854
24875
// for some reason using the full refname won't work to delete the remote branch, so
24855
24876
// refname:strip=3 removes 'refs/remotes/origin' from the pattern to have the branch name only.
24856
- const refsRaw = sh (`git for-each-ref --format='%(refname:strip=3)' --sort=authordate ${refsPattern}`, {
24877
+ const refsRaw = command_sh (`git for-each-ref --format='%(refname:strip=3)' --sort=authordate ${refsPattern}`, {
24857
24878
cwd: repo,
24858
24879
});
24859
24880
const refs = refsRaw.split("\n");
24860
24881
if (refs.length >= input.dryRunHistorySize) {
24861
24882
const toDelete = refs.slice(0, refs.length - input.dryRunHistorySize);
24862
- toDelete.forEach(ref => sh (`git push origin --delete ${ref}`, { cwd: repo }));
24883
+ toDelete.forEach(ref => command_sh (`git push origin --delete ${ref}`, { cwd: repo }));
24863
24884
}
24864
24885
}
24865
- sh (`git switch --force-create ${branch}`, { cwd: repo });
24866
- sh (`git push --force ${remote} ${branch}`, { cwd: repo });
24886
+ command_sh (`git switch --force-create ${branch}`, { cwd: repo });
24887
+ command_sh (`git push --force ${remote} ${branch}`, { cwd: repo });
24867
24888
await cleanup(input);
24868
24889
}
24869
24890
catch (error) {
0 commit comments