Skip to content

Commit

Permalink
fix: set gh release pre release for pre releases
Browse files Browse the repository at this point in the history
  • Loading branch information
diogomatsubara committed Oct 21, 2024
1 parent 4818aa5 commit 97af90a
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 3 deletions.
11 changes: 11 additions & 0 deletions __tests__/publish-crates-github.test.ts
Original file line number Diff line number Diff line change
@@ -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);
});
});
16 changes: 13 additions & 3 deletions dist/publish-crates-github-main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down Expand Up @@ -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) => {
Expand Down Expand Up @@ -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); } });
Expand Down
10 changes: 10 additions & 0 deletions src/publish-crates-github.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 });
}

Expand Down Expand Up @@ -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;
};

0 comments on commit 97af90a

Please sign in to comment.