Skip to content

Commit a61e25d

Browse files
authored
fix(ci): fix wrong file paths (#146)
* fix(ci): fix wrong file paths * chore: set cwd for git commands
1 parent 1fa88dc commit a61e25d

File tree

2 files changed

+31
-9
lines changed

2 files changed

+31
-9
lines changed

scripts/release/common.ts

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,22 @@ export const MAIN_BRANCH = config.mainBranch;
88
export const OWNER = config.owner;
99
export const REPO = config.repo;
1010

11-
type Run = (
11+
export type Run = (
1212
command: string,
13-
options?: Partial<{
14-
errorMessage: string;
15-
}>
13+
options?: Partial<
14+
execa.SyncOptions & {
15+
errorMessage: string;
16+
}
17+
>
1618
) => execa.ExecaReturnBase<string>['stdout'];
1719

18-
export const run: Run = (command, { errorMessage = undefined } = {}) => {
20+
export const run: Run = (
21+
command,
22+
{ errorMessage = undefined, ...execaOptions } = {}
23+
) => {
1924
let result: execa.ExecaSyncReturnValue<string>;
2025
try {
21-
result = execa.commandSync(command);
26+
result = execa.commandSync(command, execaOptions);
2227
} catch (err) {
2328
if (errorMessage) {
2429
throw new Error(`[ERROR] ${errorMessage}`);

scripts/release/process-release.ts

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,30 @@
11
/* eslint-disable no-console */
22
import fs from 'fs';
3+
import path from 'path';
34

45
import dotenv from 'dotenv';
56
import execa from 'execa';
67

78
import openapitools from '../../openapitools.json';
89

9-
import { MAIN_BRANCH, OWNER, REPO, run, getMarkdownSection } from './common';
10+
import type { Run } from './common';
11+
import {
12+
MAIN_BRANCH,
13+
OWNER,
14+
REPO,
15+
run as runOriginal,
16+
getMarkdownSection,
17+
} from './common';
1018
import TEXT from './text';
1119

20+
// This script is run by `yarn workspace ...`, which means the current working directory is `./script`
21+
const ROOT_DIR = path.resolve(process.cwd(), '..');
22+
1223
dotenv.config();
1324

25+
const run: Run = (command, options = {}) =>
26+
runOriginal(command, { cwd: ROOT_DIR, ...options });
27+
1428
if (!process.env.GITHUB_TOKEN) {
1529
throw new Error('Environment variable `GITHUB_TOKEN` does not exist.');
1630
}
@@ -70,12 +84,15 @@ Object.keys(openapitools['generator-cli'].generators).forEach((client) => {
7084
].additionalProperties.packageVersion = versionsToRelease[lang].next;
7185
}
7286
});
73-
fs.writeFileSync('openapitools.json', JSON.stringify(openapitools, null, 2));
87+
fs.writeFileSync(
88+
path.resolve(ROOT_DIR, 'openapitools.json'),
89+
JSON.stringify(openapitools, null, 2)
90+
);
7491

7592
// update changelogs
7693
new Set([...Object.keys(versionsToRelease), ...langsToUpdateRepo]).forEach(
7794
(lang) => {
78-
const filePath = `doc/changelogs/${lang}.md`;
95+
const filePath = path.resolve(ROOT_DIR, `doc/changelogs/${lang}.md`);
7996
const header = versionsToRelease[lang!]
8097
? `## ${versionsToRelease[lang!].next}`
8198
: `## ${new Date().toISOString().split('T')[0]}`;

0 commit comments

Comments
 (0)