github icon indicating copy to clipboard operation
github copied to clipboard

publish `dist` directory as `Source code (zip)` asset instead of root

Open gpspake opened this issue 3 years ago • 3 comments
trafficstars

My project's build outputs assets to a dist directory. This is what I publish to NPM and it's what I'd like to publish to github.

Here's my config:

module.exports = {
    "plugins": [
        "@semantic-release/commit-analyzer",
        "@semantic-release/release-notes-generator",
        "@semantic-release/changelog",
        ["@semantic-release/npm", {
            "pkgRoot": "dist",
        }],
        "@semantic-release/github",
        "@semantic-release/git"
    ],
    "preset": "angular"
}

This works (mostly). The package is published to NPM and Github but the package that's published to Github as Source code (zip|tar.gz) is the project root, not the dist directory.

Here's an example: https://github.com/gpspake/npm-demo-shared-dependency/releases/tag/v1.1.4

@semantic-release/npm has a pkgRoot option that can be used to specify which directory to publish

["@semantic-release/npm", {
    "pkgRoot": "dist",
}],

I figured the assets option would work the same way so tried setting it to dist and dist/** but that just publishes the flat files (in addition to the compressed source from the root directory)

["@semantic-release/github", {
    "assets": "dist/**"
}],

Is there a "pkgRoot" equivalent for @semantic-release/github or an implicit way to specify that? Or am I missing some obvious reason I wouldn't need it? 🙂

gpspake avatar Jan 21 '22 03:01 gpspake

Here are a couple of SO threads about this: https://stackoverflow.com/q/69841763/1827642 https://stackoverflow.com/q/69872861/1827642

gpspake avatar Jan 21 '22 03:01 gpspake

In my case, I'd like to supress generation of the source zip and tarball entirely. That's what my git tags are for. But per this comment, they're apparently added by github not semantic-release and cannot be disabled: https://github.com/semantic-release/semantic-release/issues/1597#issuecomment-656370768

github uses git export though, so you can use .gitattributes to suppress exporting. See https://stackoverflow.com/a/58443948/398670

ringerc avatar Jul 18 '22 06:07 ringerc

@gpspake Looks like you can't do it; it's autogenerated by github.

ringerc avatar Jul 18 '22 06:07 ringerc