@itcase/config 1.7.9 → 1.7.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@itcase/config",
3
- "version": "1.7.9",
3
+ "version": "1.7.10",
4
4
  "author": "ITCase",
5
5
  "description": "ITCase Config",
6
6
  "engines": {
@@ -17,8 +17,10 @@ const releaseNotesFromIssuesScript = join(
17
17
  'releaseNotesFromIssues.js',
18
18
  )
19
19
 
20
- // Ссылки на задачи из PR. Репозиторий задач и токен приходят из CI:
21
- // RELEASE_NOTES_ISSUES_REPO, RELEASE_NOTES_GH_TOKEN.
20
+ // Ссылки на задачи из PR.
21
+ // Pull request'ы текущего репозитория читает GITHUB_TOKEN.
22
+ // Задачи другого репозитория читает RELEASE_NOTES_GH_TOKEN.
23
+ // RELEASE_NOTES_ISSUES_REPO — репозиторий задач.
22
24
  const releaseNotesFromIssuesPlugin = [
23
25
  '@semantic-release/exec',
24
26
  {
@@ -14,8 +14,11 @@ import { join } from 'node:path'
14
14
  */
15
15
  const [lastTagArg, nextTagArg] = process.argv.slice(2)
16
16
 
17
- // Token is passed from GitHub Actions env and used for all API calls
18
- const githubToken = process.env.RELEASE_NOTES_GH_TOKEN
17
+ // Pull requests of this repository. In GitHub Actions this is the workflow token.
18
+ const repositoryToken = process.env.GITHUB_TOKEN || process.env.GH_TOKEN
19
+
20
+ // Issues live in another repository. The workflow token cannot read them.
21
+ const issuesToken = process.env.RELEASE_NOTES_GH_TOKEN
19
22
 
20
23
  const currentProjectOwner = process.env.GITHUB_REPOSITORY?.split('/')[0]
21
24
  const currentProjectRepo = process.env.GITHUB_REPOSITORY?.split('/')[1]
@@ -27,8 +30,12 @@ const releaseNotesIssuesRepo = process.env.RELEASE_NOTES_ISSUES_REPO
27
30
  const issuesProjectOwner = releaseNotesIssuesRepo?.split('/')[0]
28
31
  const issuesProjectRepo = releaseNotesIssuesRepo?.split('/')[1]
29
32
 
30
- if (!currentProjectOwner || !currentProjectRepo || !githubToken) {
31
- throw new Error('Missing "GITHUB_REPOSITORY" or "RELEASE_NOTES_GH_TOKEN"')
33
+ if (!currentProjectOwner || !currentProjectRepo || !repositoryToken) {
34
+ throw new Error('Missing "GITHUB_REPOSITORY" or "GITHUB_TOKEN"')
35
+ }
36
+
37
+ if (!issuesToken) {
38
+ throw new Error('Missing "RELEASE_NOTES_GH_TOKEN"')
32
39
  }
33
40
 
34
41
  if (!issuesProjectOwner || !issuesProjectRepo) {
@@ -269,7 +276,7 @@ async function run() {
269
276
  }
270
277
 
271
278
  // Small helper for GitHub REST API with common headers and query serialization.
272
- async function fetchGithubApi(pathname, queryParams = {}) {
279
+ async function fetchGithubApi(pathname, token, queryParams = {}) {
273
280
  const apiUrl = new URL(`https://api.github.com${pathname}`)
274
281
 
275
282
  for (const [key, value] of Object.entries(queryParams)) {
@@ -282,7 +289,7 @@ async function fetchGithubApi(pathname, queryParams = {}) {
282
289
  const response = await fetch(apiUrl, {
283
290
  headers: {
284
291
  Accept: 'application/vnd.github+json',
285
- Authorization: `Bearer ${githubToken}`,
292
+ Authorization: `Bearer ${token}`,
286
293
  'User-Agent': 'semantic-release-issues-notes',
287
294
  // GitHub REST API version header
288
295
  'X-GitHub-Api-Version': '2026-03-10',
@@ -428,6 +435,7 @@ async function getAssociatedPullRequestsForCommit(commitSha) {
428
435
  // Works for both merge-commit and regular commits associated with PRs.
429
436
  const response = await fetchGithubApi(
430
437
  `/repos/${currentProjectOwner}/${currentProjectRepo}/commits/${commitSha}/pulls`,
438
+ repositoryToken,
431
439
  )
432
440
  return Array.isArray(response) ? response : []
433
441
  }
@@ -449,7 +457,7 @@ async function loadIssue(ref) {
449
457
  const [issueOwner, issueRepo] = repoRef.split('/')
450
458
  const issuePath = `/repos/${issueOwner}/${issueRepo}/issues/${issueNumber}`
451
459
  try {
452
- return await fetchGithubApi(issuePath)
460
+ return await fetchGithubApi(issuePath, issuesToken)
453
461
  } catch (error) {
454
462
  throw new Error(
455
463
  `Failed to load issue for ref="${ref}" using path="${issuePath}"`,