语义发布不断将 dist 和文档提交到 repo,尽管 .gitignore

问题描述 投票:0回答:1

我使用

semantic-release
来构建和发布 NPM 包。构建过程会创建一个
dist\
docs\
目录,该目录被正确设置为在
.gitignore
中被忽略。构建阶段完成后,我将使用
upload-artifact
github 操作将它们传递到
release
阶段。在
release
阶段,我只是检索工件并运行
npx semantic-release
来发布包。

这一切都很好,包已正确发布,并且包含我期望的所有文件。但是,

semantic-release
dist\
docs\
提交到存储库中,尽管它们位于
.gitignore
中。我确信这只是我缺少的一个配置步骤。有什么想法吗?

semantic-release
配置(在
package.json
中):

"release": {
    "branches": [
        {
            "name": "main"
        },
        {
            "name": "develop",
            "channel": "beta",
            "prerelease": "beta"
        }
    ],
    "plugins": [
        "@semantic-release/commit-analyzer",
        "@semantic-release/release-notes-generator",
        [
            "@semantic-release/changelog",
            {
                "changelogFile": "CHANGELOG.md"
            }
        ],
        "@semantic-release/npm",
        "@semantic-release/github",
        [
            "@semantic-release/git",
            {
                "assets": [
                    "CHANGELOG.md",
                    "dist/**",
                    "docs/**"
                ],
                "message": "chore(release): set `package.json` to ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}"
            }
        ]
    ]
},

这是

semantic-release-bot
提交
dist\
docs\
返回存储库的屏幕截图(以及预期的变更日志)

相关部分

.gitignore

## docs
/docs/

# build
/_site/
/dist/
/out-tsc/
node.js git github-actions semantic-release
1个回答
0
投票

更新你的文件(我的意思是它的.releaserc.js)到

"release": {
    "branches": [
        {
            "name": "main"
        },
        {
            "name": "develop",
            "channel": "beta",
            "prerelease": "beta"
        }
    ],
    "plugins": [
        "@semantic-release/commit-analyzer",
        "@semantic-release/release-notes-generator",
        [
            "@semantic-release/changelog",
            {
                "changelogFile": "CHANGELOG.md"
            }
        ],
        "@semantic-release/npm",
        "@semantic-release/github",
        [
            "@semantic-release/git",
            {
                assets: ['CHANGELOG.md', 'package.json', 'package-lock.json'],
                "message": "chore(release): set `package.json` to ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}"
            }
        ]
    ]
},

(更新“@semantic-release/git”.assets) 当你将

"dist/**", "docs/**"
放入“@semantic-release/git”时。资产语义发布将它们添加到提交

您可以在此处查看使用打字稿部署语义发布的示例

https://github.com/JS-AK/example-automatic-deploy-ts-app-to-npm-with-scope

© www.soinside.com 2019 - 2024. All rights reserved.