mirror of
https://github.com/changesets/action
synced 2026-10-26 16:39:56 +08:00
Add select-mode, version, pack and publish sub-actions (#656)
* Add select-mode, version, and publish sub-actions * Rename * No github-token needed for select-mode for now * extend select-mode with publish-plan check and upload * Rename base-branch to pr-base-branch * add `pack` subaction * `--from-pack` support in the publish subaction * rename CLI arg * update rolldown config * rename pack dir input/output * tweak retendion days --------- Co-authored-by: Mateusz Burzyński <mateuszburzynski@gmail.com>
This commit is contained in:
co-authored by
Mateusz Burzyński
parent
5649ff41b8
commit
a12d90de83
@@ -0,0 +1,56 @@
|
||||
import * as core from "@actions/core";
|
||||
import { Git } from "../git.ts";
|
||||
import { setupOctokit } from "../octokit.ts";
|
||||
import { runVersion } from "../run.ts";
|
||||
|
||||
try {
|
||||
await main();
|
||||
} catch (err) {
|
||||
core.setFailed((err as Error).message);
|
||||
}
|
||||
|
||||
async function main() {
|
||||
const githubToken = core.getInput("github-token", { required: true });
|
||||
const script = core.getInput("script");
|
||||
const commitMessage = core.getInput("commit-message", { required: true });
|
||||
const prTitle = core.getInput("pr-title", { required: true });
|
||||
const prDraft = core.getInput("pr-draft") || undefined;
|
||||
const prBaseBranch = core.getInput("pr-base-branch");
|
||||
const commitMode = core.getInput("commit-mode") || "git-cli";
|
||||
const setupGitUser = core.getBooleanInput("setup-git-user");
|
||||
|
||||
// Validations
|
||||
if (prDraft !== undefined && prDraft !== "always" && prDraft !== "create") {
|
||||
throw new Error(`Invalid pr-draft input: ${prDraft}`);
|
||||
}
|
||||
|
||||
// If the user needs to change the cwd, set `working-directory` in the step instead
|
||||
const cwd = process.cwd();
|
||||
|
||||
const octokit = setupOctokit(githubToken);
|
||||
const git = new Git({
|
||||
octokit: commitMode === "github-api" ? octokit : undefined,
|
||||
cwd,
|
||||
});
|
||||
|
||||
if (setupGitUser) {
|
||||
core.info("setting git user");
|
||||
await git.setupUser();
|
||||
}
|
||||
|
||||
const { pullRequestNumber } = await runVersion({
|
||||
script,
|
||||
githubToken,
|
||||
git,
|
||||
octokit,
|
||||
cwd,
|
||||
prTitle,
|
||||
commitMessage,
|
||||
// TODO: Use neutral message for PR description
|
||||
hasPublishScript: true,
|
||||
prDraft,
|
||||
branch: prBaseBranch,
|
||||
});
|
||||
|
||||
core.setOutput("pr-number", String(pullRequestNumber));
|
||||
}
|
||||
Reference in New Issue
Block a user