chore(CI): Remove unused workflow files

This commit is contained in:
MrGadget 2024-04-14 08:53:32 -04:00
parent bb8c4cd975
commit be29b59672
3 changed files with 0 additions and 233 deletions

View File

@ -1,74 +0,0 @@
using System;
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
// Modify PreprocessorDefine.cs
string path = "Assets/Mirror/CompilerSymbols/PreprocessorDefine.cs";
string text = File.ReadAllText(path);
// Find the whole line of the first define ending with "MIRROR_n_OR_NEWER,"
string pattern = @"\s+\""(MIRROR_(\d+)_OR_NEWER)\""\,\n";
Match match = Regex.Matches(text, pattern).First();
// Remove the first define
text = text.Replace(match.Value, "");
// Find the highest version number entry, not having a comma at the end
pattern = @"\""(MIRROR_(\d+)_OR_NEWER)\""\n";
MatchCollection matches = Regex.Matches(text, pattern);
int maxVersion = matches.Max(m => int.Parse(m.Groups[2].Value));
// Find the last define ending with "MIRROR_n_OR_NEWER"
pattern = @"(\s+)\""(MIRROR_(\d+)_OR_NEWER)\""";
matches = Regex.Matches(text, pattern);
Match lastMatch = matches.Last();
// Add a new define for the next full version, used here and in ProjectSettings and version.txt
string newDefine = $"MIRROR_{maxVersion + 1}_OR_NEWER";
// Add the new define to the end of the hashset entries, with a comma after the previous entry and properly indented
text = text.Insert(lastMatch.Index + lastMatch.Length, $",\n{match.Groups[1].Value}\"{newDefine}\"");
File.WriteAllText(path, text);
// Modify ProjectSettings.asset
path = "ProjectSettings/ProjectSettings.asset";
text = File.ReadAllText(path);
// Define a regular expression pattern for finding the sections
pattern = @"(Server|Standalone|WebGL):(.+?)(?=(Server|Standalone|WebGL)|$)";
MatchCollection sectionMatches = Regex.Matches(text, pattern, RegexOptions.Singleline);
if (sectionMatches.Count > 0)
{
foreach (Match sectionMatch in sectionMatches)
{
string sectionName = sectionMatch.Groups[1].Value.Trim();
string sectionContent = sectionMatch.Groups[2].Value.Trim();
// Now, you can work with sectionName and sectionContent
// to locate and update the defines within each section.
// For example, you can use Regex to modify defines within sectionContent.
// For simplicity, let's assume you want to add the newDefine to the end of each section.
pattern = @"(MIRROR_(\d+)_OR_NEWER);";
MatchCollection defineMatches = Regex.Matches(sectionContent, pattern);
if (defineMatches.Count > 0)
{
Match lastDefineMatch = defineMatches[defineMatches.Count - 1];
int lastIndex = lastDefineMatch.Index + lastDefineMatch.Length;
sectionContent = sectionContent.Insert(lastIndex, $";{newDefine}");
}
// Replace the section in the original text with the modified section content
text = text.Remove(sectionMatch.Index, sectionMatch.Length);
text = text.Insert(sectionMatch.Index, $"{sectionName}:{sectionContent}");
}
}
File.WriteAllText(path, text);
// Update version.txt with newDefine, e.g. MIRROR_84_OR_NEWER, replacing _ with .
File.WriteAllText("Assets/Mirror/version.txt", newDefine.Replace("_", "."));

View File

@ -1,113 +0,0 @@
using System;
using System.IO;
using System.Text.RegularExpressions;
Console.WriteLine("ModPreprocessorDefine Started");
// Console.Out.Flush();
ModPreprocessorDefine.DoSomething();
Console.WriteLine("ModPreprocessorDefine Finished");
// Console.Out.Flush();
class ModPreprocessorDefine
{
public static void DoSomething()
{
// Define the path to the PreprocessorDefine.cs file
string filePath = "Assets/Mirror/CompilerSymbols/PreprocessorDefine.cs";
// Read the contents of the file
string fileContents = File.ReadAllText(filePath);
Console.WriteLine("ModPreprocessorDefine File read");
// Console.Out.Flush();
// Find and remove the first entry ending with "_OR_NEWER"
fileContents = RemoveFirstOrNewerEntry(fileContents);
Console.WriteLine("ModPreprocessorDefine Old entry removed");
// Console.Out.Flush();
// Find the last entry and capture the version number
string versionNumber = GetLastVersionNumber(fileContents);
Console.WriteLine($"ModPreprocessorDefine current version {versionNumber}");
// Console.Out.Flush();
// Append a new entry with the correct indentation and next version number
fileContents = AppendNewEntry(fileContents, versionNumber);
Console.WriteLine("ModPreprocessorDefine New entry appended");
// Console.Out.Flush();
// Write the modified contents back to the file
File.WriteAllText(filePath, fileContents);
}
static string RemoveFirstOrNewerEntry(string input)
{
// Regex pattern to match the first entry ending with "_OR_NEWER"
string pattern = @"^\s*""[^""]*_OR_NEWER""\s*,\s*$";
// Find the first match
Match match = Regex.Match(input, pattern, RegexOptions.Multiline);
// If a match is found, remove the entire line
if (match.Success)
{
input = input.Remove(match.Index, match.Length);
}
return input;
}
static string GetLastVersionNumber(string input)
{
// Regex pattern to match the last entry and capture the version number
string pattern = @"^\s*""([^""]*)_OR_NEWER""\s*,\s*$";
// Find all matches
MatchCollection matches = Regex.Matches(input, pattern, RegexOptions.Multiline);
// Capture the version number from the last match
string versionNumber = matches.Count > 0 ? matches[matches.Count - 1].Groups[1].Value : "";
return versionNumber;
}
static string AppendNewEntry(string input, string versionNumber)
{
// Calculate the next version number (increment by 1)
int nextVersion = int.TryParse(versionNumber, out int currentVersion) ? currentVersion + 1 : 1;
// Get the indentation of the "HashSet<string> defines = new HashSet<string>" line
string indentation = GetHashSetIndentation(input);
// Create the new entry with the correct indentation and next version number
string newEntry = indentation + $" \"MIRROR_{nextVersion}_OR_NEWER\"";
Console.WriteLine($"New entry: {newEntry}");
// Find the position of the "defines" HashSet and insert the new entry into it
int definesStartIndex = input.IndexOf("HashSet<string> defines = new HashSet<string>");
int definesEndIndex = input.IndexOf("};", definesStartIndex) + 1;
// Insert the comma and new entry into the "defines" HashSet
input = input.Remove(definesEndIndex - 2, 2); // Remove the trailing "};"
input = input.Insert(definesEndIndex - 2, $",\n{newEntry}\n{indentation}}};");
Console.WriteLine(input);
return input;
}
static string GetHashSetIndentation(string input)
{
// Regex pattern to match the indentation of "HashSet<string> defines = new HashSet<string>"
string pattern = @"^\s*HashSet<string> defines = new HashSet<string>";
// Find the first match
Match match = Regex.Match(input, pattern, RegexOptions.Multiline);
// If a match is found, capture the indentation and add 4 spaces
string indentation = match.Success ? Regex.Match(match.Value, @"^\s*").Value : "";
return indentation;
}
}

View File

@ -1,46 +0,0 @@
name: Create Release
on:
workflow_dispatch:
jobs:
CreateRelease:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Merge Master into AssetStoreRelease
uses: devmasx/merge-branch@master
with:
type: now
from_branch: master
target_branch: AssetStoreRelease
message: "Merged master"
github_token: ${{ secrets.GITHUB_TOKEN }}
- name: Checkout AssetStoreRelease
run: |
git checkout -b AssetStoreRelease
git pull origin AssetStoreRelease
- name: Set up .NET Core
uses: actions/setup-dotnet@v3
- name: Install dotnet-script
run: |
dotnet tool install -g dotnet-script
dotnet script --version
- name: Run ModPreprocessorDefine.csx
run: dotnet script .github/ModPreprocessorDefine.csx
- name: Commit and Push
run: |
git config user.name ${{ secrets.COMMITTER_NAME }}
git config user.email ${{ secrets.COMMITTER_EMAIL }}
git commit -m "release!: Asset Store Release" -a
git push origin AssetStoreRelease
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}