Skip to content

Commit c6de94f

Browse files
authored
Merge pull request #6 from GlebChili/Prepare-version-2-release
Prepare version 2 release
2 parents a19f3e4 + 5408928 commit c6de94f

File tree

17 files changed

+530
-140
lines changed

17 files changed

+530
-140
lines changed

.github/workflows/CI.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,11 @@ jobs:
5050
dotnet nuget update source gmodnet-packages --username CI --password ${{ secrets.AZURE_DEVOPS_ARTIFACTS_PAT }} --store-password-in-clear-text
5151
dotnet nuget push nupkgs/GmodNET.VersionTool.*.nupkg --source gmodnet-packages --skip-duplicate --api-key az
5252
dotnet nuget push nupkgs/GmodNET.VersionTool.Core.*.nupkg --source gmodnet-packages --skip-duplicate --api-key az
53-
dotnet nuget push nupkgs/GmodNET.VersionTool.Target.*.nupkg --source gmodnet-packages --skip-duplicate --api-key az
5453
dotnet nuget push nupkgs/GmodNET.VersionTool.MSBuild.*.nupkg --source gmodnet-packages --skip-duplicate --api-key az
5554
5655
- name: Push NuGets to NuGet.org
5756
if: github.event_name == 'release' && github.event.action == 'published' && github.repository_owner == 'GmodNET'
5857
run: |
5958
dotnet nuget push nupkgs/GmodNET.VersionTool.*.nupkg --source nuget --skip-duplicate --api-key ${{ secrets.NUGET_API_KEY }}
6059
dotnet nuget push nupkgs/GmodNET.VersionTool.Core.*.nupkg --source nuget --skip-duplicate --api-key ${{ secrets.NUGET_API_KEY }}
61-
dotnet nuget push nupkgs/GmodNET.VersionTool.Target.*.nupkg --source nuget --skip-duplicate --api-key ${{ secrets.NUGET_API_KEY }}
6260
dotnet nuget push nupkgs/GmodNET.VersionTool.MSBuild.*.nupkg --source nuget --skip-duplicate --api-key ${{ secrets.NUGET_API_KEY }}

GmodNET.VersionTool.Core.Tests/GmodNET.VersionTool.Core.Tests.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
</PropertyGroup>
88

99
<ItemGroup>
10-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.10.0" />
10+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.11.0-release-20210626-04" />
1111
<PackageReference Include="xunit" Version="2.4.1" />
1212
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
1313
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Text;
4+
using System.IO;
5+
using LibGit2Sharp;
6+
using System.Runtime.CompilerServices;
7+
8+
namespace GmodNET.VersionTool.Core.Tests.Helpers
9+
{
10+
public class TempVersionFileProvider : IDisposable
11+
{
12+
string file_path;
13+
bool was_disposed;
14+
15+
public string FilePath => this.file_path;
16+
17+
public TempVersionFileProvider()
18+
{
19+
file_path = Path.GetTempPath() + Guid.NewGuid().ToString() + ".json";
20+
was_disposed = false;
21+
}
22+
23+
~TempVersionFileProvider()
24+
{
25+
Dispose();
26+
}
27+
28+
public void Dispose()
29+
{
30+
if (!was_disposed)
31+
{
32+
if (File.Exists(file_path))
33+
{
34+
File.Delete(file_path);
35+
}
36+
was_disposed = true;
37+
}
38+
}
39+
}
40+
41+
public class TempRepoProvider : IDisposable
42+
{
43+
bool wasDisposed;
44+
DirectoryInfo repoDirectory;
45+
string version_file_path;
46+
47+
public DirectoryInfo RepoDirectory => repoDirectory;
48+
49+
public string RepoVersionFilePath => version_file_path;
50+
51+
public TempRepoProvider(string version_file_to_copy_into_repo, DateTimeOffset time_of_the_initial_commit, bool make_initial_commit = true)
52+
{
53+
wasDisposed = false;
54+
55+
repoDirectory = Directory.CreateDirectory(Path.GetTempPath() + Guid.NewGuid().ToString());
56+
57+
Repository.Init(repoDirectory.FullName);
58+
59+
version_file_path = Path.Combine(repoDirectory.FullName, version_file_to_copy_into_repo);
60+
61+
File.Copy(version_file_to_copy_into_repo, version_file_path);
62+
63+
using Repository repository = new Repository(repoDirectory.FullName);
64+
65+
if (make_initial_commit)
66+
{
67+
Commands.Stage(repository, "*");
68+
69+
Signature repo_commiter_signature = new Signature("Test runner", "support@gmodnet.xyz", time_of_the_initial_commit);
70+
71+
repository.Commit("Initial commit", repo_commiter_signature, repo_commiter_signature);
72+
}
73+
}
74+
75+
public TempRepoProvider(string version_file_to_copy_into_repo) : this(version_file_to_copy_into_repo, DateTimeOffset.Now, true)
76+
{
77+
78+
}
79+
80+
public void Dispose()
81+
{
82+
if(!wasDisposed)
83+
{
84+
if(repoDirectory.Exists)
85+
{
86+
repoDirectory.SetFilesAttributesToNormal();
87+
repoDirectory.Delete(true);
88+
}
89+
wasDisposed = true;
90+
}
91+
}
92+
93+
~TempRepoProvider()
94+
{
95+
Dispose();
96+
}
97+
}
98+
99+
public static class HelperExtensions
100+
{
101+
public static void SetFilesAttributesToNormal(this DirectoryInfo directory)
102+
{
103+
foreach (FileInfo file in directory.GetFiles())
104+
{
105+
File.SetAttributes(file.FullName, FileAttributes.Normal);
106+
}
107+
108+
foreach (DirectoryInfo subdirectory in directory.GetDirectories())
109+
{
110+
subdirectory.SetFilesAttributesToNormal();
111+
}
112+
}
113+
}
114+
}

0 commit comments

Comments
 (0)