diff --git a/plugins/gh-pages/__tests__/gh-pages.test.ts b/plugins/gh-pages/__tests__/gh-pages.test.ts index 150c881a1..199b31501 100644 --- a/plugins/gh-pages/__tests__/gh-pages.test.ts +++ b/plugins/gh-pages/__tests__/gh-pages.test.ts @@ -45,6 +45,14 @@ describe("Gh-Pages Plugin", () => { expect(execSpy).not.toHaveBeenCalled(); }); + test("should not release on anything on a dry run", async () => { + const hooks = createTest({ dir: "test" }); + + await hooks.beforeShipIt.promise({ releaseType: "latest", dryRun: true }); + + expect(execSpy).not.toHaveBeenCalled(); + }); + test("should not release if there is a version bump", async () => { const hooks = createTest({ dir: "test" }, { getVersion: () => "patch" }); diff --git a/plugins/gh-pages/src/index.ts b/plugins/gh-pages/src/index.ts index c76bb8133..859a538fb 100644 --- a/plugins/gh-pages/src/index.ts +++ b/plugins/gh-pages/src/index.ts @@ -53,35 +53,38 @@ export default class GhPagesPlugin implements IPlugin { } }); - auto.hooks.beforeShipIt.tapPromise(this.name, async ({ releaseType }) => { - if (releaseType !== "latest" || !auto.git) { - return; - } + auto.hooks.beforeShipIt.tapPromise( + this.name, + async ({ releaseType, dryRun }) => { + if (releaseType !== "latest" || !auto.git || dryRun) { + return; + } - const bump = await auto.getVersion(); + const bump = await auto.getVersion(); - // If it's a bump the 'afterRelease' hook will release the docs - if (bump !== SEMVER.noVersion) { - return; - } + // If it's a bump the 'afterRelease' hook will release the docs + if (bump !== SEMVER.noVersion) { + return; + } - const sha = await auto.git.getSha(); - const pr = await auto.git.matchCommitToPr(sha); + const sha = await auto.git.getSha(); + const pr = await auto.git.matchCommitToPr(sha); - if (!pr) { - return; - } + if (!pr) { + return; + } - const hasDocumentationLabel = pr.labels.includes(this.options.label); + const hasDocumentationLabel = pr.labels.includes(this.options.label); - if (!hasDocumentationLabel) { - return; - } + if (!hasDocumentationLabel) { + return; + } - // If: skip-release + w/documentation label then we will push to gh-pages - await auto.setGitUser(); - await this.releaseGhPages(auto); - }); + // If: skip-release + w/documentation label then we will push to gh-pages + await auto.setGitUser(); + await this.releaseGhPages(auto); + } + ); auto.hooks.afterRelease.tapPromise(this.name, async ({ response }) => { if (!response) {