* Run an async function with BUMPY_GH_TOKEN as GH_TOKEN if available. * * GitHub releases created with the default GITHUB_TOKEN won't trigger * downstream workflows. Using BUMPY_GH_TOKEN (a PAT or App token) * allows `release` events to fire follow-up workflows. * * Any errors are scrubbed so
(fn: () => Promise<T>)
| 19 | * Any errors are scrubbed so the token never appears in CI logs. |
| 20 | */ |
| 21 | async function withReleaseToken<T>(fn: () => Promise<T>): Promise<T> { |
| 22 | const token = process.env.BUMPY_GH_TOKEN; |
| 23 | if (!token) return fn(); |
| 24 | const original = process.env.GH_TOKEN; |
| 25 | process.env.GH_TOKEN = token; |
| 26 | try { |
| 27 | return await fn(); |
| 28 | } catch (err) { |
| 29 | // Redact token from error messages to prevent leakage in CI logs |
| 30 | const msg = err instanceof Error ? err.message : String(err); |
| 31 | throw new Error(msg.replaceAll(token, '***')); |
| 32 | } finally { |
| 33 | if (original !== undefined) { |
| 34 | process.env.GH_TOKEN = original; |
| 35 | } else { |
| 36 | delete process.env.GH_TOKEN; |
| 37 | } |
| 38 | } |
| 39 | } |
| 40 | |
| 41 | export interface GitHubReleaseOptions { |
| 42 | dryRun?: boolean; |
no outgoing calls
no test coverage detected
searching dependent graphs…