File tree Expand file tree Collapse file tree 2 files changed +19
-7
lines changed Expand file tree Collapse file tree 2 files changed +19
-7
lines changed Original file line number Diff line number Diff line change @@ -24,9 +24,13 @@ import { execSync } from 'child_process'
24
24
// token, because releasePublish wants a token that has the id_token: write permission
25
25
// so that we can use OIDC for trusted publishing
26
26
27
- const gh_token_bak = process . env . GITHUB_TOKEN
28
- process . env . GITHUB_TOKEN = process . env . RELEASE_GITHUB_TOKEN
29
-
27
+ // backup original auth header
28
+ const originalAuth = execSync ( 'git config --local http.https://github.com/.extraheader' )
29
+ . toString ( )
30
+ . trim ( )
31
+ // switch the token used
32
+ const authHeader = `AUTHORIZATION: basic ${ Buffer . from ( `x-access-token:${ process . env . RELEASE_GITHUB_TOKEN } ` ) . toString ( 'base64' ) } `
33
+ execSync ( `git config --local http.https://github.com/.extraheader "${ authHeader } "` )
30
34
await releaseChangelog ( {
31
35
versionData : projectsVersionData ,
32
36
version : workspaceVersion ,
@@ -36,7 +40,8 @@ import { execSync } from 'child_process'
36
40
} )
37
41
38
42
// npm publish with OIDC
39
- process . env . GITHUB_TOKEN = gh_token_bak
43
+ // not strictly necessary to restore the header but do it incase we require it later
44
+ execSync ( `git config --local http.https://github.com/.extraheader "${ originalAuth } "` )
40
45
const publishResult = await releasePublish ( {
41
46
registry : 'https://registry.npmjs.org/' ,
42
47
access : 'public' ,
Original file line number Diff line number Diff line change @@ -62,8 +62,13 @@ if (!validSpecifiers.includes(versionSpecifier) && !isValidVersion) {
62
62
// token, because releasePublish wants a token that has the id_token: write permission
63
63
// so that we can use OIDC for trusted publishing
64
64
65
- const gh_token_bak = process . env . GITHUB_TOKEN
66
- process . env . GITHUB_TOKEN = process . env . RELEASE_GITHUB_TOKEN
65
+ // backup original auth header
66
+ const originalAuth = execSync ( 'git config --local http.https://github.com/.extraheader' )
67
+ . toString ( )
68
+ . trim ( )
69
+ // switch the token used
70
+ const authHeader = `AUTHORIZATION: basic ${ Buffer . from ( `x-access-token:${ process . env . RELEASE_GITHUB_TOKEN } ` ) . toString ( 'base64' ) } `
71
+ execSync ( `git config --local http.https://github.com/.extraheader "${ authHeader } "` )
67
72
68
73
const result = await releaseChangelog ( {
69
74
versionData : projectsVersionData ,
@@ -74,7 +79,9 @@ if (!validSpecifiers.includes(versionSpecifier) && !isValidVersion) {
74
79
} )
75
80
76
81
// npm publish with OIDC
77
- process . env . GITHUB_TOKEN = gh_token_bak
82
+ // not strictly necessary to restore the header but do it incase we require it later
83
+ execSync ( `git config --local http.https://github.com/.extraheader "${ originalAuth } "` )
84
+
78
85
const publishResult = await releasePublish ( {
79
86
registry : 'https://registry.npmjs.org/' ,
80
87
access : 'public' ,
You can’t perform that action at this time.
0 commit comments