-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
config.ts
98 lines (92 loc) · 2.8 KB
/
config.ts
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
93
94
95
96
97
98
import path from 'path';
import { UserConfig } from './types';
import { promises as fs } from 'fs';
const ciConfig = {
configFile: process.env.PLUGIN_CONFIG_FILE,
isCI: process.env.CI === 'woodpecker',
eventType: process.env.CI_PIPELINE_EVENT,
releaseBranch: process.env.PLUGIN_RELEASE_BRANCH || process.env.CI_REPO_DEFAULT_BRANCH || 'main',
commitMessage: process.env.CI_COMMIT_MESSAGE,
forgeType: process.env.PLUGIN_FORGE_TYPE || process.env.CI_FORGE_TYPE,
forgeToken: process.env.PLUGIN_FORGE_TOKEN || process.env.PLUGIN_GITHUB_TOKEN,
forgeURL: process.env.PLUGIN_FORGE_URL || process.env.CI_FORGE_URL,
gitEmail: process.env.PLUGIN_GIT_EMAIL,
repoOwner: process.env.CI_REPO_OWNER,
repoName: process.env.CI_REPO_NAME,
pullRequestBranchPrefix: process.env.PLUGIN_PULL_REQUEST_BRANCH_PREFIX || 'next-release/',
debug: process.env.PLUGIN_DEBUG === 'true',
releasePrefix: process.env.PLUGIN_RELEASE_PREFIX || '🎉 Release',
};
export type Config = { user: UserConfig; ci: typeof ciConfig };
export const defaultUserConfig: UserConfig = {
changeTypes: [
{
title: '💥 Breaking changes',
labels: ['breaking'],
bump: 'major',
weight: 3,
},
{
title: '🔒 Security',
labels: ['security'],
bump: 'patch',
weight: 2,
},
{
title: '✨ Features',
labels: ['feature', 'feature 🚀️'],
bump: 'minor',
weight: 1,
},
{
title: '📈 Enhancement',
labels: ['enhancement', 'refactor', 'enhancement 👆️'],
bump: 'minor',
},
{
title: '🐛 Bug Fixes',
labels: ['bug', 'bug 🐛️'],
bump: 'patch',
},
{
title: '📚 Documentation',
labels: ['docs', 'documentation', 'documentation 📖️'],
bump: 'patch',
},
{
title: '📦️ Dependency',
labels: ['dependency', 'dependencies'],
bump: 'patch',
weight: -1,
},
{
title: 'Misc',
labels: ['misc', 'chore 🧰'],
bump: 'patch',
default: true,
weight: -2,
},
],
skipLabels: ['skip-release', 'skip-changelog', 'regression'],
skipCommitsWithoutPullRequest: true,
commentOnReleasedPullRequests: false,
};
export async function getConfig(basePath?: string): Promise<Config> {
const userConfig: UserConfig = {};
const configFilePath = ciConfig.configFile || path.resolve(basePath ?? process.cwd(), 'release-config.ts');
if (
await fs
.stat(configFilePath)
.then(() => true)
.catch(() => false)
) {
console.log('# Loading config from', configFilePath, '...');
const _userConfig = await import(configFilePath);
Object.assign(userConfig, _userConfig.default);
console.log('# Loaded config from', configFilePath);
}
return {
user: { ...defaultUserConfig, ...userConfig },
ci: ciConfig,
};
}