git icon indicating copy to clipboard operation
git copied to clipboard

Why ".gitignore" is ignored ?

Open merlosy opened this issue 4 years ago • 6 comments

Hi! I'd like to understand the motivation for adding files that are ignored to the next commit.

For example, my project build outputs code into a dist folder. This should be published as part of the artifact on the registry. But I don't want to find those dist files in the code (pollution IMO).

It seems like a common use case. Am I the only one troubled by this?

Thanks,

merlosy avatar Apr 07 '22 20:04 merlosy

https://github.com/semantic-release/git/pull/56 has the history of why this was done in this way

travi avatar Apr 07 '22 20:04 travi

Thanks for the link!

It was not very intuitive to explicitly define the assets, but I get it. I'll be able to test it soon on my side

merlosy avatar Apr 12 '22 15:04 merlosy

:( I don't get it, I looked at the link, and could not see why, just that it was going to be done

I am building a package to go in the github registry

If I don't include the dist folder in the .releaserc assets, they don't go into the package If I do, then they go into the package AND committed into the repo

As they are committed, they are pulled down by the developer and when they build locally the files become a change.

The assets for the package are built files and should be in the package but not committed - how do I do that?

  • also as a side note there is a loader directory, which I have not added to assets, but is added to the package but not committed

MrAntix avatar Aug 11 '22 17:08 MrAntix

I am building a package to go in the github registry

it sounds like your problem is likely unrelated to this issue. you may not even need this git plugin at all. the github registry works the same as other npm registries, so you just need to inform npm which files to include through files in package.json or through a .npmignore (we recommend the files option, specifically because it is an allow-list rather than a deny list).

travi avatar Aug 11 '22 19:08 travi

thanks for the reply

I needed to look at the ~~github~~ npm plugin and this one

just for anyone else who ends up here, this gets me what I wanted

.releaserc

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

@semantic-release/npm

creates and publishes packages - to npm or github depending on your registry settings, assets from the package.json > files setting e.g.

package.json

{
  "files": [
    "dist/",
    "loader/"
  ],
}

@semantic-release/git

commits changes from the build that are in the assets setting in .releaserc (see above)

@semantic-release/github

creates GitHub Releases - not packages

MrAntix avatar Aug 12 '22 09:08 MrAntix