首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >语义发布在GitHub身份验证中失败:插件“@semantic-semantic/github”的失败步骤“Failed”

语义发布在GitHub身份验证中失败:插件“@semantic-semantic/github”的失败步骤“Failed”
EN

Stack Overflow用户
提问于 2022-04-16 18:51:43
回答 1查看 1.2K关注 0票数 1

我正在尝试将semantic-release集成到我的Node /CD工作流中。我试过遵循文档和教程,但我显然遗漏了一些东西。测试步骤通过,但是发布步骤在“运行npx语义发布”时失败。

这是我使用的YML脚本:

代码语言:javascript
复制
name: Test and Release CI/CD

on:
  push:
    branches: [ main ]
  pull_request:
    branches: [ main ]

jobs:
  test:

    runs-on: ${{ matrix.os }}

    strategy:
      matrix:
        node-version: [16.x]
        os: [ubuntu-latest]

    steps:
    - uses: actions/checkout@v3
    - name: Use Node.js ${{ matrix.node-version }}
      uses: actions/setup-node@v3
      with:
        node-version: ${{ matrix.node-version }}
        cache: 'npm'
    - run: npm ci
    - run: npm test

  publish:
    runs-on: ubuntu-latest
    needs: [test]
    steps:
    - uses: actions/checkout@v3
    - name: Use Node.js 16.x
      uses: actions/setup-node@v3
      with:
        node-version: "16.x"
    - run: npm ci
    - run: npx semantic-release
      env:
        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

以下是来自Github操作的错误:

代码语言:javascript
复制
Run npx semantic-release
[5:46:35 PM] [semantic-release] › ℹ  Running semantic-release version 19.0.2
[5:46:35 PM] [semantic-release] › ✔  Loaded plugin "verifyConditions" from "@semantic-release/npm"
[5:46:35 PM] [semantic-release] › ✔  Loaded plugin "verifyConditions" from "@semantic-release/github"
[5:46:35 PM] [semantic-release] › ✔  Loaded plugin "analyzeCommits" from "@semantic-release/commit-analyzer"
[5:46:35 PM] [semantic-release] › ✔  Loaded plugin "generateNotes" from "@semantic-release/release-notes-generator"
[5:46:35 PM] [semantic-release] › ✔  Loaded plugin "prepare" from "@semantic-release/npm"
[5:46:35 PM] [semantic-release] › ✔  Loaded plugin "publish" from "@semantic-release/npm"
[5:46:35 PM] [semantic-release] › ✔  Loaded plugin "publish" from "@semantic-release/github"
[5:46:35 PM] [semantic-release] › ✔  Loaded plugin "addChannel" from "@semantic-release/npm"
[5:46:35 PM] [semantic-release] › ✔  Loaded plugin "addChannel" from "@semantic-release/github"
[5:46:35 PM] [semantic-release] › ✔  Loaded plugin "success" from "@semantic-release/github"
[5:46:35 PM] [semantic-release] › ✔  Loaded plugin "fail" from "@semantic-release/github"
[5:46:36 PM] [semantic-release] › ℹ  Start step "fail" of plugin "@semantic-release/github"
[5:46:36 PM] [semantic-release] [@semantic-release/github] › ℹ  Verify GitHub authentication (https://api.github.com)
[5:46:36 PM] [semantic-release] › ✖  Failed step "fail" of plugin "@semantic-release/github"
[5:46:36 PM] [semantic-release] › ✖  An error occurred while running semantic-release: TypeError: Cannot read properties of undefined (reading 'name')
    at module.exports (/home/runner/work/Alphanumeric-Encoder/Alphanumeric-Encoder/node_modules/@semantic-release/github/lib/get-fail-comment.js:19:10)
    at module.exports (/home/runner/work/Alphanumeric-Encoder/Alphanumeric-Encoder/node_modules/@semantic-release/github/lib/fail.js:28:74)
    at async fail (/home/runner/work/Alphanumeric-Encoder/Alphanumeric-Encoder/node_modules/@semantic-release/github/index.js:64:3)
    at async validator (/home/runner/work/Alphanumeric-Encoder/Alphanumeric-Encoder/node_modules/semantic-release/lib/plugins/normalize.js:34:24)
    at async /home/runner/work/Alphanumeric-Encoder/Alphanumeric-Encoder/node_modules/semantic-release/lib/plugins/pipeline.js:37:34
    at async /home/runner/work/Alphanumeric-Encoder/Alphanumeric-Encoder/node_modules/semantic-release/lib/plugins/pipeline.js:31:3
    at async Object.pluginsConf.<computed> [as fail] (/home/runner/work/Alphanumeric-Encoder/Alphanumeric-Encoder/node_modules/semantic-release/lib/plugins/index.js:80:11)
    at async callFail (/home/runner/work/Alphanumeric-Encoder/Alphanumeric-Encoder/node_modules/semantic-release/index.js:243:7)
    at async module.exports (/home/runner/work/Alphanumeric-Encoder/Alphanumeric-Encoder/node_modules/semantic-release/index.js:272:7)
    at async module.exports (/home/runner/work/Alphanumeric-Encoder/Alphanumeric-Encoder/node_modules/semantic-release/cli.js:55:5) {
  pluginName: '@semantic-release/github'
}
[5:46:36 PM] [semantic-release] › ✖  ERELEASEBRANCHES The release branches are invalid in the `branches` configuration.
A minimum of 1 and a maximum of 3 release branches are required in the branches configuration (https://github.com/semantic-release/semantic-release/blob/master/docs/usage/configuration.md#branches).

This may occur if your repository does not have a release branch, such as master.

Your configuration for the problematic branches is [].

AggregateError: 
    SemanticReleaseError: The release branches are invalid in the `branches` configuration.
        at module.exports (/home/runner/work/Alphanumeric-Encoder/Alphanumeric-Encoder/node_modules/semantic-release/lib/get-error.js:6:10)
        at /home/runner/work/Alphanumeric-Encoder/Alphanumeric-Encoder/node_modules/semantic-release/lib/branches/index.js:44:19
        at Array.reduce (<anonymous>)
        at module.exports (/home/runner/work/Alphanumeric-Encoder/Alphanumeric-Encoder/node_modules/semantic-release/lib/branches/index.js:34:46)
        at processTicksAndRejections (node:internal/process/task_queues:96:5)
        at async run (/home/runner/work/Alphanumeric-Encoder/Alphanumeric-Encoder/node_modules/semantic-release/index.js:65:22)
        at async module.exports (/home/runner/work/Alphanumeric-Encoder/Alphanumeric-Encoder/node_modules/semantic-release/index.js:268:22)
        at async module.exports (/home/runner/work/Alphanumeric-Encoder/Alphanumeric-Encoder/node_modules/semantic-release/cli.js:55:5)
    at module.exports (/home/runner/work/Alphanumeric-Encoder/Alphanumeric-Encoder/node_modules/semantic-release/lib/branches/index.js:66:11)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async run (/home/runner/work/Alphanumeric-Encoder/Alphanumeric-Encoder/node_modules/semantic-release/index.js:65:22)
    at async module.exports (/home/runner/work/Alphanumeric-Encoder/Alphanumeric-Encoder/node_modules/semantic-release/index.js:268:22)
    at async module.exports (/home/runner/work/Alphanumeric-Encoder/Alphanumeric-Encoder/node_modules/semantic-release/cli.js:55:5)
Error: Process completed with exit code 1.

在其他故障排除过程中,我成功地使用了这个项目中的NPM_TOKEN,所以我知道这不是问题所在。我相信问题可能与GitHub身份验证令牌有关,但对于我的生活,我感到困惑。我不知道我做错了什么。如何纠正此错误?

编辑相关:semantic release - TypeError: Cannot read property 'name' of undefined

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2022-04-19 20:27:21

默认配置假设分支master,所以如果使用main,就会得到ERELEASEBRANCHES错误。

您可以尝试使用该分支设置.releaserc.js文件(或package.json中的release属性)。

代码语言:javascript
复制
"branches": ["main", "next"]

配置的文档位于https://semantic-release.gitbook.io/semantic-release/usage/configuration

有一个PR添加main作为后备默认分支,但它还没有合并。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/71896623

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档