diff --git a/.github/CreateRelease.cs b/.github/CreateRelease.cs index 567a57a8c..2d5b734d8 100644 --- a/.github/CreateRelease.cs +++ b/.github/CreateRelease.cs @@ -8,27 +8,27 @@ 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)\""\,\r\n"; +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)\""\r\n"; +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)\"""; -MatchCollection matches = Regex.Matches(text, pattern); +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, $",\r\n{match.Groups[1].Value}\"{newDefine}\""); +text = text.Insert(lastMatch.Index + lastMatch.Length, $",\n{match.Groups[1].Value}\"{newDefine}\""); File.WriteAllText(path, text); diff --git a/.github/workflows/CreateRelease.yml b/.github/workflows/CreateRelease.yml index ca3b85c6c..a31c0e652 100644 --- a/.github/workflows/CreateRelease.yml +++ b/.github/workflows/CreateRelease.yml @@ -14,17 +14,20 @@ jobs: - name: Merge master into AssetStoreRelease run: | - git config --local user.name ${{ secrets.COMMITTER_NAME }} - git config --local user.email ${{ secrets.COMMITTER_EMAIL }} git fetch origin master --depth 1 - git rebase origin/master + git reset --hard origin/master env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Set up .NET Core uses: actions/setup-dotnet@v1 - with: - dotnet-version: 3.1.301 + #with: + # dotnet-version: 3.1.301 + + - name: Install dotnet-script + run: | + dotnet tool install -g dotnet-script + dotnet script --version - name: Run CreateRelease.cs run: | @@ -32,8 +35,18 @@ jobs: - name: Commit and Push run: | - git config --local user.email "action@github.com" - git config --local user.name "GitHub Action" + git config --local user.name ${{ secrets.COMMITTER_NAME }} + git config --local user.email ${{ secrets.COMMITTER_EMAIL }} git add Assets/Mirror/version.txt git commit -m "release!: Asset Store Release" -a + + # Configure Git to rebase when pulling + git config --local pull.rebase true + + # Perform a git pull to update the local branch with remote changes + git pull origin AssetStoreRelease + + # Push the updated branch to the remote git push origin AssetStoreRelease + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}