Compare commits
20 Commits
Author | SHA1 | Date | |
---|---|---|---|
8d706275e6 | |||
62f0ffff69 | |||
aed6046022 | |||
2905f30af7 | |||
3c23675eec | |||
8df87c67d2 | |||
d318f9ea5e | |||
ed032bad48 | |||
5200cc526c | |||
1ba54342bc | |||
29659db0b7 | |||
44d8d11b4a | |||
622c112f7f | |||
0930ce3636 | |||
061e19d861 | |||
511d2d9c06 | |||
8cb7703aa1 | |||
5e254836e8 | |||
93710f2846 | |||
f3854126ac |
46
CHANGELOG.md
46
CHANGELOG.md
@ -1,8 +1,54 @@
|
||||
## [1.0.63] - 2025-06-12
|
||||
|
||||
### Added
|
||||
|
||||
- 📊 **CI Job Log Pagination**: Added pagination support for CI job logs to prevent context window flooding
|
||||
- `get_pipeline_job_output` now supports optional `limit` and `offset` parameters
|
||||
- Default limit is 1000 lines when pagination is used
|
||||
- Returns lines from the end of the log, with configurable offset
|
||||
- Includes truncation metadata showing what was skipped
|
||||
- Maintains backward compatibility (no parameters = full log)
|
||||
- See: [PR #97](https://github.com/zereight/gitlab-mcp/pull/97)
|
||||
|
||||
---
|
||||
|
||||
## [1.0.62] - 2025-06-10
|
||||
|
||||
### Fixed
|
||||
|
||||
- 🔐 **Private Token Authentication Fix**: Fixed Private-Token header authentication for GitLab API
|
||||
- Removed incorrect `Bearer ` prefix from Private-Token header in legacy authentication mode
|
||||
- Fixed authentication issues when using older GitLab instances with private tokens
|
||||
- Ensures proper API authentication for both new and legacy GitLab configurations
|
||||
- See: [PR #91](https://github.com/zereight/gitlab-mcp/pull/91), [Issue #88](https://github.com/zereight/gitlab-mcp/issues/88)
|
||||
|
||||
---
|
||||
|
||||
## [1.0.60] - 2025-06-07
|
||||
|
||||
### Added
|
||||
|
||||
- 📄 **Merge Request Enhancement**: Added support for `remove_source_branch` and `squash` options for merge requests
|
||||
- Enhanced merge request functionality with additional configuration options
|
||||
- Allows automatic source branch removal after merge
|
||||
- Supports squash commits for cleaner Git history
|
||||
- See: [PR #86](https://github.com/zereight/gitlab-mcp/pull/86)
|
||||
|
||||
### Fixed
|
||||
|
||||
- 🔧 **Issue Assignment Fix**: Fixed list issues assignee username handling
|
||||
- Corrected assignee username field in issue listing functionality
|
||||
- Improved user assignment data processing for GitLab issues
|
||||
- See: [PR #87](https://github.com/zereight/gitlab-mcp/pull/87), [Issue #74](https://github.com/zereight/gitlab-mcp/issues/74)
|
||||
|
||||
---
|
||||
|
||||
## [1.0.54] - 2025-05-31
|
||||
|
||||
### Added
|
||||
|
||||
- 🌐 **Multi-Platform Support**: Added support for multiple platforms to improve compatibility across different environments
|
||||
|
||||
- Enhanced platform detection and configuration handling
|
||||
- Improved cross-platform functionality for GitLab MCP server
|
||||
- See: [PR #71](https://github.com/zereight/gitlab-mcp/pull/71), [Issue #69](https://github.com/zereight/gitlab-mcp/issues/69)
|
||||
|
@ -84,7 +84,7 @@ docker run -i --rm \
|
||||
-e USE_PIPELINE=true \
|
||||
-e SSE=true \
|
||||
-p 3333:3002 \
|
||||
gitlab-mcp
|
||||
iwakitakuma/gitlab-mcp
|
||||
```
|
||||
|
||||
```json
|
||||
|
11
RELEASE_NOTES.md
Normal file
11
RELEASE_NOTES.md
Normal file
@ -0,0 +1,11 @@
|
||||
## [1.0.62] - 2025-06-10
|
||||
|
||||
### Fixed
|
||||
|
||||
- 🔐 **Private Token Authentication Fix**: Fixed Private-Token header authentication for GitLab API
|
||||
- Removed incorrect `Bearer ` prefix from Private-Token header in legacy authentication mode
|
||||
- Fixed authentication issues when using older GitLab instances with private tokens
|
||||
- Ensures proper API authentication for both new and legacy GitLab configurations
|
||||
- See: [PR #91](https://github.com/zereight/gitlab-mcp/pull/91), [Issue #88](https://github.com/zereight/gitlab-mcp/issues/88)
|
||||
|
||||
---
|
197
index.ts
197
index.ts
@ -17,7 +17,7 @@ import path from "path";
|
||||
import express, { Request, Response } from "express";
|
||||
// Add type imports for proxy agents
|
||||
import { Agent } from "http";
|
||||
import { Agent as HttpsAgent } from 'https';
|
||||
import { Agent as HttpsAgent } from "https";
|
||||
import { URL } from "url";
|
||||
|
||||
import {
|
||||
@ -171,6 +171,7 @@ import {
|
||||
GitLabCompareResult,
|
||||
GitLabCompareResultSchema,
|
||||
GetBranchDiffsSchema,
|
||||
ListWikiPagesOptions,
|
||||
} from "./schemas.js";
|
||||
|
||||
/**
|
||||
@ -186,7 +187,7 @@ try {
|
||||
SERVER_VERSION = packageJson.version || SERVER_VERSION;
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Warning: Could not read version from package.json:", error);
|
||||
// Warning: Could not read version from package.json - silently continue
|
||||
}
|
||||
|
||||
const server = new Server(
|
||||
@ -202,6 +203,7 @@ const server = new Server(
|
||||
);
|
||||
|
||||
const GITLAB_PERSONAL_ACCESS_TOKEN = process.env.GITLAB_PERSONAL_ACCESS_TOKEN;
|
||||
const IS_OLD = process.env.GITLAB_IS_OLD === "true";
|
||||
const GITLAB_READ_ONLY_MODE = process.env.GITLAB_READ_ONLY_MODE === "true";
|
||||
const USE_GITLAB_WIKI = process.env.USE_GITLAB_WIKI === "true";
|
||||
const USE_MILESTONE = process.env.USE_MILESTONE === "true";
|
||||
@ -214,12 +216,12 @@ const HTTPS_PROXY = process.env.HTTPS_PROXY;
|
||||
const NODE_TLS_REJECT_UNAUTHORIZED = process.env.NODE_TLS_REJECT_UNAUTHORIZED;
|
||||
const GITLAB_CA_CERT_PATH = process.env.GITLAB_CA_CERT_PATH;
|
||||
|
||||
let sslOptions= undefined;
|
||||
if (NODE_TLS_REJECT_UNAUTHORIZED === '0') {
|
||||
let sslOptions = undefined;
|
||||
if (NODE_TLS_REJECT_UNAUTHORIZED === "0") {
|
||||
sslOptions = { rejectUnauthorized: false };
|
||||
} else if (GITLAB_CA_CERT_PATH) {
|
||||
const ca = fs.readFileSync(GITLAB_CA_CERT_PATH);
|
||||
sslOptions = { ca };
|
||||
const ca = fs.readFileSync(GITLAB_CA_CERT_PATH);
|
||||
sslOptions = { ca };
|
||||
}
|
||||
|
||||
// Configure proxy agents if proxies are set
|
||||
@ -244,11 +246,15 @@ httpsAgent = httpsAgent || new HttpsAgent(sslOptions);
|
||||
httpAgent = httpAgent || new Agent();
|
||||
|
||||
// Modify DEFAULT_HEADERS to include agent configuration
|
||||
const DEFAULT_HEADERS = {
|
||||
const DEFAULT_HEADERS: Record<string, string> = {
|
||||
Accept: "application/json",
|
||||
"Content-Type": "application/json",
|
||||
Authorization: `Bearer ${GITLAB_PERSONAL_ACCESS_TOKEN}`,
|
||||
};
|
||||
if (IS_OLD) {
|
||||
DEFAULT_HEADERS["Private-Token"] = `${GITLAB_PERSONAL_ACCESS_TOKEN}`;
|
||||
} else {
|
||||
DEFAULT_HEADERS["Authorization"] = `Bearer ${GITLAB_PERSONAL_ACCESS_TOKEN}`;
|
||||
}
|
||||
|
||||
// Create a default fetch configuration object that includes proxy agents if set
|
||||
const DEFAULT_FETCH_CONFIG = {
|
||||
@ -322,8 +328,7 @@ const allTools = [
|
||||
},
|
||||
{
|
||||
name: "get_branch_diffs",
|
||||
description:
|
||||
"Get the changes/diffs between two branches or commits in a GitLab project",
|
||||
description: "Get the changes/diffs between two branches or commits in a GitLab project",
|
||||
inputSchema: zodToJsonSchema(GetBranchDiffsSchema),
|
||||
},
|
||||
{
|
||||
@ -518,7 +523,7 @@ const allTools = [
|
||||
},
|
||||
{
|
||||
name: "get_pipeline_job_output",
|
||||
description: "Get the output/trace of a GitLab pipeline job number",
|
||||
description: "Get the output/trace of a GitLab pipeline job with optional pagination to limit context window usage",
|
||||
inputSchema: zodToJsonSchema(GetPipelineJobOutputSchema),
|
||||
},
|
||||
{
|
||||
@ -906,13 +911,18 @@ async function listIssues(
|
||||
// Add all query parameters
|
||||
Object.entries(options).forEach(([key, value]) => {
|
||||
if (value !== undefined) {
|
||||
if (key === "labels" && Array.isArray(value)) {
|
||||
// Handle array of labels
|
||||
value.forEach(label => {
|
||||
url.searchParams.append("labels[]", label.toString());
|
||||
});
|
||||
const keys = ["labels", "assignee_username"];
|
||||
if (keys.includes(key)) {
|
||||
if (Array.isArray(value)) {
|
||||
// Handle array of labels
|
||||
value.forEach(label => {
|
||||
url.searchParams.append(`${key}[]`, label.toString());
|
||||
});
|
||||
} else {
|
||||
url.searchParams.append(`${key}[]`, value.toString());
|
||||
}
|
||||
} else {
|
||||
url.searchParams.append("labels[]", value.toString());
|
||||
url.searchParams.append(key, value.toString());
|
||||
}
|
||||
}
|
||||
});
|
||||
@ -1194,6 +1204,8 @@ async function createMergeRequest(
|
||||
labels: options.labels?.join(","),
|
||||
allow_collaboration: options.allow_collaboration,
|
||||
draft: options.draft,
|
||||
remove_source_branch: options.remove_source_branch,
|
||||
squash: options.squash,
|
||||
}),
|
||||
});
|
||||
|
||||
@ -1226,7 +1238,7 @@ async function listDiscussions(
|
||||
resourceType: "issues" | "merge_requests",
|
||||
resourceIid: number,
|
||||
options: PaginationOptions = {}
|
||||
): Promise<PaginatedDiscussionsResponse> {
|
||||
): Promise<PaginatedDiscussionsResponse> {
|
||||
projectId = decodeURIComponent(projectId); // Decode project ID
|
||||
const url = new URL(
|
||||
`${GITLAB_API_URL}/projects/${encodeURIComponent(
|
||||
@ -1251,12 +1263,20 @@ async function listDiscussions(
|
||||
|
||||
// Extract pagination headers
|
||||
const pagination = {
|
||||
x_next_page: response.headers.get("x-next-page") ? parseInt(response.headers.get("x-next-page")!) : null,
|
||||
x_next_page: response.headers.get("x-next-page")
|
||||
? parseInt(response.headers.get("x-next-page")!)
|
||||
: null,
|
||||
x_page: response.headers.get("x-page") ? parseInt(response.headers.get("x-page")!) : undefined,
|
||||
x_per_page: response.headers.get("x-per-page") ? parseInt(response.headers.get("x-per-page")!) : undefined,
|
||||
x_prev_page: response.headers.get("x-prev-page") ? parseInt(response.headers.get("x-prev-page")!) : null,
|
||||
x_per_page: response.headers.get("x-per-page")
|
||||
? parseInt(response.headers.get("x-per-page")!)
|
||||
: undefined,
|
||||
x_prev_page: response.headers.get("x-prev-page")
|
||||
? parseInt(response.headers.get("x-prev-page")!)
|
||||
: null,
|
||||
x_total: response.headers.get("x-total") ? parseInt(response.headers.get("x-total")!) : null,
|
||||
x_total_pages: response.headers.get("x-total-pages") ? parseInt(response.headers.get("x-total-pages")!) : null,
|
||||
x_total_pages: response.headers.get("x-total-pages")
|
||||
? parseInt(response.headers.get("x-total-pages")!)
|
||||
: null,
|
||||
};
|
||||
|
||||
return PaginatedDiscussionsResponseSchema.parse({
|
||||
@ -1833,14 +1853,14 @@ async function getBranchDiffs(
|
||||
straight?: boolean
|
||||
): Promise<GitLabCompareResult> {
|
||||
projectId = decodeURIComponent(projectId); // Decode project ID
|
||||
|
||||
|
||||
const url = new URL(
|
||||
`${GITLAB_API_URL}/projects/${encodeURIComponent(projectId)}/repository/compare`
|
||||
);
|
||||
|
||||
|
||||
url.searchParams.append("from", from);
|
||||
url.searchParams.append("to", to);
|
||||
|
||||
|
||||
if (straight !== undefined) {
|
||||
url.searchParams.append("straight", straight.toString());
|
||||
}
|
||||
@ -1851,9 +1871,7 @@ async function getBranchDiffs(
|
||||
|
||||
if (!response.ok) {
|
||||
const errorBody = await response.text();
|
||||
throw new Error(
|
||||
`GitLab API error: ${response.status} ${response.statusText}\n${errorBody}`
|
||||
);
|
||||
throw new Error(`GitLab API error: ${response.status} ${response.statusText}\n${errorBody}`);
|
||||
}
|
||||
|
||||
const data = await response.json();
|
||||
@ -2376,12 +2394,14 @@ async function listGroupProjects(
|
||||
*/
|
||||
async function listWikiPages(
|
||||
projectId: string,
|
||||
options: Omit<z.infer<typeof ListWikiPagesSchema>, "project_id"> = {}
|
||||
options: Omit<ListWikiPagesOptions, "project_id"> = {}
|
||||
): Promise<GitLabWikiPage[]> {
|
||||
projectId = decodeURIComponent(projectId); // Decode project ID
|
||||
const url = new URL(`${GITLAB_API_URL}/projects/${encodeURIComponent(projectId)}/wikis`);
|
||||
if (options.page) url.searchParams.append("page", options.page.toString());
|
||||
if (options.per_page) url.searchParams.append("per_page", options.per_page.toString());
|
||||
if (options.with_content)
|
||||
url.searchParams.append("with_content", options.with_content.toString());
|
||||
const response = await fetch(url.toString(), {
|
||||
...DEFAULT_FETCH_CONFIG,
|
||||
});
|
||||
@ -2591,9 +2611,11 @@ async function getPipelineJob(projectId: string, jobId: number): Promise<GitLabP
|
||||
*
|
||||
* @param {string} projectId - The ID or URL-encoded path of the project
|
||||
* @param {number} jobId - The ID of the job
|
||||
* @param {number} limit - Maximum number of lines to return from the end (default: 1000)
|
||||
* @param {number} offset - Number of lines to skip from the end (default: 0)
|
||||
* @returns {Promise<string>} The job output/trace
|
||||
*/
|
||||
async function getPipelineJobOutput(projectId: string, jobId: number): Promise<string> {
|
||||
async function getPipelineJobOutput(projectId: string, jobId: number, limit?: number, offset?: number): Promise<string> {
|
||||
projectId = decodeURIComponent(projectId); // Decode project ID
|
||||
const url = new URL(
|
||||
`${GITLAB_API_URL}/projects/${encodeURIComponent(projectId)}/jobs/${jobId}/trace`
|
||||
@ -2612,7 +2634,35 @@ async function getPipelineJobOutput(projectId: string, jobId: number): Promise<s
|
||||
}
|
||||
|
||||
await handleGitLabError(response);
|
||||
return await response.text();
|
||||
const fullTrace = await response.text();
|
||||
|
||||
// Apply client-side pagination to limit context window usage
|
||||
if (limit !== undefined || offset !== undefined) {
|
||||
const lines = fullTrace.split('\n');
|
||||
const startOffset = offset || 0;
|
||||
const maxLines = limit || 1000;
|
||||
|
||||
// Return lines from the end, skipping offset lines and limiting to maxLines
|
||||
const startIndex = Math.max(0, lines.length - startOffset - maxLines);
|
||||
const endIndex = lines.length - startOffset;
|
||||
|
||||
const selectedLines = lines.slice(startIndex, endIndex);
|
||||
const result = selectedLines.join('\n');
|
||||
|
||||
// Add metadata about truncation
|
||||
if (startIndex > 0 || endIndex < lines.length) {
|
||||
const totalLines = lines.length;
|
||||
const shownLines = selectedLines.length;
|
||||
const skippedFromStart = startIndex;
|
||||
const skippedFromEnd = startOffset;
|
||||
|
||||
return `[Log truncated: showing ${shownLines} of ${totalLines} lines, skipped ${skippedFromStart} from start, ${skippedFromEnd} from end]\n\n${result}`;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
return fullTrace;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -2633,10 +2683,13 @@ async function createPipeline(
|
||||
|
||||
const body: any = { ref };
|
||||
if (variables && variables.length > 0) {
|
||||
body.variables = variables.reduce((acc, { key, value }) => {
|
||||
acc[key] = value;
|
||||
return acc;
|
||||
}, {} as Record<string, string>);
|
||||
body.variables = variables.reduce(
|
||||
(acc, { key, value }) => {
|
||||
acc[key] = value;
|
||||
return acc;
|
||||
},
|
||||
{} as Record<string, string>
|
||||
);
|
||||
}
|
||||
|
||||
const response = await fetch(url.toString(), {
|
||||
@ -2712,15 +2765,20 @@ async function getRepositoryTree(options: GetRepositoryTreeOptions): Promise<Git
|
||||
if (options.page_token) queryParams.append("page_token", options.page_token);
|
||||
if (options.pagination) queryParams.append("pagination", options.pagination);
|
||||
|
||||
const headers: Record<string, string> = {
|
||||
"Content-Type": "application/json",
|
||||
};
|
||||
if (IS_OLD) {
|
||||
headers["Private-Token"] = `${GITLAB_PERSONAL_ACCESS_TOKEN}`;
|
||||
} else {
|
||||
headers["Authorization"] = `Bearer ${GITLAB_PERSONAL_ACCESS_TOKEN}`;
|
||||
}
|
||||
const response = await fetch(
|
||||
`${GITLAB_API_URL}/projects/${encodeURIComponent(
|
||||
options.project_id
|
||||
)}/repository/tree?${queryParams.toString()}`,
|
||||
{
|
||||
headers: {
|
||||
Authorization: `Bearer ${GITLAB_PERSONAL_ACCESS_TOKEN}`,
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
headers,
|
||||
}
|
||||
);
|
||||
|
||||
@ -2968,9 +3026,9 @@ async function getUser(username: string): Promise<GitLabUser | null> {
|
||||
});
|
||||
|
||||
await handleGitLabError(response);
|
||||
|
||||
|
||||
const users = await response.json();
|
||||
|
||||
|
||||
// GitLab returns an array of users that match the username
|
||||
if (Array.isArray(users) && users.length > 0) {
|
||||
// Find exact match for username (case-sensitive)
|
||||
@ -2979,7 +3037,7 @@ async function getUser(username: string): Promise<GitLabUser | null> {
|
||||
return GitLabUserSchema.parse(exactMatch);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// No matching user found
|
||||
return null;
|
||||
} catch (error) {
|
||||
@ -2990,13 +3048,13 @@ async function getUser(username: string): Promise<GitLabUser | null> {
|
||||
|
||||
/**
|
||||
* Get multiple users from GitLab
|
||||
*
|
||||
*
|
||||
* @param {string[]} usernames - Array of usernames to look up
|
||||
* @returns {Promise<GitLabUsersResponse>} Object with usernames as keys and user objects or null as values
|
||||
*/
|
||||
async function getUsers(usernames: string[]): Promise<GitLabUsersResponse> {
|
||||
const users: Record<string, GitLabUser | null> = {};
|
||||
|
||||
|
||||
// Process usernames sequentially to avoid rate limiting
|
||||
for (const username of usernames) {
|
||||
try {
|
||||
@ -3025,9 +3083,7 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
|
||||
? tools1
|
||||
: tools1.filter(tool => !milestoneToolNames.includes(tool.name));
|
||||
// Toggle pipeline tools by USE_PIPELINE flag
|
||||
let tools = USE_PIPELINE
|
||||
? tools2
|
||||
: tools2.filter(tool => !pipelineToolNames.includes(tool.name));
|
||||
let tools = USE_PIPELINE ? tools2 : tools2.filter(tool => !pipelineToolNames.includes(tool.name));
|
||||
|
||||
// <<< START: Gemini 호환성을 위해 $schema 제거 >>>
|
||||
tools = tools.map(tool => {
|
||||
@ -3101,26 +3157,19 @@ server.setRequestHandler(CallToolRequestSchema, async request => {
|
||||
|
||||
case "get_branch_diffs": {
|
||||
const args = GetBranchDiffsSchema.parse(request.params.arguments);
|
||||
const diffResp = await getBranchDiffs(
|
||||
args.project_id,
|
||||
args.from,
|
||||
args.to,
|
||||
args.straight
|
||||
);
|
||||
const diffResp = await getBranchDiffs(args.project_id, args.from, args.to, args.straight);
|
||||
|
||||
if (args.excluded_file_patterns?.length) {
|
||||
const regexPatterns = args.excluded_file_patterns.map(pattern => new RegExp(pattern));
|
||||
|
||||
|
||||
// Helper function to check if a path matches any regex pattern
|
||||
const matchesAnyPattern = (path: string): boolean => {
|
||||
if (!path) return false;
|
||||
return regexPatterns.some(regex => regex.test(path));
|
||||
};
|
||||
|
||||
|
||||
// Filter out files that match any of the regex patterns on new files
|
||||
diffResp.diffs = diffResp.diffs.filter(diff =>
|
||||
!matchesAnyPattern(diff.new_path)
|
||||
);
|
||||
diffResp.diffs = diffResp.diffs.filter(diff => !matchesAnyPattern(diff.new_path));
|
||||
}
|
||||
return {
|
||||
content: [{ type: "text", text: JSON.stringify(diffResp, null, 2) }],
|
||||
@ -3399,11 +3448,11 @@ server.setRequestHandler(CallToolRequestSchema, async request => {
|
||||
content: [{ type: "text", text: JSON.stringify(projects, null, 2) }],
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
case "get_users": {
|
||||
const args = GetUsersSchema.parse(request.params.arguments);
|
||||
const usersMap = await getUsers(args.usernames);
|
||||
|
||||
|
||||
return {
|
||||
content: [{ type: "text", text: JSON.stringify(usersMap, null, 2) }],
|
||||
};
|
||||
@ -3597,8 +3646,10 @@ server.setRequestHandler(CallToolRequestSchema, async request => {
|
||||
}
|
||||
|
||||
case "list_wiki_pages": {
|
||||
const { project_id, page, per_page } = ListWikiPagesSchema.parse(request.params.arguments);
|
||||
const wikiPages = await listWikiPages(project_id, { page, per_page });
|
||||
const { project_id, page, per_page, with_content } = ListWikiPagesSchema.parse(
|
||||
request.params.arguments
|
||||
);
|
||||
const wikiPages = await listWikiPages(project_id, { page, per_page, with_content });
|
||||
return {
|
||||
content: [{ type: "text", text: JSON.stringify(wikiPages, null, 2) }],
|
||||
};
|
||||
@ -3711,8 +3762,8 @@ server.setRequestHandler(CallToolRequestSchema, async request => {
|
||||
}
|
||||
|
||||
case "get_pipeline_job_output": {
|
||||
const { project_id, job_id } = GetPipelineJobOutputSchema.parse(request.params.arguments);
|
||||
const jobOutput = await getPipelineJobOutput(project_id, job_id);
|
||||
const { project_id, job_id, limit, offset } = GetPipelineJobOutputSchema.parse(request.params.arguments);
|
||||
const jobOutput = await getPipelineJobOutput(project_id, job_id, limit, offset);
|
||||
return {
|
||||
content: [
|
||||
{
|
||||
@ -3933,14 +3984,13 @@ server.setRequestHandler(CallToolRequestSchema, async request => {
|
||||
*/
|
||||
async function runServer() {
|
||||
try {
|
||||
console.error("========================");
|
||||
console.error(`GitLab MCP Server v${SERVER_VERSION}`);
|
||||
console.error(`API URL: ${GITLAB_API_URL}`);
|
||||
console.error("========================");
|
||||
if ( !SSE )
|
||||
{
|
||||
// Server startup banner removed - inappropriate use of console.error for logging
|
||||
// Server version banner removed - inappropriate use of console.error for logging
|
||||
// API URL banner removed - inappropriate use of console.error for logging
|
||||
// Server startup banner removed - inappropriate use of console.error for logging
|
||||
if (!SSE) {
|
||||
const transport = new StdioServerTransport();
|
||||
await server.connect(transport);
|
||||
await server.connect(transport);
|
||||
} else {
|
||||
const app = express();
|
||||
const transports: { [sessionId: string]: SSEServerTransport } = {};
|
||||
@ -3952,7 +4002,7 @@ async function runServer() {
|
||||
});
|
||||
await server.connect(transport);
|
||||
});
|
||||
|
||||
|
||||
app.post("/messages", async (req: Request, res: Response) => {
|
||||
const sessionId = req.query.sessionId as string;
|
||||
const transport = transports[sessionId];
|
||||
@ -3962,13 +4012,12 @@ async function runServer() {
|
||||
res.status(400).send("No transport found for sessionId");
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
const PORT = process.env.PORT || 3002;
|
||||
app.listen(PORT, () => {
|
||||
console.log(`Server is running on port ${PORT}`);
|
||||
});
|
||||
}
|
||||
console.error("GitLab MCP Server running on stdio");
|
||||
} catch (error) {
|
||||
console.error("Error initializing server:", error);
|
||||
process.exit(1);
|
||||
|
201
package-lock.json
generated
201
package-lock.json
generated
@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "@zereight/mcp-gitlab",
|
||||
"version": "1.0.56",
|
||||
"version": "1.0.60",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "@zereight/mcp-gitlab",
|
||||
"version": "1.0.56",
|
||||
"version": "1.0.60",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@modelcontextprotocol/sdk": "1.8.0",
|
||||
@ -27,6 +27,7 @@
|
||||
"@types/node": "^22.13.10",
|
||||
"@typescript-eslint/eslint-plugin": "^8.21.0",
|
||||
"@typescript-eslint/parser": "^8.21.0",
|
||||
"auto-changelog": "^2.4.0",
|
||||
"eslint": "^9.18.0",
|
||||
"prettier": "^3.4.2",
|
||||
"ts-node": "^10.9.2",
|
||||
@ -889,6 +890,48 @@
|
||||
"integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/auto-changelog": {
|
||||
"version": "2.5.0",
|
||||
"resolved": "https://registry.npmjs.org/auto-changelog/-/auto-changelog-2.5.0.tgz",
|
||||
"integrity": "sha512-UTnLjT7I9U2U/xkCUH5buDlp8C7g0SGChfib+iDrJkamcj5kaMqNKHNfbKJw1kthJUq8sUo3i3q2S6FzO/l/wA==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"commander": "^7.2.0",
|
||||
"handlebars": "^4.7.7",
|
||||
"import-cwd": "^3.0.0",
|
||||
"node-fetch": "^2.6.1",
|
||||
"parse-github-url": "^1.0.3",
|
||||
"semver": "^7.3.5"
|
||||
},
|
||||
"bin": {
|
||||
"auto-changelog": "src/index.js"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=8.3"
|
||||
}
|
||||
},
|
||||
"node_modules/auto-changelog/node_modules/node-fetch": {
|
||||
"version": "2.7.0",
|
||||
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.7.0.tgz",
|
||||
"integrity": "sha512-c4FRfUm/dbcWZ7U+1Wq0AwCyFL+3nt2bEw05wfxSz+DWpWsitgmSgYmy2dQdWyKC1694ELPqMs/YzUSNozLt8A==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"whatwg-url": "^5.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": "4.x || >=6.0.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"encoding": "^0.1.0"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"encoding": {
|
||||
"optional": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/balanced-match": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz",
|
||||
@ -1036,6 +1079,16 @@
|
||||
"node": ">= 0.8"
|
||||
}
|
||||
},
|
||||
"node_modules/commander": {
|
||||
"version": "7.2.0",
|
||||
"resolved": "https://registry.npmjs.org/commander/-/commander-7.2.0.tgz",
|
||||
"integrity": "sha512-QrWXB+ZQSVPmIWIhtEO9H+gwHaMGYiF5ChvoJ+K9ZGHG/sVsa6yiesAD1GC/x46sET00Xlwo1u49RVVVzvcSkw==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 10"
|
||||
}
|
||||
},
|
||||
"node_modules/concat-map": {
|
||||
"version": "0.0.1",
|
||||
"resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz",
|
||||
@ -1894,6 +1947,28 @@
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/handlebars": {
|
||||
"version": "4.7.8",
|
||||
"resolved": "https://registry.npmjs.org/handlebars/-/handlebars-4.7.8.tgz",
|
||||
"integrity": "sha512-vafaFqs8MZkRrSX7sFVUdo3ap/eNiLnb4IakshzvP56X5Nr1iGKAIqdX6tMlm6HcNRIkr6AxO5jFEoJzzpT8aQ==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"minimist": "^1.2.5",
|
||||
"neo-async": "^2.6.2",
|
||||
"source-map": "^0.6.1",
|
||||
"wordwrap": "^1.0.0"
|
||||
},
|
||||
"bin": {
|
||||
"handlebars": "bin/handlebars"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=0.4.7"
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"uglify-js": "^3.1.4"
|
||||
}
|
||||
},
|
||||
"node_modules/has-flag": {
|
||||
"version": "4.0.0",
|
||||
"resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz",
|
||||
@ -2007,6 +2082,19 @@
|
||||
"node": ">= 4"
|
||||
}
|
||||
},
|
||||
"node_modules/import-cwd": {
|
||||
"version": "3.0.0",
|
||||
"resolved": "https://registry.npmjs.org/import-cwd/-/import-cwd-3.0.0.tgz",
|
||||
"integrity": "sha512-4pnzH16plW+hgvRECbDWpQl3cqtvSofHWh44met7ESfZ8UZOWWddm8hEyDTqREJ9RbYHY8gi8DqmaelApoOGMg==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"import-from": "^3.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=8"
|
||||
}
|
||||
},
|
||||
"node_modules/import-fresh": {
|
||||
"version": "3.3.1",
|
||||
"resolved": "https://registry.npmjs.org/import-fresh/-/import-fresh-3.3.1.tgz",
|
||||
@ -2024,6 +2112,29 @@
|
||||
"url": "https://github.com/sponsors/sindresorhus"
|
||||
}
|
||||
},
|
||||
"node_modules/import-from": {
|
||||
"version": "3.0.0",
|
||||
"resolved": "https://registry.npmjs.org/import-from/-/import-from-3.0.0.tgz",
|
||||
"integrity": "sha512-CiuXOFFSzkU5x/CR0+z7T91Iht4CXgfCxVOFRhh2Zyhg5wOpWvvDLQUsWl+gcN+QscYBjez8hDCt85O7RLDttQ==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"resolve-from": "^5.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=8"
|
||||
}
|
||||
},
|
||||
"node_modules/import-from/node_modules/resolve-from": {
|
||||
"version": "5.0.0",
|
||||
"resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-5.0.0.tgz",
|
||||
"integrity": "sha512-qYg9KP24dD5qka9J47d0aVky0N+b4fTU89LN9iDnjB5waksiC49rvMB0PrUJQGoTmH50XPiqOvAjDfaijGxYZw==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=8"
|
||||
}
|
||||
},
|
||||
"node_modules/imurmurhash": {
|
||||
"version": "0.1.4",
|
||||
"resolved": "https://registry.npmjs.org/imurmurhash/-/imurmurhash-0.1.4.tgz",
|
||||
@ -2292,6 +2403,16 @@
|
||||
"url": "https://github.com/sponsors/isaacs"
|
||||
}
|
||||
},
|
||||
"node_modules/minimist": {
|
||||
"version": "1.2.8",
|
||||
"resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.8.tgz",
|
||||
"integrity": "sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/ljharb"
|
||||
}
|
||||
},
|
||||
"node_modules/ms": {
|
||||
"version": "2.1.3",
|
||||
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz",
|
||||
@ -2314,6 +2435,13 @@
|
||||
"node": ">= 0.6"
|
||||
}
|
||||
},
|
||||
"node_modules/neo-async": {
|
||||
"version": "2.6.2",
|
||||
"resolved": "https://registry.npmjs.org/neo-async/-/neo-async-2.6.2.tgz",
|
||||
"integrity": "sha512-Yd3UES5mWCSqR+qNT93S3UoYUkqAZ9lLg8a7g9rimsWmYGK8cVToA4/sF3RrshdyV3sAGMXVUmpMYOw+dLpOuw==",
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/node-domexception": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/node-domexception/-/node-domexception-1.0.0.tgz",
|
||||
@ -2456,6 +2584,19 @@
|
||||
"node": ">=6"
|
||||
}
|
||||
},
|
||||
"node_modules/parse-github-url": {
|
||||
"version": "1.0.3",
|
||||
"resolved": "https://registry.npmjs.org/parse-github-url/-/parse-github-url-1.0.3.tgz",
|
||||
"integrity": "sha512-tfalY5/4SqGaV/GIGzWyHnFjlpTPTNpENR9Ea2lLldSJ8EWXMsvacWucqY3m3I4YPtas15IxTLQVQ5NSYXPrww==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"bin": {
|
||||
"parse-github-url": "cli.js"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.10"
|
||||
}
|
||||
},
|
||||
"node_modules/parseurl": {
|
||||
"version": "1.3.3",
|
||||
"resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz",
|
||||
@ -2898,6 +3039,16 @@
|
||||
"node": ">= 14"
|
||||
}
|
||||
},
|
||||
"node_modules/source-map": {
|
||||
"version": "0.6.1",
|
||||
"resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz",
|
||||
"integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==",
|
||||
"dev": true,
|
||||
"license": "BSD-3-Clause",
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
}
|
||||
},
|
||||
"node_modules/sprintf-js": {
|
||||
"version": "1.1.3",
|
||||
"resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.1.3.tgz",
|
||||
@ -2961,6 +3112,13 @@
|
||||
"node": ">=0.6"
|
||||
}
|
||||
},
|
||||
"node_modules/tr46": {
|
||||
"version": "0.0.3",
|
||||
"resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz",
|
||||
"integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==",
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/ts-api-utils": {
|
||||
"version": "2.1.0",
|
||||
"resolved": "https://registry.npmjs.org/ts-api-utils/-/ts-api-utils-2.1.0.tgz",
|
||||
@ -3059,6 +3217,20 @@
|
||||
"node": ">=14.17"
|
||||
}
|
||||
},
|
||||
"node_modules/uglify-js": {
|
||||
"version": "3.19.3",
|
||||
"resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.19.3.tgz",
|
||||
"integrity": "sha512-v3Xu+yuwBXisp6QYTcH4UbH+xYJXqnq2m/LtQVWKWzYc1iehYnLixoQDN9FH6/j9/oybfd6W9Ghwkl8+UMKTKQ==",
|
||||
"dev": true,
|
||||
"license": "BSD-2-Clause",
|
||||
"optional": true,
|
||||
"bin": {
|
||||
"uglifyjs": "bin/uglifyjs"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=0.8.0"
|
||||
}
|
||||
},
|
||||
"node_modules/undici-types": {
|
||||
"version": "6.20.0",
|
||||
"resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.20.0.tgz",
|
||||
@ -3109,6 +3281,24 @@
|
||||
"node": ">= 8"
|
||||
}
|
||||
},
|
||||
"node_modules/webidl-conversions": {
|
||||
"version": "3.0.1",
|
||||
"resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz",
|
||||
"integrity": "sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==",
|
||||
"dev": true,
|
||||
"license": "BSD-2-Clause"
|
||||
},
|
||||
"node_modules/whatwg-url": {
|
||||
"version": "5.0.0",
|
||||
"resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz",
|
||||
"integrity": "sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"tr46": "~0.0.3",
|
||||
"webidl-conversions": "^3.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/which": {
|
||||
"version": "2.0.2",
|
||||
"resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz",
|
||||
@ -3134,6 +3324,13 @@
|
||||
"node": ">=0.10.0"
|
||||
}
|
||||
},
|
||||
"node_modules/wordwrap": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-1.0.0.tgz",
|
||||
"integrity": "sha512-gvVzJFlPycKc5dZN4yPkP8w7Dc37BtP1yczEneOb4uq34pXZcvrtRTmWV8W+Ume+XCxKgbjM+nevkyFPMybd4Q==",
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/wrappy": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz",
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@zereight/mcp-gitlab",
|
||||
"version": "1.0.57",
|
||||
"version": "1.0.63",
|
||||
"description": "MCP server for using the GitLab API",
|
||||
"license": "MIT",
|
||||
"author": "zereight",
|
||||
@ -21,6 +21,7 @@
|
||||
"watch": "tsc --watch",
|
||||
"deploy": "npm publish --access public",
|
||||
"generate-tools": "npx ts-node scripts/generate-tools-readme.ts",
|
||||
"changelog": "auto-changelog -p",
|
||||
"test": "node test/validate-api.js",
|
||||
"test:integration": "node test/validate-api.js",
|
||||
"lint": "eslint . --ext .ts",
|
||||
@ -48,6 +49,7 @@
|
||||
"prettier": "^3.4.2",
|
||||
"ts-node": "^10.9.2",
|
||||
"typescript": "^5.8.2",
|
||||
"zod": "^3.24.2"
|
||||
"zod": "^3.24.2",
|
||||
"auto-changelog": "^2.4.0"
|
||||
}
|
||||
}
|
||||
|
16
schemas.ts
16
schemas.ts
@ -191,6 +191,8 @@ export const CancelPipelineSchema = z.object({
|
||||
export const GetPipelineJobOutputSchema = z.object({
|
||||
project_id: z.string().describe("Project ID or URL-encoded path"),
|
||||
job_id: z.number().describe("The ID of the job"),
|
||||
limit: z.number().optional().describe("Maximum number of lines to return from the end of the log (default: 1000)"),
|
||||
offset: z.number().optional().describe("Number of lines to skip from the end of the log (default: 0)"),
|
||||
});
|
||||
|
||||
// User schemas
|
||||
@ -212,7 +214,7 @@ export const GitLabUsersResponseSchema = z.record(
|
||||
id: z.number(),
|
||||
username: z.string(),
|
||||
name: z.string(),
|
||||
avatar_url: z.string(),
|
||||
avatar_url: z.string().nullable(),
|
||||
web_url: z.string(),
|
||||
}).nullable()
|
||||
);
|
||||
@ -253,7 +255,7 @@ export const GitLabNamespaceExistsResponseSchema = z.object({
|
||||
export const GitLabOwnerSchema = z.object({
|
||||
username: z.string(), // Changed from login to match GitLab API
|
||||
id: z.number(),
|
||||
avatar_url: z.string(),
|
||||
avatar_url: z.string().nullable(),
|
||||
web_url: z.string(), // Changed from html_url to match GitLab API
|
||||
name: z.string(), // Added as GitLab includes full name
|
||||
state: z.string(), // Added as GitLab includes user state
|
||||
@ -467,6 +469,8 @@ export const CreateMergeRequestOptionsSchema = z.object({
|
||||
labels: z.array(z.string()).optional(),
|
||||
allow_collaboration: z.boolean().optional(), // Changed from maintainer_can_modify to match GitLab API
|
||||
draft: z.boolean().optional(),
|
||||
remove_source_branch: z.boolean().optional().describe("Flag indicating if a merge request should remove the source branch when merging."),
|
||||
squash: z.boolean().optional().describe("If true, squash all commits into a single commit on merge.")
|
||||
});
|
||||
|
||||
export const GitLabDiffSchema = z.object({
|
||||
@ -593,7 +597,7 @@ export const GitLabForkParentSchema = z.object({
|
||||
.object({
|
||||
username: z.string(), // Changed from login to match GitLab API
|
||||
id: z.number(),
|
||||
avatar_url: z.string(),
|
||||
avatar_url: z.string().nullable(),
|
||||
})
|
||||
.optional(), // Made optional to handle cases where GitLab API doesn't include it
|
||||
web_url: z.string(), // Changed from html_url to match GitLab API
|
||||
@ -916,7 +920,7 @@ export const CreateNoteSchema = z.object({
|
||||
export const ListIssuesSchema = z.object({
|
||||
project_id: z.string().describe("Project ID or URL-encoded path"),
|
||||
assignee_id: z.number().optional().describe("Return issues assigned to the given user ID"),
|
||||
assignee_username: z.string().optional().describe("Return issues assigned to the given username"),
|
||||
assignee_username: z.array(z.string()).optional().describe("Return issues assigned to the given username"),
|
||||
author_id: z.number().optional().describe("Return issues created by the given user ID"),
|
||||
author_username: z.string().optional().describe("Return issues created by the given username"),
|
||||
confidential: z.boolean().optional().describe("Filter confidential or public issues"),
|
||||
@ -1197,7 +1201,9 @@ export const ListGroupProjectsSchema = z.object({
|
||||
// Add wiki operation schemas
|
||||
export const ListWikiPagesSchema = z.object({
|
||||
project_id: z.string().describe("Project ID or URL-encoded path"),
|
||||
with_content: z.boolean().optional().describe("Include content of the wiki pages"),
|
||||
}).merge(PaginationOptionsSchema);
|
||||
|
||||
export const GetWikiPageSchema = z.object({
|
||||
project_id: z.string().describe("Project ID or URL-encoded path"),
|
||||
slug: z.string().describe("URL-encoded slug of the wiki page"),
|
||||
@ -1226,7 +1232,7 @@ export const GitLabWikiPageSchema = z.object({
|
||||
title: z.string(),
|
||||
slug: z.string(),
|
||||
format: z.string(),
|
||||
content: z.string(),
|
||||
content: z.string().optional(),
|
||||
created_at: z.string().optional(),
|
||||
updated_at: z.string().optional(),
|
||||
});
|
||||
|
38
scripts/create-github-release.sh
Executable file
38
scripts/create-github-release.sh
Executable file
@ -0,0 +1,38 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
# Extract version from package.json
|
||||
VERSION=$(jq -r .version package.json)
|
||||
|
||||
if [ -z "$VERSION" ]; then
|
||||
echo "Could not read version from package.json."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Check if release notes file exists
|
||||
if [ ! -f RELEASE_NOTES.md ]; then
|
||||
echo "RELEASE_NOTES.md file does not exist."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Generate RELEASE_NOTES.md from CHANGELOG.md for the current version
|
||||
node <<'EOF'
|
||||
const fs = require('fs');
|
||||
const changelog = fs.readFileSync('CHANGELOG.md', 'utf8');
|
||||
const pkg = JSON.parse(fs.readFileSync('package.json', 'utf8'));
|
||||
const version = pkg.version;
|
||||
|
||||
const regex = new RegExp(`## \\[${version.replace(/\./g, '\\.')}\\][\\s\\S]*?(?=\\n## |\\n?$)`, 'g');
|
||||
const match = changelog.match(regex);
|
||||
|
||||
if (match && match[0]) {
|
||||
fs.writeFileSync('RELEASE_NOTES.md', match[0].trim() + '\n');
|
||||
console.log('RELEASE_NOTES.md generated for version', version);
|
||||
} else {
|
||||
console.error('No changelog entry found for version', version);
|
||||
process.exit(1);
|
||||
}
|
||||
EOF
|
||||
|
||||
# Create GitHub release using CLI
|
||||
gh release create "$VERSION" -t "Release $VERSION" -F RELEASE_NOTES.md
|
Reference in New Issue
Block a user