-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
Added support for change package name based on buildscript
- Loading branch information
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"name": "GameWorkstore.Automation.Editor", | ||
"rootNamespace": "", | ||
"references": [ | ||
"GUID:381921da55d39454f9a6ce7095941507", | ||
"GUID:c32d36751e998d74999be5c29b033d6e" | ||
], | ||
"includePlatforms": [ | ||
"Editor" | ||
], | ||
"excludePlatforms": [], | ||
"allowUnsafeCode": false, | ||
"overrideReferences": false, | ||
"precompiledReferences": [], | ||
"autoReferenced": true, | ||
"defineConstraints": [], | ||
"versionDefines": [], | ||
"noEngineReferences": false | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
#if UNITY_EDITOR | ||
using System.IO; | ||
using UnityEditor; | ||
using UnityEditor.Build; | ||
using UnityEditor.Build.Reporting; | ||
using UnityEditor.Callbacks; | ||
using UnityEngine; | ||
|
||
namespace GameWorkstore.Automation | ||
{ | ||
public class VersionWriter : IPreprocessBuildWithReport | ||
{ | ||
public const string FileName = "GameVersion.cs"; | ||
|
||
public int callbackOrder => 0; | ||
|
||
public void OnPreprocessBuild(BuildReport report) | ||
{ | ||
var buildScript = BuildClass.GetBuildScript(); | ||
WriteVersion(buildScript); | ||
} | ||
|
||
[DidReloadScripts] | ||
public static void WriteVersion() | ||
{ | ||
var buildScript = BuildClass.GetBuildScript(); | ||
WriteVersion(buildScript); | ||
} | ||
|
||
public static void WriteVersion(BuildScript script) | ||
{ | ||
if (script == null) return; | ||
if (!script.GameVersionWriterConfig.Enabled) return; | ||
|
||
var content = | ||
"namespace " + script.GameVersionWriterConfig.Namespace + "\r\n" + | ||
"{\r\n"+ | ||
"\tpublic static class GameVersion\r\n" + | ||
"\t{\r\n" + | ||
"\t"+ FormatVar("IosBundleVersion", PlayerSettings.iOS.buildNumber) + "\r\n" + | ||
"\t" + FormatVar("AndroidBundleVersion", PlayerSettings.Android.bundleVersionCode.ToString()) + "\r\n" + | ||
"\t}\r\n" + | ||
"}"; | ||
|
||
var directoryPath = GetDirectory(script); | ||
if (!Directory.Exists(directoryPath)) | ||
{ | ||
Directory.CreateDirectory(directoryPath); | ||
} | ||
|
||
var filePath = GetAbsoluteFilePath(script); | ||
|
||
var currentText = string.Empty; | ||
if (File.Exists(filePath)) | ||
{ | ||
currentText = File.ReadAllText(filePath); | ||
} | ||
|
||
if (currentText == content) return; | ||
Debug.Log("Updated GameVersion.cs"); | ||
|
||
File.WriteAllText(filePath, content); | ||
AssetDatabase.Refresh(); | ||
AssetDatabase.ImportAsset(GetLocalFilePath(script)); | ||
} | ||
|
||
private static string FormatVar(string varName, string varValue) | ||
{ | ||
return "\tpublic const string " + varName + " = \"" + varValue + "\";"; | ||
} | ||
|
||
public static string GetAbsoluteFilePath(BuildScript script) | ||
{ | ||
return Path.Combine(GetDirectory(script), FileName); | ||
} | ||
|
||
public static string GetLocalFilePath(BuildScript script) | ||
{ | ||
return Path.Combine("Assets",GetLocalDirectory(script), FileName); | ||
} | ||
|
||
public static string GetDirectory(BuildScript script) | ||
{ | ||
return Path.Combine(Application.dataPath, GetLocalDirectory(script)); | ||
} | ||
|
||
public static string GetLocalDirectory(BuildScript script) | ||
{ | ||
if (script.GameVersionWriterConfig.Path.StartsWith("/")) | ||
{ | ||
return script.GameVersionWriterConfig.Path.Substring(1); | ||
} | ||
return script.GameVersionWriterConfig.Path; | ||
} | ||
} | ||
} | ||
#endif |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2020 Game Workstore | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
# Automation | ||
Automate your projects with this powerful tool with many build options! | ||
|
||
# How to install | ||
|
||
At package.json, add these 2 lines of code: | ||
```json | ||
"com.gameworkstore.automation": "https://github.com/GameWorkstore/automation.git#1.1.1" | ||
"com.gameworkstore.patterns": "https://github.com/GameWorkstore/patterns.git#1.1.8" | ||
``` | ||
|
||
And wait for unity to download and compile the package. | ||
|
||
you can upgrade your version by including the release version at end of the link: | ||
```json | ||
"com.gameworkstore.automation": "https://github.com/GameWorkstore/automation.git#1.1.1" | ||
"com.gameworkstore.patterns": "https://github.com/GameWorkstore/patterns.git#1.1.8" | ||
``` | ||
|
||
# Automate Builds | ||
|
||
On a windows .bat file, you invoke unity to build your game as the example below: | ||
```bat | ||
set CODEVERSION=23 | ||
set VERSION=1.0.%CODEVERSION% | ||
call %UNITYPATH% -executeMethod GameWorkstore.Automation.BuildClass.BuildAndroid -projectPath %WORKSPACE% -gameversion %VERSION% -gamebundleversion %CODEVERSION% | ||
``` | ||
|
||
You can also use Jenkins to attribute BUILD_NUMBER to CODEVERSION | ||
```bat | ||
set CODEVERSION=%BUILD_NUMBER% | ||
``` | ||
|
||
or you can sum with a static number | ||
```bat | ||
set /a "CODEVERSION=%BUILD_NUMBER%+0" | ||
``` | ||
|
||
# Arguments | ||
## -builscript | ||
name of the BuildScript asset. | ||
The target buildscript of your game, like 'BuildScript.asset'. | ||
don't forget to include '.asset' at end. | ||
|
||
## -gameversion | ||
public version for the app/game. Use 1.0.0 for best results (applestore don't allow larger versions, some appstore are following). | ||
|
||
## -gamebundleversion | ||
exclusive code version for android and iOS. must be a integer. | ||
|
||
# Build Methods | ||
|
||
* BuildWindows | ||
* BuildLinux | ||
* BuildAndroid | ||
* BuildIOS | ||
* BuildServerWindows | ||
* BuildServerLinux | ||
* BuildServerMacOS | ||
* BuildWebGL | ||
* BuildUWP | ||
|
||
# Contributions | ||
|
||
If you are using this library and want to submit a change, go ahead! Overall, this project accepts contributions if: | ||
- Is a bug fix; | ||
- Or, is a generalization of a well-known issue; | ||
- Or is performance improvement; | ||
- Or is an improvement to already supported feature. | ||
|
||
Also, you can donate to allow us to drink coffee while we improve it for you! |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.