File tree Expand file tree Collapse file tree 6 files changed +53
-44
lines changed Expand file tree Collapse file tree 6 files changed +53
-44
lines changed Original file line number Diff line number Diff line change 1
1
/* eslint-disable no-console */
2
- import { ensureGitHubToken , MAIN_BRANCH , run } from '../../common' ;
3
- import { configureGitHubAuthor } from '../../release/common' ;
2
+ import {
3
+ configureGitHubAuthor ,
4
+ ensureGitHubToken ,
5
+ MAIN_BRANCH ,
6
+ run ,
7
+ } from '../../common' ;
4
8
import { getNbGitDiff } from '../utils' ;
5
9
6
10
import text , { commitStartPrepareRelease } from './text' ;
Original file line number Diff line number Diff line change @@ -9,15 +9,12 @@ import {
9
9
toAbsolutePath ,
10
10
REPO_URL ,
11
11
ensureGitHubToken ,
12
+ configureGitHubAuthor ,
12
13
} from '../../common' ;
13
14
import { getLanguageFolder , getPackageVersionDefault } from '../../config' ;
14
- import {
15
- cloneRepository ,
16
- configureGitHubAuthor ,
17
- RELEASED_TAG ,
18
- } from '../../release/common' ;
15
+ import { RELEASED_TAG } from '../../release/common' ;
19
16
import type { Language } from '../../types' ;
20
- import { getNbGitDiff } from '../utils' ;
17
+ import { cloneRepository , getNbGitDiff } from '../utils' ;
21
18
22
19
import text , { commitStartRelease } from './text' ;
23
20
@@ -106,7 +103,7 @@ async function spreadGeneration(): Promise<void> {
106
103
await run ( `git push --delete origin ${ RELEASED_TAG } ` ) ;
107
104
108
105
console . log ( 'Creating new `released` tag for latest commit' ) ;
109
- await run ( ' git tag released' ) ;
106
+ await run ( ` git tag ${ RELEASED_TAG } ` ) ;
110
107
await run ( 'git push --tags' ) ;
111
108
}
112
109
@@ -154,6 +151,7 @@ async function spreadGeneration(): Promise<void> {
154
151
`Processing release commit, creating new release tag ('${ version } ') for '${ lang } ' repository.`
155
152
) ;
156
153
154
+ await run ( `git tag -d ${ version } ` , { cwd : tempGitDir } ) ;
157
155
await run ( `git tag ${ version } HEAD` , { cwd : tempGitDir } ) ;
158
156
await run ( 'git push --tags' , { cwd : tempGitDir } ) ;
159
157
}
Original file line number Diff line number Diff line change
1
+ import fsp from 'fs/promises' ;
2
+ import { resolve } from 'path' ;
3
+
1
4
import { run } from '../common' ;
5
+ import { getGitHubUrl } from '../config' ;
6
+ import { getTargetBranch } from '../release/common' ;
7
+ import type { Language } from '../types' ;
2
8
3
9
/**
4
10
* Returns the number of diff between a `branch` and its `HEAD` for the given `path`.
@@ -32,3 +38,26 @@ export async function getNbGitDiff({
32
38
10
33
39
) ;
34
40
}
41
+
42
+ export async function cloneRepository ( {
43
+ lang,
44
+ githubToken,
45
+ tempDir,
46
+ } : {
47
+ lang : Language ;
48
+ githubToken : string ;
49
+ tempDir : string ;
50
+ } ) : Promise < { tempGitDir : string } > {
51
+ const targetBranch = getTargetBranch ( lang ) ;
52
+
53
+ const gitHubUrl = getGitHubUrl ( lang , { token : githubToken } ) ;
54
+ const tempGitDir = resolve ( tempDir , lang ) ;
55
+ await fsp . rm ( tempGitDir , { force : true , recursive : true } ) ;
56
+ await run (
57
+ `git clone --depth 1 --branch ${ targetBranch } ${ gitHubUrl } ${ tempGitDir } `
58
+ ) ;
59
+
60
+ return {
61
+ tempGitDir,
62
+ } ;
63
+ }
Original file line number Diff line number Diff line change @@ -9,6 +9,7 @@ import { remove } from 'fs-extra';
9
9
import openapiConfig from '../config/openapitools.json' ;
10
10
import releaseConfig from '../config/release.config.json' ;
11
11
12
+ import { getGitAuthor } from './release/common' ;
12
13
import { createSpinner } from './spinners' ;
13
14
import type {
14
15
CheckForCache ,
@@ -286,6 +287,13 @@ export function capitalize(str: string): string {
286
287
return str . charAt ( 0 ) . toUpperCase ( ) + str . slice ( 1 ) ;
287
288
}
288
289
290
+ export async function configureGitHubAuthor ( cwd ?: string ) : Promise < void > {
291
+ const { name, email } = getGitAuthor ( ) ;
292
+
293
+ await run ( `git config user.name "${ name } "` , { cwd } ) ;
294
+ await run ( `git config user.email "${ email } "` , { cwd } ) ;
295
+ }
296
+
289
297
let verbose = false ;
290
298
export function setVerbose ( v : boolean ) : void {
291
299
verbose = v ;
Original file line number Diff line number Diff line change 1
1
import fsp from 'fs/promises' ;
2
- import path from 'path' ;
3
2
4
3
import config from '../../config/release.config.json' ;
5
- import { run } from '../common' ;
6
- import { getGitHubUrl } from '../config' ;
7
- import type { Language } from '../types' ;
8
4
9
5
export const RELEASED_TAG = config . releasedTag ;
10
6
export const TEAM_SLUG = config . teamSlug ;
@@ -17,36 +13,6 @@ export function getGitAuthor(): { name: string; email: string } {
17
13
return config . gitAuthor ;
18
14
}
19
15
20
- export async function configureGitHubAuthor ( cwd ?: string ) : Promise < void > {
21
- const { name, email } = getGitAuthor ( ) ;
22
-
23
- await run ( `git config user.name "${ name } "` , { cwd } ) ;
24
- await run ( `git config user.email "${ email } "` , { cwd } ) ;
25
- }
26
-
27
- export async function cloneRepository ( {
28
- lang,
29
- githubToken,
30
- tempDir,
31
- } : {
32
- lang : Language ;
33
- githubToken : string ;
34
- tempDir : string ;
35
- } ) : Promise < { tempGitDir : string } > {
36
- const targetBranch = getTargetBranch ( lang ) ;
37
-
38
- const gitHubUrl = getGitHubUrl ( lang , { token : githubToken } ) ;
39
- const tempGitDir = path . resolve ( tempDir , lang ) ;
40
- await fsp . rm ( tempGitDir , { force : true , recursive : true } ) ;
41
- await run (
42
- `git clone --depth 1 --branch ${ targetBranch } ${ gitHubUrl } ${ tempGitDir } `
43
- ) ;
44
-
45
- return {
46
- tempGitDir,
47
- } ;
48
- }
49
-
50
16
/**
51
17
* Reads a JSON file and returns its parsed data.
52
18
*
Original file line number Diff line number Diff line change @@ -18,10 +18,11 @@ import {
18
18
CI ,
19
19
gitBranchExists ,
20
20
setVerbose ,
21
+ configureGitHubAuthor ,
21
22
} from '../common' ;
22
23
import { getPackageVersionDefault } from '../config' ;
23
24
24
- import { configureGitHubAuthor , RELEASED_TAG } from './common' ;
25
+ import { RELEASED_TAG } from './common' ;
25
26
import TEXT from './text' ;
26
27
import type {
27
28
Versions ,
@@ -459,6 +460,9 @@ async function createReleasePR(): Promise<void> {
459
460
await run ( `CI=false git commit -m "${ commitMessage } "` ) ;
460
461
}
461
462
463
+ // cleanup all the changes to the generated files (the ones not commited because of the pre-commit hook)
464
+ await run ( `git checkout .` ) ;
465
+
462
466
await run ( `git push origin ${ headBranch } ` ) ;
463
467
await run ( `git checkout ${ MAIN_BRANCH } ` ) ;
464
468
You can’t perform that action at this time.
0 commit comments