Skip to content

Commit 9de5252

Browse files
committed
+Version 1.1.2
0 parents  commit 9de5252

19 files changed

+1025
-0
lines changed

.icon.png

6.3 KB
Loading

Editor.meta

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"name": "GameWorkstore.Automation.Editor",
3+
"rootNamespace": "",
4+
"references": [
5+
"GUID:381921da55d39454f9a6ce7095941507",
6+
"GUID:c32d36751e998d74999be5c29b033d6e"
7+
],
8+
"includePlatforms": [
9+
"Editor"
10+
],
11+
"excludePlatforms": [],
12+
"allowUnsafeCode": false,
13+
"overrideReferences": false,
14+
"precompiledReferences": [],
15+
"autoReferenced": true,
16+
"defineConstraints": [],
17+
"versionDefines": [],
18+
"noEngineReferences": false
19+
}

Editor/GameWorkstore.Automation.Editor.asmdef.meta

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Editor/VersionWriter.cs

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
#if UNITY_EDITOR
2+
using System.IO;
3+
using UnityEditor;
4+
using UnityEditor.Build;
5+
using UnityEditor.Build.Reporting;
6+
using UnityEditor.Callbacks;
7+
using UnityEngine;
8+
9+
namespace GameWorkstore.Automation
10+
{
11+
public class VersionWriter : IPreprocessBuildWithReport
12+
{
13+
public const string FileName = "GameVersion.cs";
14+
15+
public int callbackOrder => 0;
16+
17+
public void OnPreprocessBuild(BuildReport report)
18+
{
19+
var buildScript = BuildClass.GetBuildScript();
20+
WriteVersion(buildScript);
21+
}
22+
23+
[DidReloadScripts]
24+
public static void WriteVersion()
25+
{
26+
var buildScript = BuildClass.GetBuildScript();
27+
WriteVersion(buildScript);
28+
}
29+
30+
public static void WriteVersion(BuildScript script)
31+
{
32+
if (script == null) return;
33+
if (!script.GameVersionWriterConfig.Enabled) return;
34+
35+
var content =
36+
"namespace " + script.GameVersionWriterConfig.Namespace + "\r\n" +
37+
"{\r\n"+
38+
"\tpublic static class GameVersion\r\n" +
39+
"\t{\r\n" +
40+
"\t"+ FormatVar("IosBundleVersion", PlayerSettings.iOS.buildNumber) + "\r\n" +
41+
"\t" + FormatVar("AndroidBundleVersion", PlayerSettings.Android.bundleVersionCode.ToString()) + "\r\n" +
42+
"\t}\r\n" +
43+
"}";
44+
45+
var directoryPath = GetDirectory(script);
46+
if (!Directory.Exists(directoryPath))
47+
{
48+
Directory.CreateDirectory(directoryPath);
49+
}
50+
51+
var filePath = GetAbsoluteFilePath(script);
52+
53+
var currentText = string.Empty;
54+
if (File.Exists(filePath))
55+
{
56+
currentText = File.ReadAllText(filePath);
57+
}
58+
59+
if (currentText == content) return;
60+
Debug.Log("Updated GameVersion.cs");
61+
62+
File.WriteAllText(filePath, content);
63+
AssetDatabase.Refresh();
64+
AssetDatabase.ImportAsset(GetLocalFilePath(script));
65+
}
66+
67+
private static string FormatVar(string varName, string varValue)
68+
{
69+
return "\tpublic const string " + varName + " = \"" + varValue + "\";";
70+
}
71+
72+
public static string GetAbsoluteFilePath(BuildScript script)
73+
{
74+
return Path.Combine(GetDirectory(script), FileName);
75+
}
76+
77+
public static string GetLocalFilePath(BuildScript script)
78+
{
79+
return Path.Combine("Assets",GetLocalDirectory(script), FileName);
80+
}
81+
82+
public static string GetDirectory(BuildScript script)
83+
{
84+
return Path.Combine(Application.dataPath, GetLocalDirectory(script));
85+
}
86+
87+
public static string GetLocalDirectory(BuildScript script)
88+
{
89+
if (script.GameVersionWriterConfig.Path.StartsWith("/"))
90+
{
91+
return script.GameVersionWriterConfig.Path.Substring(1);
92+
}
93+
return script.GameVersionWriterConfig.Path;
94+
}
95+
}
96+
}
97+
#endif

Editor/VersionWriter.cs.meta

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2020 Game Workstore
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

LICENSE.meta

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# Automation
2+
Automate your projects with this powerful tool with many build options!
3+
4+
# How to install
5+
6+
At package.json, add these 2 lines of code:
7+
```json
8+
"com.gameworkstore.automation": "https://github.com/GameWorkstore/automation.git#1.1.1"
9+
"com.gameworkstore.patterns": "https://github.com/GameWorkstore/patterns.git#1.1.8"
10+
```
11+
12+
And wait for unity to download and compile the package.
13+
14+
you can upgrade your version by including the release version at end of the link:
15+
```json
16+
"com.gameworkstore.automation": "https://github.com/GameWorkstore/automation.git#1.1.1"
17+
"com.gameworkstore.patterns": "https://github.com/GameWorkstore/patterns.git#1.1.8"
18+
```
19+
20+
# Automate Builds
21+
22+
On a windows .bat file, you invoke unity to build your game as the example below:
23+
```bat
24+
set CODEVERSION=23
25+
set VERSION=1.0.%CODEVERSION%
26+
call %UNITYPATH% -executeMethod GameWorkstore.Automation.BuildClass.BuildClass.BuildAndroid -projectPath %WORKSPACE% -gameversion %VERSION% -bundleversion %CODEVERSION%
27+
```
28+
29+
You can also use Jenkins to attribute BUILD_NUMBER to CODEVERSION
30+
```bat
31+
set CODEVERSION=%BUILD_NUMBER%
32+
```
33+
34+
or you can sum with a static number
35+
```bat
36+
set /a "CODEVERSION=%BUILD_NUMBER%+0"
37+
```
38+
39+
# Contributions
40+
41+
If you are using this library and want to submit a change, go ahead! Overall, this project accepts contributions if:
42+
- Is a bug fix;
43+
- Or, is a generalization of a well-known issue;
44+
- Or is performance improvement;
45+
- Or is an improvement to already supported feature.
46+
47+
Also, you can donate to allow us to drink coffee while we improve it for you!

README.md.meta

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)