diff --git a/.github/workflows/_ci.yml b/.github/workflows/_ci.yml index cb534c4..f558b5c 100644 --- a/.github/workflows/_ci.yml +++ b/.github/workflows/_ci.yml @@ -23,3 +23,17 @@ jobs: - name: Check that dist/ is correctly generated run: git diff --quiet HEAD -- dist + + # NOTE: In GitHub repository settings, the "Require status checks to pass + # before merging" branch protection rule ensures that commits are only merged + # from branches where specific status checks have passed. These checks are + # specified manually as a list of workflow job names. Thus we use this extra + # job to signal whether all CI checks have passed. + ci: + name: CI status checks + runs-on: ubuntu-latest + needs: main + if: always() + steps: + - name: Check whether all jobs pass + run: echo '${{ toJson(needs) }}' | jq -e 'all(.result == "success")' \ No newline at end of file diff --git a/__tests__/cargo.test.ts b/__tests__/cargo.test.ts index ac97fae..4c38b6d 100644 --- a/__tests__/cargo.test.ts +++ b/__tests__/cargo.test.ts @@ -163,11 +163,21 @@ describe("cargo", () => { const tmp = await downloadGitHubRepo("eclipse-zenoh/zenoh", SHA_ZENOH); const version = "1.2.3-beta.1"; + const debian_version = "1.2.3~beta.1-1"; await cargo.bumpDependencies(tmp, /zenoh.*/, version); expect(toml.get(`${tmp}/Cargo.toml`, ["workspace", "dependencies", "zenoh", "version"])).toEqual(version); expect(toml.get(`${tmp}/zenoh/Cargo.toml`, ["package", "metadata", "deb", "depends"])).toEqual( - `zenohd (=${version}), zenoh-plugin-rest (=${version}), zenoh-plugin-storage-manager (=${version})`, + `zenohd (=${debian_version}), zenoh-plugin-rest (=${debian_version}), zenoh-plugin-storage-manager (=${debian_version})`, ); }); + + test("toDebianVersion()", async () => { + expect(cargo.toDebianVersion("1.0.0.0")).toEqual("1.0.0~dev-1"); + expect(cargo.toDebianVersion("1.0.0.11")).toEqual("1.0.0~pre.11-1"); + expect(cargo.toDebianVersion("1.0.0-rc.1")).toEqual("1.0.0~rc.1-1"); + expect(cargo.toDebianVersion("1.0.0")).toEqual("1.0.0"); + expect(cargo.toDebianVersion("1.0.0.1")).toEqual("1.0.0~pre.1-1"); + expect(cargo.toDebianVersion("1.0.0.1", 2)).toEqual("1.0.0~pre.1-2"); + }); }); diff --git a/dist/build-crates-debian-main.js b/dist/build-crates-debian-main.js index dd87c08..efb4050 100644 --- a/dist/build-crates-debian-main.js +++ b/dist/build-crates-debian-main.js @@ -127537,8 +127537,26 @@ function buildDebian(path, target, version) { * @returns Modified version. */ function toDebianVersion(version, revision) { - // HACK(fuzzypixelz): This is an oversimplification of the Debian Policy - return `${version.replace("-", "~")}-${revision ?? 1}`; + let debVersion = version; + // Check if version is semver or cmake version + if (version.includes("-")) { + // HACK(fuzzypixelz): This is an oversimplification of the Debian Policy + debVersion = `${version.replace("-", "~")}-${revision ?? 1}`; + } + else { + // check cmake version has tweak component + if (version.split(".").length == 4) { + if (version.endsWith(".0")) { + const pos = version.lastIndexOf(".0"); + debVersion = `${version.substring(0, pos)}~dev-${revision ?? 1}`; + } + else if (parseInt(version.substring(version.lastIndexOf(".") + 1)) > 0) { + const pos = version.lastIndexOf("."); + debVersion = `${version.substring(0, pos)}~pre.${version.substring(pos + 1)}-${revision ?? 1}`; + } + } + } + return `${debVersion}`; } /** * Check if Package is already published in crates.io diff --git a/dist/build-crates-standalone-main.js b/dist/build-crates-standalone-main.js index ce5a67c..5d52a9e 100644 --- a/dist/build-crates-standalone-main.js +++ b/dist/build-crates-standalone-main.js @@ -127521,8 +127521,26 @@ function buildDebian(path, target, version) { * @returns Modified version. */ function toDebianVersion(version, revision) { - // HACK(fuzzypixelz): This is an oversimplification of the Debian Policy - return `${version.replace("-", "~")}-${revision ?? 1}`; + let debVersion = version; + // Check if version is semver or cmake version + if (version.includes("-")) { + // HACK(fuzzypixelz): This is an oversimplification of the Debian Policy + debVersion = `${version.replace("-", "~")}-${revision ?? 1}`; + } + else { + // check cmake version has tweak component + if (version.split(".").length == 4) { + if (version.endsWith(".0")) { + const pos = version.lastIndexOf(".0"); + debVersion = `${version.substring(0, pos)}~dev-${revision ?? 1}`; + } + else if (parseInt(version.substring(version.lastIndexOf(".") + 1)) > 0) { + const pos = version.lastIndexOf("."); + debVersion = `${version.substring(0, pos)}~pre.${version.substring(pos + 1)}-${revision ?? 1}`; + } + } + } + return `${debVersion}`; } /** * Check if Package is already published in crates.io diff --git a/dist/bump-crates-main.js b/dist/bump-crates-main.js index 118c532..eed2d13 100644 --- a/dist/bump-crates-main.js +++ b/dist/bump-crates-main.js @@ -81243,8 +81243,26 @@ function buildDebian(path, target, version) { * @returns Modified version. */ function toDebianVersion(version, revision) { - // HACK(fuzzypixelz): This is an oversimplification of the Debian Policy - return `${version.replace("-", "~")}-${revision ?? 1}`; + let debVersion = version; + // Check if version is semver or cmake version + if (version.includes("-")) { + // HACK(fuzzypixelz): This is an oversimplification of the Debian Policy + debVersion = `${version.replace("-", "~")}-${revision ?? 1}`; + } + else { + // check cmake version has tweak component + if (version.split(".").length == 4) { + if (version.endsWith(".0")) { + const pos = version.lastIndexOf(".0"); + debVersion = `${version.substring(0, pos)}~dev-${revision ?? 1}`; + } + else if (parseInt(version.substring(version.lastIndexOf(".") + 1)) > 0) { + const pos = version.lastIndexOf("."); + debVersion = `${version.substring(0, pos)}~pre.${version.substring(pos + 1)}-${revision ?? 1}`; + } + } + } + return `${debVersion}`; } /** * Check if Package is already published in crates.io diff --git a/dist/publish-crates-cargo-main.js b/dist/publish-crates-cargo-main.js index 5d05b79..6f4d504 100644 --- a/dist/publish-crates-cargo-main.js +++ b/dist/publish-crates-cargo-main.js @@ -81132,8 +81132,26 @@ function buildDebian(path, target, version) { * @returns Modified version. */ function toDebianVersion(version, revision) { - // HACK(fuzzypixelz): This is an oversimplification of the Debian Policy - return `${version.replace("-", "~")}-${revision ?? 1}`; + let debVersion = version; + // Check if version is semver or cmake version + if (version.includes("-")) { + // HACK(fuzzypixelz): This is an oversimplification of the Debian Policy + debVersion = `${version.replace("-", "~")}-${revision ?? 1}`; + } + else { + // check cmake version has tweak component + if (version.split(".").length == 4) { + if (version.endsWith(".0")) { + const pos = version.lastIndexOf(".0"); + debVersion = `${version.substring(0, pos)}~dev-${revision ?? 1}`; + } + else if (parseInt(version.substring(version.lastIndexOf(".") + 1)) > 0) { + const pos = version.lastIndexOf("."); + debVersion = `${version.substring(0, pos)}~pre.${version.substring(pos + 1)}-${revision ?? 1}`; + } + } + } + return `${debVersion}`; } /** * Check if Package is already published in crates.io diff --git a/dist/publish-crates-debian-main.js b/dist/publish-crates-debian-main.js index 0f3a70d..99f17e1 100644 --- a/dist/publish-crates-debian-main.js +++ b/dist/publish-crates-debian-main.js @@ -127516,8 +127516,26 @@ function buildDebian(path, target, version) { * @returns Modified version. */ function toDebianVersion(version, revision) { - // HACK(fuzzypixelz): This is an oversimplification of the Debian Policy - return `${version.replace("-", "~")}-${revision ?? 1}`; + let debVersion = version; + // Check if version is semver or cmake version + if (version.includes("-")) { + // HACK(fuzzypixelz): This is an oversimplification of the Debian Policy + debVersion = `${version.replace("-", "~")}-${revision ?? 1}`; + } + else { + // check cmake version has tweak component + if (version.split(".").length == 4) { + if (version.endsWith(".0")) { + const pos = version.lastIndexOf(".0"); + debVersion = `${version.substring(0, pos)}~dev-${revision ?? 1}`; + } + else if (parseInt(version.substring(version.lastIndexOf(".") + 1)) > 0) { + const pos = version.lastIndexOf("."); + debVersion = `${version.substring(0, pos)}~pre.${version.substring(pos + 1)}-${revision ?? 1}`; + } + } + } + return `${debVersion}`; } /** * Check if Package is already published in crates.io diff --git a/dist/publish-crates-eclipse-main.js b/dist/publish-crates-eclipse-main.js index 9f5fdf2..82d4c0b 100644 --- a/dist/publish-crates-eclipse-main.js +++ b/dist/publish-crates-eclipse-main.js @@ -127597,8 +127597,26 @@ function buildDebian(path, target, version) { * @returns Modified version. */ function toDebianVersion(version, revision) { - // HACK(fuzzypixelz): This is an oversimplification of the Debian Policy - return `${version.replace("-", "~")}-${revision ?? 1}`; + let debVersion = version; + // Check if version is semver or cmake version + if (version.includes("-")) { + // HACK(fuzzypixelz): This is an oversimplification of the Debian Policy + debVersion = `${version.replace("-", "~")}-${revision ?? 1}`; + } + else { + // check cmake version has tweak component + if (version.split(".").length == 4) { + if (version.endsWith(".0")) { + const pos = version.lastIndexOf(".0"); + debVersion = `${version.substring(0, pos)}~dev-${revision ?? 1}`; + } + else if (parseInt(version.substring(version.lastIndexOf(".") + 1)) > 0) { + const pos = version.lastIndexOf("."); + debVersion = `${version.substring(0, pos)}~pre.${version.substring(pos + 1)}-${revision ?? 1}`; + } + } + } + return `${debVersion}`; } /** * Check if Package is already published in crates.io diff --git a/dist/publish-crates-github-main.js b/dist/publish-crates-github-main.js index 5b10d96..5886143 100644 --- a/dist/publish-crates-github-main.js +++ b/dist/publish-crates-github-main.js @@ -127597,8 +127597,26 @@ function buildDebian(path, target, version) { * @returns Modified version. */ function toDebianVersion(version, revision) { - // HACK(fuzzypixelz): This is an oversimplification of the Debian Policy - return `${version.replace("-", "~")}-${revision ?? 1}`; + let debVersion = version; + // Check if version is semver or cmake version + if (version.includes("-")) { + // HACK(fuzzypixelz): This is an oversimplification of the Debian Policy + debVersion = `${version.replace("-", "~")}-${revision ?? 1}`; + } + else { + // check cmake version has tweak component + if (version.split(".").length == 4) { + if (version.endsWith(".0")) { + const pos = version.lastIndexOf(".0"); + debVersion = `${version.substring(0, pos)}~dev-${revision ?? 1}`; + } + else if (parseInt(version.substring(version.lastIndexOf(".") + 1)) > 0) { + const pos = version.lastIndexOf("."); + debVersion = `${version.substring(0, pos)}~pre.${version.substring(pos + 1)}-${revision ?? 1}`; + } + } + } + return `${debVersion}`; } /** * Check if Package is already published in crates.io diff --git a/dist/publish-crates-homebrew-main.js b/dist/publish-crates-homebrew-main.js index f8c686f..392552f 100644 --- a/dist/publish-crates-homebrew-main.js +++ b/dist/publish-crates-homebrew-main.js @@ -127501,8 +127501,26 @@ function buildDebian(path, target, version) { * @returns Modified version. */ function toDebianVersion(version, revision) { - // HACK(fuzzypixelz): This is an oversimplification of the Debian Policy - return `${version.replace("-", "~")}-${revision ?? 1}`; + let debVersion = version; + // Check if version is semver or cmake version + if (version.includes("-")) { + // HACK(fuzzypixelz): This is an oversimplification of the Debian Policy + debVersion = `${version.replace("-", "~")}-${revision ?? 1}`; + } + else { + // check cmake version has tweak component + if (version.split(".").length == 4) { + if (version.endsWith(".0")) { + const pos = version.lastIndexOf(".0"); + debVersion = `${version.substring(0, pos)}~dev-${revision ?? 1}`; + } + else if (parseInt(version.substring(version.lastIndexOf(".") + 1)) > 0) { + const pos = version.lastIndexOf("."); + debVersion = `${version.substring(0, pos)}~pre.${version.substring(pos + 1)}-${revision ?? 1}`; + } + } + } + return `${debVersion}`; } /** * Check if Package is already published in crates.io diff --git a/src/cargo.ts b/src/cargo.ts index 53aa4ae..1c4fbea 100644 --- a/src/cargo.ts +++ b/src/cargo.ts @@ -368,8 +368,24 @@ export function buildDebian(path: string, target: string, version: string) { * @returns Modified version. */ export function toDebianVersion(version: string, revision?: number): string { - // HACK(fuzzypixelz): This is an oversimplification of the Debian Policy - return `${version.replace("-", "~")}-${revision ?? 1}`; + let debVersion = version; + // Check if version is semver or cmake version + if (version.includes("-")) { + // HACK(fuzzypixelz): This is an oversimplification of the Debian Policy + debVersion = `${version.replace("-", "~")}-${revision ?? 1}`; + } else { + // check cmake version has tweak component + if (version.split(".").length == 4) { + if (version.endsWith(".0")) { + const pos = version.lastIndexOf(".0"); + debVersion = `${version.substring(0, pos)}~dev-${revision ?? 1}`; + } else if (parseInt(version.substring(version.lastIndexOf(".") + 1)) > 0) { + const pos = version.lastIndexOf("."); + debVersion = `${version.substring(0, pos)}~pre.${version.substring(pos + 1)}-${revision ?? 1}`; + } + } + } + return `${debVersion}`; } /**