From 97af90a0596af264023cf89527994a461534190f Mon Sep 17 00:00:00 2001 From: Diogo Mendes Matsubara Date: Mon, 21 Oct 2024 08:30:07 +0200 Subject: [PATCH] fix: set gh release pre release for pre releases --- __tests__/publish-crates-github.test.ts | 11 +++++++++++ dist/publish-crates-github-main.js | 16 +++++++++++++--- src/publish-crates-github.ts | 10 ++++++++++ 3 files changed, 34 insertions(+), 3 deletions(-) create mode 100644 __tests__/publish-crates-github.test.ts diff --git a/__tests__/publish-crates-github.test.ts b/__tests__/publish-crates-github.test.ts new file mode 100644 index 0000000..8f26718 --- /dev/null +++ b/__tests__/publish-crates-github.test.ts @@ -0,0 +1,11 @@ +import { isPreRelease } from "../src/publish-crates-github"; + +describe("publish-crates-github", () => { + test("isPreRelease()", async () => { + expect(isPreRelease("1.0.0")).toBe(false); + expect(isPreRelease("1.0.0.0")).toBe(true); + expect(isPreRelease("1.0.0.11")).toBe(true); + expect(isPreRelease("1.0.0-rc.1")).toBe(true); + expect(isPreRelease("1.0.0.1")).toBe(true); + }); +}); diff --git a/dist/publish-crates-github-main.js b/dist/publish-crates-github-main.js index 5886143..a20de75 100644 --- a/dist/publish-crates-github-main.js +++ b/dist/publish-crates-github-main.js @@ -127791,7 +127791,7 @@ __nccwpck_require__.r(__webpack_exports__); var __webpack_async_dependencies__ = __webpack_handle_async_dependencies__([_publish_crates_github__WEBPACK_IMPORTED_MODULE_0__]); _publish_crates_github__WEBPACK_IMPORTED_MODULE_0__ = (__webpack_async_dependencies__.then ? (await __webpack_async_dependencies__)() : __webpack_async_dependencies__)[0]; -await (0,_publish_crates_github__WEBPACK_IMPORTED_MODULE_0__/* .main */ .D)((0,_publish_crates_github__WEBPACK_IMPORTED_MODULE_0__/* .setup */ .c)()); +await (0,_publish_crates_github__WEBPACK_IMPORTED_MODULE_0__/* .main */ .DH)((0,_publish_crates_github__WEBPACK_IMPORTED_MODULE_0__/* .setup */ .cY)()); __webpack_async_result__(); } catch(e) { __webpack_async_result__(e); } }, 1); @@ -127804,9 +127804,10 @@ __webpack_async_result__(); "use strict"; __nccwpck_require__.a(module, async (__webpack_handle_async_dependencies__, __webpack_async_result__) => { try { /* harmony export */ __nccwpck_require__.d(__webpack_exports__, { -/* harmony export */ "D": () => (/* binding */ main), -/* harmony export */ "c": () => (/* binding */ setup) +/* harmony export */ "DH": () => (/* binding */ main), +/* harmony export */ "cY": () => (/* binding */ setup) /* harmony export */ }); +/* unused harmony export isPreRelease */ /* harmony import */ var _actions_core__WEBPACK_IMPORTED_MODULE_0__ = __nccwpck_require__(42186); /* harmony import */ var _actions_core__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__nccwpck_require__.n(_actions_core__WEBPACK_IMPORTED_MODULE_0__); /* harmony import */ var _actions_artifact__WEBPACK_IMPORTED_MODULE_1__ = __nccwpck_require__(79450); @@ -127861,6 +127862,9 @@ async function main(input) { if (releaseLatest != undefined) { command.push("--notes-start-tag", releaseLatest.tagName); } + if (isPreRelease(input.version)) { + command.push("--prerelease"); + } (0,_command__WEBPACK_IMPORTED_MODULE_2__.sh)(command.join(" "), { env }); } const shouldPublishArtifact = (name) => { @@ -127888,6 +127892,12 @@ async function main(input) { _actions_core__WEBPACK_IMPORTED_MODULE_0__.setFailed(error.message); } } +function isPreRelease(version) { + if (version.indexOf("-") > 0 || version.split(".").length == 4) { + return true; + } + return false; +} __webpack_async_result__(); } catch(e) { __webpack_async_result__(e); } }); diff --git a/src/publish-crates-github.ts b/src/publish-crates-github.ts index 91bf746..1e2e8a2 100644 --- a/src/publish-crates-github.ts +++ b/src/publish-crates-github.ts @@ -58,6 +58,9 @@ export async function main(input: Input) { if (releaseLatest != undefined) { command.push("--notes-start-tag", releaseLatest.tagName); } + if (isPreRelease(input.version)) { + command.push("--prerelease") + } sh(command.join(" "), { env }); } @@ -86,6 +89,13 @@ export async function main(input: Input) { } } +export function isPreRelease(version: string): boolean { + if (version.indexOf("-") > 0 || version.split(".").length == 4) { + return true + } + return false +} + type GitHubRelease = { tagName: string; };