Skip to content

Commit

Permalink
Fix publish action issues
Browse files Browse the repository at this point in the history
  • Loading branch information
visose committed Dec 6, 2021
1 parent f4e1883 commit 2480c0b
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 17 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ jobs:
- uses: actions/setup-dotnet@v1
with:
dotnet-version: '6.0.x'
- run: /home/runner/.dotnet/dotnet build "build/Robots.Build/Robots.Build.csproj"
- run: sudo /home/runner/.dotnet/dotnet run --no-build --project "build/Robots.Build/Robots.Build.csproj" test build package publish release
- run: dotnet run --project "build/Robots.Build/Robots.Build.csproj" test build package publish release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
YAK_TOKEN: ${{ secrets.YAK_TOKEN }}
16 changes: 10 additions & 6 deletions build/Robots.Build/Commands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,22 +89,26 @@ public static async Task<int> ReleaseAsync()

static async Task<string> GetYakPathAsync()
{
const string yak = "Yak.exe";
const string yak = "Yak.exe";
const string rhino = "C:/Program Files/Rhino 7/System/Yak.exe";

if (File.Exists(rhino))
return rhino;
return rhino;

if (File.Exists(yak))
return Path.GetFullPath(yak);
string yakPath = Path.GetFullPath(yak);

if (File.Exists(yakPath))
return yakPath;

var http = new HttpClient();
var response = await http.GetAsync($"http://files.mcneel.com/yak/tools/latest/yak.exe");
response.EnsureSuccessStatusCode();
await using var ms = await response.Content.ReadAsStreamAsync();
await using var fs = File.Create(yak);
await using var fs = File.Create(yakPath);
ms.Seek(0, SeekOrigin.Begin);
ms.CopyTo(fs);
return Path.GetFullPath(yak);
Run("chmod", $"+x {yakPath}");

return yakPath;
}
}
19 changes: 10 additions & 9 deletions build/Robots.Build/Util.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,31 +16,32 @@ public static void Log(string? text)

public static int Run(string file, string args, string? setCurrentDir = null)
{
var currentDir = Directory.GetCurrentDirectory();

if (setCurrentDir is not null)
Directory.SetCurrentDirectory(setCurrentDir);
var currentDir = setCurrentDir ?? Directory.GetCurrentDirectory();

var startInfo = new ProcessStartInfo(file, args)
{
CreateNoWindow = true,
FileName = file,
Arguments = args,
WorkingDirectory = currentDir,
RedirectStandardInput = true,
RedirectStandardOutput = true,
RedirectStandardError = true
RedirectStandardError = true,
UseShellExecute = false,
CreateNoWindow = true
};

using var process = new Process
{
StartInfo = startInfo
};

process.OutputDataReceived += (o, e) => Log(e.Data);
process.ErrorDataReceived += (o, e) => Log(e.Data);
process.Start();
process.Start();
process.BeginErrorReadLine();
process.BeginOutputReadLine();
process.WaitForExit();

Directory.SetCurrentDirectory(currentDir);
return process.ExitCode;
}

Expand Down

0 comments on commit 2480c0b

Please sign in to comment.