Skip to content

Commit

Permalink
+Version 1.1.4
Browse files Browse the repository at this point in the history
Added support for change package name based on buildscript
  • Loading branch information
HanzaRu committed Aug 8, 2022
0 parents commit eb62a28
Show file tree
Hide file tree
Showing 19 changed files with 1,070 additions and 0 deletions.
Binary file added .icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions Editor.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 19 additions & 0 deletions Editor/GameWorkstore.Automation.Editor.asmdef
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
}
7 changes: 7 additions & 0 deletions Editor/GameWorkstore.Automation.Editor.asmdef.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

97 changes: 97 additions & 0 deletions Editor/VersionWriter.cs
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
11 changes: 11 additions & 0 deletions Editor/VersionWriter.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 21 additions & 0 deletions LICENSE
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.
7 changes: 7 additions & 0 deletions LICENSE.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

71 changes: 71 additions & 0 deletions README.md
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!
7 changes: 7 additions & 0 deletions README.md.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions Runtime.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit eb62a28

Please sign in to comment.