TheAngryByrd / MiniScaffold

F# Template for creating and publishing libraries targeting .NET 6.0 `net6.0` or console apps .NET 6.0 `net6.0`.
https://www.jimmybyrd.me/MiniScaffold/
MIT License
267 stars 31 forks source link

Limit files staged by Git during a release #187

Closed ominestre closed 4 years ago

ominestre commented 4 years ago

Describe the bug The current build script uses Git StageAll during a release. If someone has a dirty working directory this could add unintended files to a release.

Expected behavior Explicitly declare which files should be staged during a release.

ominestre commented 4 years ago

@TheAngryByrd looking at the history it looks like the only thing that needs staged is the generated HTML files. Is there any AssemblyInfo or anything else I should account for?

rmunn commented 4 years ago

@ominestre There are some generated AssemblyInfo files, which get put in different places depending on whether it's an F# or C# project. IIRC, F# AssemblyInfo.fs files get put into src/ProjectName/ and tests/ProjectName.Tests/, while C# AssemblyInfo.fs get put into src/ProjectName/Properties/ and tests/ProjectName.Tests/Properties. But I'm not 100% sure of that; you can look at the "GenerateAssemblyInfo" target in the build script to double-check my recollection.

TheAngryByrd commented 4 years ago

@ominestre The HTML files are staged and committed separately during the ReleaseDocs target so no need to worry about the docsDir.

halcwb commented 4 years ago

Just my 2 cents. I use a different approach when commit files to git, an opt-in approach. So in my .gitignore I start with explicitly excluding everything and then I handpick which files/dirs can be included. So, it looks like this:

# Ignore all files using an opt-inn approach
*

# Add .gitignore and .gitattributes
!.gitignore
!.gitattributes

# Add license
!LICENSE.txt

# Add todo list
!ToDo.txt

# Add md files
!*.md

# Add fsx files
!*.fsx

# ignore release command
release.cmd
publishnuget.cmd

# Add proc file
!Procfile

# Add local tools config
!/.config/
!/.config/*.json

# Add paket bootstrapper
!/.paket/
!/.paket/paket.bootstrapper.exe

# Add dependencies file
!paket.dependencies
!paket.lock
!paket.references
!paket.template

# Add yml files to ci on appveyor and travis
!appveyor.yml
!.travis.yml

# Add solution file
!*.sln

# Add fsharp project files
!*.fsproj

# Etc...

This way I prevent accidentally adding sensitive or unnecessary files. The downside is that it happens that I forget to include files. But then this will immediately show up on the CI builds.

ominestre commented 4 years ago

I like the idea of whitelisting files to avoid a SNAFU. We'd still have a problem if someone had a dirty working directory with a whitelisted file and they ran the release script. The change I'm looking to make is to replace the stageAll with a more explicit glob for just the assembly data.