mirror of https://github.com/theNewDynamic/gohugo-theme-ananke.git

Patrick Kollitsch
yesterday 1832a681026ac3db6e62aa90cb5ed75886ea69ac
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
import { execSync } from "node:child_process";
import { createReleaseConfig } from "@dnbhq/release-config";
import type { Config } from "release-it";
 
function getCurrentBranch(): string {
  try {
    return execSync("git rev-parse --abbrev-ref HEAD", {
      encoding: "utf8",
      stdio: ["ignore", "pipe", "pipe"],
    }).trim();
  } catch (error: unknown) {
    console.error("Failed to determine the current Git branch.");
    console.error(error);
    process.exit(1);
  }
}
 
function isPreReleaseRun(argv: string[]): boolean {
  return argv.some((argument) => {
    return (
      argument === "--preRelease" ||
      argument.startsWith("--preRelease=") ||
      argument === "--preReleaseId" ||
      argument.startsWith("--preReleaseId=")
    );
  });
}
 
const currentBranch = getCurrentBranch();
const preReleaseRun = isPreReleaseRun(process.argv);
 
if (preReleaseRun && currentBranch !== "development") {
  console.error(
    `Pre-releases are only allowed on "development". Current branch: "${currentBranch}".`,
  );
  process.exit(1);
}
 
if (!preReleaseRun && currentBranch !== "main") {
  console.error(
    `Stable releases are only allowed on "main". Current branch: "${currentBranch}".`,
  );
  process.exit(1);
}
 
const config: Config = createReleaseConfig({
  githubTokenRef: "GITHUB_ANANKE_TOKEN_ADMIN_PRIVATE",
  scopes: {
    minorTypes: ["feat"],
    patchTypes: [
      "fix",
      "build",
      "chore",
      "ci",
      "docs",
      "perf",
      "refactor",
      "revert",
      "style",
      "test",
      "ai",
    ],
  },
  overrides: {
    git: {
      requireCleanWorkingDir: true,
      requireBranch: currentBranch,
      commit: true,
      // biome-ignore lint/suspicious/noTemplateCurlyInString: release-it expands this placeholder.
      commitMessage: "chore(release): v${version}",
      commitArgs: ["--no-verify"],
      tag: true,
      // biome-ignore lint/suspicious/noTemplateCurlyInString: release-it expands this placeholder.
      tagName: "v${version}",
      push: true,
      pushArgs: ["--follow-tags"],
    },
    github: {
      release: true,
      // biome-ignore lint/suspicious/noTemplateCurlyInString: release-it expands this placeholder.
      releaseName: "Release v${version}",
      skipChecks: true,
      tokenRef: "GITHUB_ANANKE_TOKEN_ADMIN_PRIVATE",
      comments: {
        submit: true,
      },
      discussionCategoryName: "1-release-notes",
    },
  },
});
 
export default config;