brandedoutcast / publish-nuget

📦 GitHub action to automate publishing NuGet packages when project version changes
https://github.com/marketplace/actions/publish-nuget
MIT License
197 stars 101 forks source link

not finding version number change on windows #2

Closed cuzzlor closed 4 years ago

cuzzlor commented 4 years ago

I love the idea behind looking for the change to the <version></version> attribute, publishing and tagging based on this, however, I can't reliably get it to work.

I wonder if you can help by looking at my repo and config. The process correctly finds my project file but fails to recognise the version change.

https://github.com/cuzzlor/password-check/commit/d8a509d62c28514444bc853062844148308886f7/checks?check_suite_id=362514686

It reports: no version change in PasswordCheck.csproj

If I run git diff -U0 HEAD^ I see:

diff --git a/src/PasswordCheck/PasswordCheck.csproj b/src/PasswordCheck/PasswordCheck.csproj
index 9deb62f..fc555a4 100644
--- a/src/PasswordCheck/PasswordCheck.csproj
+++ b/src/PasswordCheck/PasswordCheck.csproj
@@ -13 +13 @@
-    <Version>1.0.2</Version>
+    <Version>1.0.3</Version>

this looks right!

Any idea what I am missing?

Thanks!

cuzzlor commented 4 years ago

One thing just occurred to me trying to work out why this worked a couple of times then stopped working. I changed to run on windows-latest so I could target net461, I bet that is why.

Here is one that worked early on: https://github.com/cuzzlor/password-check/commit/a1374662f7b22ebad94cdbc451a3cdeafc1e9d30/checks?check_suite_id=361776879

Vs not working on Windows: https://github.com/cuzzlor/password-check/commit/d8a509d62c28514444bc853062844148308886f7/checks?check_suite_id=362514686

Might be worth adding some debug code and running (on windows) to see if it's the git diff with path or the regex test that isn't working the same way..

cuzzlor commented 4 years ago

I have done some debugging (on windows) and have found that running git diff via execSync always returns an empty string:

gitDiff = execSync(git diff -U0 HEAD^ -- ${projPath}, { encoding: "utf-8" }),

I can't work out why, because running the same git diff command outside of execSync works perfectly.

Some strange windows quirk. I tried changing lots of the execSync options such as cwd, shell etc and nothing seems to make a difference. It's not encoding, if I use the buffer returning overload the buffer is empty.

brandedoutcast commented 4 years ago

Hey @cuzzlor that's a ton of digging you've done on this & I truly appreciate the effort

I haven't really tested it out on windows-latest as my target has always been .NET Core with ubuntu-latest but let me take a look

execSync wasn't really playing well on windows so replaced with with spawnSync & it now works cross platform, no changes required on your side just re-run the workflow

cuzzlor commented 4 years ago

Thanks @rohith much appreciated. I have PR'd a fix for the command command also not being available on windows. When I researched a cross platform method to check if a command exists it seems surprisingly hard, therefore I just went for an easy truth check against the dotnet --version command.