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
2 changes: 1 addition & 1 deletion .changeset/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"$schema": "https://unpkg.com/@changesets/config@1.6.2/schema.json",
"changelog": [
"@changesets/changelog-github",
{ "repo": "changesets/action" }
{ "repo": "telia-actions/changesets-action" }
],
"commit": false,
"linked": [],
Expand Down
26 changes: 25 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,28 @@
# @changesets/action
# @telia-actions/changeset-action

## 1.4.7

### Patch Changes

- [`27e0cf7`](https://github.com/telia-actions/changesets-action/commit/27e0cf7ad1a9af99bbebbef4d8ca49c68da7b1dd) Thanks [@theomuller](https://github.com/theomuller)! - Update from parent repository.

## 1.4.6

### Patch Changes

- [#6](https://github.com/telia-actions/changesets-action/pull/6) [`c075836`](https://github.com/telia-actions/changesets-action/commit/c0758365433964248f0547e6f636e5085eba7cfa) Thanks [@theomuller](https://github.com/theomuller)! - Update from parent repository.

## 1.4.2

### Patch Changes

- [#4](https://github.com/telia-actions/changesets-action/pull/4) [`49e841a`](https://github.com/telia-actions/changesets-action/commit/49e841a09280a0846775bb505dacfed5264a664a) Thanks [@theomuller](https://github.com/theomuller)! - Update from head repository

## 1.4.1

### Patch Changes

- [#123](https://github.com/changesets/action/pull/123) [`b78f480`](https://github.com/changesets/action/commit/b78f48099899f0a853c5d9cd3feb21a5440babbd) Thanks [@Andarist](https://github.com/Andarist)! - Updated `@actions/*` dependencies to avoid using deprecated features of the runner.

## 1.4.8

Expand Down
4 changes: 4 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ inputs:
description: "A boolean value to indicate whether to create Github releases after `publish` or not"
required: false
default: true
exitPrereleaseMode:
description: "A boolean value to indicate whether to exit prerelease mode or not"
required: false
default: false
branch:
description: Sets the branch in which the action will run. Default to `github.ref_name` if not provided
required: false
Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"name": "@changesets/action",
"version": "1.4.8",
"name": "@telia-actions/changeset-action",
"version": "1.4.7",
"main": "dist/index.js",
"private": true,
"license": "MIT",
"devDependencies": {
"@changesets/changelog-github": "^0.4.2",
Expand Down
12 changes: 12 additions & 0 deletions src/exitPreMode.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { readPreState, exitPre } from "@changesets/pre";

export default async function exitPreMode(
cwd: string = process.cwd()
): Promise<void> {
let preState = await readPreState(cwd);
let isInPreMode = preState !== undefined && preState.mode === "pre";

if (isInPreMode) {
await exitPre(cwd);
}
}
5 changes: 4 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ const getOptionalInput = (name: string) => core.getInput(name) || undefined;
`machine github.com\nlogin github-actions[bot]\npassword ${githubToken}`
);

let { changesets } = await readChangesetState();
let exitPrereleaseMode = core.getBooleanInput("exitPrereleaseMode");

let { changesets } = await readChangesetState(process.cwd(), exitPrereleaseMode);

let publishScript = core.getInput("publish");
let hasChangesets = changesets.length !== 0;
Expand Down Expand Up @@ -109,6 +111,7 @@ const getOptionalInput = (name: string) => core.getInput(name) || undefined;
prTitle: getOptionalInput("title"),
commitMessage: getOptionalInput("commit"),
hasPublishScript,
exitPrereleaseMode,
branch: getOptionalInput("branch"),
});

Expand Down
8 changes: 5 additions & 3 deletions src/readChangesetState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@ export type ChangesetState = {
};

export default async function readChangesetState(
cwd: string = process.cwd()
cwd: string = process.cwd(),
exitingPrereleaseMode: boolean = false,
): Promise<ChangesetState> {
let preState = await readPreState(cwd);
let changesets = await readChangesets(cwd);

if (preState !== undefined && preState.mode === "pre") {
let isInPreMode = preState !== undefined && preState.mode === "pre";

if (isInPreMode && preState && !exitingPrereleaseMode) {
let changesetsToFilter = new Set(preState.changesets);

return {
Expand Down
23 changes: 15 additions & 8 deletions src/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
import * as gitUtils from "./gitUtils";
import readChangesetState from "./readChangesetState";
import resolveFrom from "resolve-from";
import exitPreMode from "./exitPreMode";
import { throttling } from "@octokit/plugin-throttling";

// GitHub Issues/PRs messages have a max size limit on the
Expand Down Expand Up @@ -232,12 +233,12 @@ type GetMessageOptions = {
header: string;
}[];
prBodyMaxCharacters: number;
preState?: PreState;
isPrerelease: boolean;
};

export async function getVersionPrBody({
hasPublishScript,
preState,
isPrerelease,
changedPackagesInfo,
prBodyMaxCharacters,
branch,
Expand All @@ -248,7 +249,7 @@ export async function getVersionPrBody({
: `publish to npm yourself or [setup this action to publish automatically](https://github.com/changesets/action#with-publishing)`
}. If you're not ready to do a release yet, that's fine, whenever you add more changesets to ${branch}, this PR will be updated.
`;
let messagePrestate = !!preState
let messagePrestate = isPrerelease
? `⚠️⚠️⚠️⚠️⚠️⚠️

\`${branch}\` is currently in **pre mode** so this branch has prereleases rather than normal releases. If you want to exit prereleases, run \`changeset pre exit\` on \`${branch}\`.
Expand Down Expand Up @@ -299,6 +300,7 @@ type VersionOptions = {
commitMessage?: string;
hasPublishScript?: boolean;
prBodyMaxCharacters?: number;
exitPrereleaseMode?: boolean;
branch?: string;
};

Expand All @@ -314,6 +316,7 @@ export async function runVersion({
commitMessage = "Version Packages",
hasPublishScript = false,
prBodyMaxCharacters = MAX_CHARACTERS_PER_MESSAGE,
exitPrereleaseMode = false,
branch,
}: VersionOptions): Promise<RunVersionResult> {
const octokit = setupOctokit(githubToken);
Expand All @@ -327,6 +330,10 @@ export async function runVersion({
await gitUtils.switchToMaybeExistingBranch(versionBranch);
await gitUtils.reset(github.context.sha);

if (exitPrereleaseMode) {
await exitPreMode();
}

let versionsByDirectory = await getVersionsByDirectory(cwd);

if (script) {
Expand Down Expand Up @@ -366,13 +373,13 @@ export async function runVersion({
})
);

const finalPrTitle = `${prTitle}${!!preState ? ` (${preState.tag})` : ""}`;
const isPrerelease = !!preState && !exitPrereleaseMode;
const releaseTypeString = `${isPrerelease && preState? ` (${preState.tag})` : ""}`;
const finalPrTitle = `${prTitle}${releaseTypeString}`;

// project with `commit: true` setting could have already committed files
if (!(await gitUtils.checkIfClean())) {
const finalCommitMessage = `${commitMessage}${
!!preState ? ` (${preState.tag})` : ""
}`;
const finalCommitMessage = `${commitMessage}${releaseTypeString}`;
await gitUtils.commitAll(finalCommitMessage);
}

Expand All @@ -387,7 +394,7 @@ export async function runVersion({

let prBody = await getVersionPrBody({
hasPublishScript,
preState,
isPrerelease,
branch,
changedPackagesInfo,
prBodyMaxCharacters,
Expand Down