Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions scripts/release-canary.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,13 @@ import { execSync } from 'child_process'
// token, because releasePublish wants a token that has the id_token: write permission
// so that we can use OIDC for trusted publishing

const gh_token_bak = process.env.GITHUB_TOKEN
process.env.GITHUB_TOKEN = process.env.RELEASE_GITHUB_TOKEN

// backup original auth header
const originalAuth = execSync('git config --local http.https://github.com/.extraheader')
.toString()
.trim()
// switch the token used
const authHeader = `AUTHORIZATION: basic ${Buffer.from(`x-access-token:${process.env.RELEASE_GITHUB_TOKEN}`).toString('base64')}`
execSync(`git config --local http.https://github.com/.extraheader "${authHeader}"`)
await releaseChangelog({
versionData: projectsVersionData,
version: workspaceVersion,
Expand All @@ -36,7 +40,8 @@ import { execSync } from 'child_process'
})

// npm publish with OIDC
process.env.GITHUB_TOKEN = gh_token_bak
// not strictly necessary to restore the header but do it incase we require it later
execSync(`git config --local http.https://github.com/.extraheader "${originalAuth}"`)
const publishResult = await releasePublish({
registry: 'https://registry.npmjs.org/',
access: 'public',
Expand Down
13 changes: 10 additions & 3 deletions scripts/release-stable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,13 @@ if (!validSpecifiers.includes(versionSpecifier) && !isValidVersion) {
// token, because releasePublish wants a token that has the id_token: write permission
// so that we can use OIDC for trusted publishing

const gh_token_bak = process.env.GITHUB_TOKEN
process.env.GITHUB_TOKEN = process.env.RELEASE_GITHUB_TOKEN
// backup original auth header
const originalAuth = execSync('git config --local http.https://github.com/.extraheader')
.toString()
.trim()
// switch the token used
const authHeader = `AUTHORIZATION: basic ${Buffer.from(`x-access-token:${process.env.RELEASE_GITHUB_TOKEN}`).toString('base64')}`
execSync(`git config --local http.https://github.com/.extraheader "${authHeader}"`)

const result = await releaseChangelog({
versionData: projectsVersionData,
Expand All @@ -74,7 +79,9 @@ if (!validSpecifiers.includes(versionSpecifier) && !isValidVersion) {
})

// npm publish with OIDC
process.env.GITHUB_TOKEN = gh_token_bak
// not strictly necessary to restore the header but do it incase we require it later
execSync(`git config --local http.https://github.com/.extraheader "${originalAuth}"`)

const publishResult = await releasePublish({
registry: 'https://registry.npmjs.org/',
access: 'public',
Expand Down