mirror of
https://github.com/vrtmrz/obsidian-livesync.git
synced 2026-07-23 04:52:58 +00:00
Prepare the 1.0 compatibility review flow
This commit is contained in:
@@ -13,6 +13,7 @@ const workspaceUpdateScript = fileURLToPath(new URL("../update-workspaces.mjs",
|
||||
const prepareReleaseWorkflow = fileURLToPath(new URL("../.github/workflows/prepare-release.yml", import.meta.url));
|
||||
const finaliseReleaseWorkflow = fileURLToPath(new URL("../.github/workflows/finalise-release.yml", import.meta.url));
|
||||
const releaseWorkflow = fileURLToPath(new URL("../.github/workflows/release.yml", import.meta.url));
|
||||
const cliDockerWorkflow = fileURLToPath(new URL("../.github/workflows/cli-docker.yml", import.meta.url));
|
||||
const temporaryDirectories: string[] = [];
|
||||
|
||||
afterEach(() => {
|
||||
@@ -150,7 +151,7 @@ describe("release workflow", () => {
|
||||
expect(workflow).toContain("Mark this pull request ready and merge it with a merge commit");
|
||||
});
|
||||
|
||||
it("explicitly dispatches publishing workflows after creating tags", () => {
|
||||
it("dispatches the plug-in workflow and lets the CLI tag trigger its own workflow", () => {
|
||||
const workflow = readFileSync(finaliseReleaseWorkflow, "utf8");
|
||||
|
||||
expect(workflow).toContain("actions: write");
|
||||
@@ -158,8 +159,8 @@ describe("release workflow", () => {
|
||||
expect(workflow).toContain('git push --atomic origin "refs/tags/${VERSION}" "refs/tags/${VERSION}-cli"');
|
||||
expect(workflow).not.toContain("Tag already exists");
|
||||
expect(workflow).toContain("gh workflow run release.yml");
|
||||
expect(workflow).toContain("gh workflow run cli-docker.yml");
|
||||
expect(workflow).toContain("dry_run=false");
|
||||
expect(workflow).not.toContain("gh workflow run cli-docker.yml");
|
||||
expect(workflow).toContain("its tag event starts the container workflow");
|
||||
});
|
||||
|
||||
it("publishes only by explicit dispatch and validates the selected release", () => {
|
||||
@@ -171,6 +172,29 @@ describe("release workflow", () => {
|
||||
expect(workflow).toContain('TAG_SHA="$(git rev-parse "refs/tags/${TAG}^{commit}")"');
|
||||
expect(workflow).not.toContain("Get Version");
|
||||
});
|
||||
|
||||
it("supports a pre-release plug-in without creating or publishing a CLI release", () => {
|
||||
const workflow = readFileSync(finaliseReleaseWorkflow, "utf8");
|
||||
|
||||
expect(workflow).toContain("prerelease:");
|
||||
expect(workflow).toContain("publish_cli:");
|
||||
expect(workflow).toContain('--field prerelease="${PRERELEASE}"');
|
||||
expect(workflow).toContain("--plugin-only");
|
||||
});
|
||||
|
||||
it("does not attach an unsupported release archive", () => {
|
||||
const workflow = readFileSync(releaseWorkflow, "utf8");
|
||||
|
||||
expect(workflow).not.toContain("zip -r");
|
||||
expect(workflow).not.toContain("${{ github.event.repository.name }}.zip");
|
||||
});
|
||||
|
||||
it("does not promote a pre-release CLI image to stable moving tags", () => {
|
||||
const workflow = readFileSync(cliDockerWorkflow, "utf8");
|
||||
|
||||
expect(workflow).toContain('if [[ "${VERSION}" == *-* ]]; then');
|
||||
expect(workflow).toContain('TAGS="${IMAGE}:${VERSION}-cli,${IMAGE}:${VERSION}-sha-${SHORT_SHA}-cli"');
|
||||
});
|
||||
});
|
||||
|
||||
describe("release tags", () => {
|
||||
@@ -198,6 +222,16 @@ describe("release tags", () => {
|
||||
);
|
||||
expect(tags.has("0.25.84")).toBe(false);
|
||||
});
|
||||
|
||||
it("can create only the plug-in tag for a review release", () => {
|
||||
const head = "a".repeat(40);
|
||||
const { git, tags } = createTagGit(head);
|
||||
|
||||
ensureTags("1.0.0-rc.0", head, git, () => undefined, { pluginOnly: true });
|
||||
|
||||
expect(tags.get("1.0.0-rc.0")).toBe(head);
|
||||
expect(tags.has("1.0.0-rc.0-cli")).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe("version bump", () => {
|
||||
|
||||
@@ -36,10 +36,10 @@ function resolveTag(tag, runGit) {
|
||||
return runGit(["rev-parse", "--verify", "--quiet", `refs/tags/${tag}^{commit}`], true);
|
||||
}
|
||||
|
||||
export function ensureTags(version, expectedRevision, runGit = git, log = console.log) {
|
||||
export function ensureTags(version, expectedRevision, runGit = git, log = console.log, options = {}) {
|
||||
assertVersion(version);
|
||||
const expectedCommit = resolveCommit(expectedRevision, runGit);
|
||||
const tags = [version, `${version}-cli`];
|
||||
const tags = options.pluginOnly ? [version] : [version, `${version}-cli`];
|
||||
const existing = tags.map((tag) => ({ tag, commit: resolveTag(tag, runGit) }));
|
||||
|
||||
for (const { tag, commit } of existing) {
|
||||
@@ -60,13 +60,13 @@ export function ensureTags(version, expectedRevision, runGit = git, log = consol
|
||||
|
||||
const isMain = process.argv[1] && import.meta.url === pathToFileURL(resolve(process.argv[1])).href;
|
||||
if (isMain) {
|
||||
const [command, version, expectedRevision] = process.argv.slice(2);
|
||||
if (command !== "ensure" || !version || !expectedRevision) {
|
||||
fail("Usage: node utils/release-tags.mjs ensure <version> <expected-commit>");
|
||||
const [command, version, expectedRevision, mode] = process.argv.slice(2);
|
||||
if (command !== "ensure" || !version || !expectedRevision || (mode && mode !== "--plugin-only")) {
|
||||
fail("Usage: node utils/release-tags.mjs ensure <version> <expected-commit> [--plugin-only]");
|
||||
}
|
||||
|
||||
try {
|
||||
ensureTags(version, expectedRevision);
|
||||
ensureTags(version, expectedRevision, git, console.log, { pluginOnly: mode === "--plugin-only" });
|
||||
} catch (error) {
|
||||
fail(error instanceof Error ? error.message : String(error));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user