Skip to content

GitLab

  • Menu
    • Projects Groups Snippets
      Help
Projects Groups Snippets
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • I Inversia
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 0
    • Issues 0
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 0
    • Merge requests 0
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Monitor
    • Monitor
    • Incidents
  • Packages & Registries
    • Packages & Registries
    • Package Registry
    • Container Registry
    • Infrastructure Registry
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • public-projects
  • Inversia
  • Merge requests
  • !19

Merged
Created 2 years ago by Дмитрий Макаров@mentosterMaintainer

Автоматическая сборка проекта

  • Overview 0
  • Commits 1
  • Changes 16

Последняя версия будет находиться в CI/CD -> Pipelines -> три точки по последней сборки -> скачать нужный для платформы билд

  • Дмитрий Макаров @mentoster requested review from @mentoster 2 years ago

    requested review from @mentoster

  • Дмитрий Макаров @mentoster assigned to @mentoster 2 years ago

    assigned to @mentoster

  • Дмитрий Макаров @mentoster merged 2 years ago

    merged

  • Дмитрий Макаров @mentoster mentioned in commit 97b0d00f 2 years ago

    mentioned in commit 97b0d00f

  • You're only seeing other activity in the feed. To add a comment, switch to one of the following options.
Please register or sign in to reply
Compare
  • master (base)

and
  • latest version
    da19496d
    1 commit, 2 years ago

16 files
+ 966
- 0

    Preferences

    File browser
    Compare changes
Assets/Scr‎ipts/Editor‎
EditMo‎deTests‎
EditModeExa‎mpleTests.cs‎ +25 -0
EditModeExampl‎eTests.cs.meta‎ +11 -0
BuildCo‎mmand.cs‎ +288 -0
BuildComma‎nd.cs.meta‎ +11 -0
BuildPost‎Process.cs‎ +71 -0
BuildPostPro‎cess.cs.meta‎ +11 -0
EditModeT‎ests.meta‎ +8 -0
c‎i‎
nunit-tr‎ansforms‎
LICEN‎SE.txt‎ +19 -0
nunit3-j‎unit.xslt‎ +69 -0
before_s‎cript.sh‎ +32 -0
buil‎d.sh‎ +36 -0
docker_‎build.sh‎ +14 -0
docker_‎test.sh‎ +13 -0
get_activat‎ion_file.sh‎ +49 -0
tes‎t.sh‎ +56 -0
.gitlab‎-ci.yml‎ +253 -0
Assets/Scripts/Editor/EditModeTests/EditModeExampleTests.cs 0 → 100644
+ 25
- 0
  • View file @ da19496d

  • Edit in single-file editor

  • Open in Web IDE

using UnityEngine.TestTools;
using NUnit.Framework;
using System.Collections;
public class EditModeExampleTests
{
[Test]
public void EditModeExampleTestSimplePasses ()
{
// Use the Assert class to test conditions.
Assert.True(true);
}
// A UnityTest behaves like a coroutine in PlayMode
// and allows you to yield null to skip a frame in EditMode
[UnityTest]
public IEnumerator EditModeExampleTestWithEnumeratorPasses ()
{
// Use the Assert class to test conditions.
// yield to skip a frame
Assert.True(true);
yield return null;
}
}
Assets/Scripts/Editor/EditModeTests/EditModeExampleTests.cs.meta 0 → 100644
+ 11
- 0
  • View file @ da19496d

  • Edit in single-file editor

  • Open in Web IDE

fileFormatVersion: 2
guid: 564a47f022d4146b8a72a27f3caccc2c
timeCreated: 1501856731
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
Assets/Scripts/Editor/BuildCommand.cs 0 → 100644
+ 288
- 0
  • View file @ da19496d

  • Edit in single-file editor

  • Open in Web IDE

using UnityEditor;
using System.Linq;
using System;
using System.IO;
static class BuildCommand
{
private const string KEYSTORE_PASS = "KEYSTORE_PASS";
private const string KEY_ALIAS_PASS = "KEY_ALIAS_PASS";
private const string KEY_ALIAS_NAME = "KEY_ALIAS_NAME";
private const string KEYSTORE = "keystore.keystore";
private const string BUILD_OPTIONS_ENV_VAR = "BuildOptions";
private const string ANDROID_BUNDLE_VERSION_CODE = "VERSION_BUILD_VAR";
private const string ANDROID_APP_BUNDLE = "BUILD_APP_BUNDLE";
private const string SCRIPTING_BACKEND_ENV_VAR = "SCRIPTING_BACKEND";
private const string VERSION_NUMBER_VAR = "VERSION_NUMBER_VAR";
private const string VERSION_iOS = "VERSION_BUILD_VAR";
static string GetArgument(string name)
{
string[] args = Environment.GetCommandLineArgs();
for (int i = 0; i < args.Length; i++)
{
if (args[i].Contains(name))
{
return args[i + 1];
}
}
return null;
}
static string[] GetEnabledScenes()
{
return (
from scene in EditorBuildSettings.scenes
where scene.enabled
where !string.IsNullOrEmpty(scene.path)
select scene.path
).ToArray();
}
static BuildTarget GetBuildTarget()
{
string buildTargetName = GetArgument("customBuildTarget");
Console.WriteLine(":: Received customBuildTarget " + buildTargetName);
if (buildTargetName.ToLower() == "android")
{
#if !UNITY_5_6_OR_NEWER
// https://issuetracker.unity3d.com/issues/buildoptions-dot-acceptexternalmodificationstoplayer-causes-unityexception-unknown-project-type-0
// Fixed in Unity 5.6.0
// side effect to fix android build system:
EditorUserBuildSettings.androidBuildSystem = AndroidBuildSystem.Internal;
#endif
}
if (buildTargetName.TryConvertToEnum(out BuildTarget target))
return target;
Console.WriteLine($":: {nameof(buildTargetName)} \"{buildTargetName}\" not defined on enum {nameof(BuildTarget)}, using {nameof(BuildTarget.NoTarget)} enum to build");
return BuildTarget.NoTarget;
}
static string GetBuildPath()
{
string buildPath = GetArgument("customBuildPath");
Console.WriteLine(":: Received customBuildPath " + buildPath);
if (buildPath == "")
{
throw new Exception("customBuildPath argument is missing");
}
return buildPath;
}
static string GetBuildName()
{
string buildName = GetArgument("customBuildName");
Console.WriteLine(":: Received customBuildName " + buildName);
if (buildName == "")
{
throw new Exception("customBuildName argument is missing");
}
return buildName;
}
static string GetFixedBuildPath(BuildTarget buildTarget, string buildPath, string buildName)
{
if (buildTarget.ToString().ToLower().Contains("windows")) {
buildName += ".exe";
} else if (buildTarget == BuildTarget.Android) {
#if UNITY_2018_3_OR_NEWER
buildName += EditorUserBuildSettings.buildAppBundle ? ".aab" : ".apk";
#else
buildName += ".apk";
#endif
}
return buildPath + buildName;
}
static BuildOptions GetBuildOptions()
{
if (TryGetEnv(BUILD_OPTIONS_ENV_VAR, out string envVar)) {
string[] allOptionVars = envVar.Split(',');
BuildOptions allOptions = BuildOptions.None;
BuildOptions option;
string optionVar;
int length = allOptionVars.Length;
Console.WriteLine($":: Detecting {BUILD_OPTIONS_ENV_VAR} env var with {length} elements ({envVar})");
for (int i = 0; i < length; i++) {
optionVar = allOptionVars[i];
if (optionVar.TryConvertToEnum(out option)) {
allOptions |= option;
}
else {
Console.WriteLine($":: Cannot convert {optionVar} to {nameof(BuildOptions)} enum, skipping it.");
}
}
return allOptions;
}
return BuildOptions.None;
}
// https://stackoverflow.com/questions/1082532/how-to-tryparse-for-enum-value
static bool TryConvertToEnum<TEnum>(this string strEnumValue, out TEnum value)
{
if (!Enum.IsDefined(typeof(TEnum), strEnumValue))
{
value = default;
return false;
}
value = (TEnum)Enum.Parse(typeof(TEnum), strEnumValue);
return true;
}
static bool TryGetEnv(string key, out string value)
{
value = Environment.GetEnvironmentVariable(key);
return !string.IsNullOrEmpty(value);
}
static void SetScriptingBackendFromEnv(BuildTarget platform) {
var targetGroup = BuildPipeline.GetBuildTargetGroup(platform);
if (TryGetEnv(SCRIPTING_BACKEND_ENV_VAR, out string scriptingBackend)) {
if (scriptingBackend.TryConvertToEnum(out ScriptingImplementation backend)) {
Console.WriteLine($":: Setting ScriptingBackend to {backend}");
PlayerSettings.SetScriptingBackend(targetGroup, backend);
} else {
string possibleValues = string.Join(", ", Enum.GetValues(typeof(ScriptingImplementation)).Cast<ScriptingImplementation>());
throw new Exception($"Could not find '{scriptingBackend}' in ScriptingImplementation enum. Possible values are: {possibleValues}");
}
} else {
var defaultBackend = PlayerSettings.GetDefaultScriptingBackend(targetGroup);
Console.WriteLine($":: Using project's configured ScriptingBackend (should be {defaultBackend} for targetGroup {targetGroup}");
}
}
static void PerformBuild()
{
var buildTarget = GetBuildTarget();
Console.WriteLine(":: Performing build");
if (TryGetEnv(VERSION_NUMBER_VAR, out var bundleVersionNumber))
{
if (buildTarget == BuildTarget.iOS)
{
bundleVersionNumber = GetIosVersion();
}
Console.WriteLine($":: Setting bundleVersionNumber to '{bundleVersionNumber}' (Length: {bundleVersionNumber.Length})");
PlayerSettings.bundleVersion = bundleVersionNumber;
}
if (buildTarget == BuildTarget.Android) {
HandleAndroidAppBundle();
HandleAndroidBundleVersionCode();
HandleAndroidKeystore();
}
var buildPath = GetBuildPath();
var buildName = GetBuildName();
var buildOptions = GetBuildOptions();
var fixedBuildPath = GetFixedBuildPath(buildTarget, buildPath, buildName);
SetScriptingBackendFromEnv(buildTarget);
var buildReport = BuildPipeline.BuildPlayer(GetEnabledScenes(), fixedBuildPath, buildTarget, buildOptions);
if (buildReport.summary.result != UnityEditor.Build.Reporting.BuildResult.Succeeded)
throw new Exception($"Build ended with {buildReport.summary.result} status");
Console.WriteLine(":: Done with build");
}
private static void HandleAndroidAppBundle()
{
if (TryGetEnv(ANDROID_APP_BUNDLE, out string value))
{
#if UNITY_2018_3_OR_NEWER
if (bool.TryParse(value, out bool buildAppBundle))
{
EditorUserBuildSettings.buildAppBundle = buildAppBundle;
Console.WriteLine($":: {ANDROID_APP_BUNDLE} env var detected, set buildAppBundle to {value}.");
}
else
{
Console.WriteLine($":: {ANDROID_APP_BUNDLE} env var detected but the value \"{value}\" is not a boolean.");
}
#else
Console.WriteLine($":: {ANDROID_APP_BUNDLE} env var detected but does not work with lower Unity version than 2018.3");
#endif
}
}
private static void HandleAndroidBundleVersionCode()
{
if (TryGetEnv(ANDROID_BUNDLE_VERSION_CODE, out string value))
{
if (int.TryParse(value, out int version))
{
PlayerSettings.Android.bundleVersionCode = version;
Console.WriteLine($":: {ANDROID_BUNDLE_VERSION_CODE} env var detected, set the bundle version code to {value}.");
}
else
Console.WriteLine($":: {ANDROID_BUNDLE_VERSION_CODE} env var detected but the version value \"{value}\" is not an integer.");
}
}
private static string GetIosVersion()
{
if (TryGetEnv(VERSION_iOS, out string value))
{
if (int.TryParse(value, out int version))
{
Console.WriteLine($":: {VERSION_iOS} env var detected, set the version to {value}.");
return version.ToString();
}
else
Console.WriteLine($":: {VERSION_iOS} env var detected but the version value \"{value}\" is not an integer.");
}
throw new ArgumentNullException(nameof(value), $":: Error finding {VERSION_iOS} env var");
}
private static void HandleAndroidKeystore()
{
#if UNITY_2019_1_OR_NEWER
PlayerSettings.Android.useCustomKeystore = false;
#endif
if (!File.Exists(KEYSTORE)) {
Console.WriteLine($":: {KEYSTORE} not found, skipping setup, using Unity's default keystore");
return;
}
PlayerSettings.Android.keystoreName = KEYSTORE;
string keystorePass;
string keystoreAliasPass;
if (TryGetEnv(KEY_ALIAS_NAME, out string keyaliasName)) {
PlayerSettings.Android.keyaliasName = keyaliasName;
Console.WriteLine($":: using ${KEY_ALIAS_NAME} env var on PlayerSettings");
} else {
Console.WriteLine($":: ${KEY_ALIAS_NAME} env var not set, using Project's PlayerSettings");
}
if (!TryGetEnv(KEYSTORE_PASS, out keystorePass)) {
Console.WriteLine($":: ${KEYSTORE_PASS} env var not set, skipping setup, using Unity's default keystore");
return;
}
if (!TryGetEnv(KEY_ALIAS_PASS, out keystoreAliasPass)) {
Console.WriteLine($":: ${KEY_ALIAS_PASS} env var not set, skipping setup, using Unity's default keystore");
return;
}
#if UNITY_2019_1_OR_NEWER
PlayerSettings.Android.useCustomKeystore = true;
#endif
PlayerSettings.Android.keystorePass = keystorePass;
PlayerSettings.Android.keyaliasPass = keystoreAliasPass;
}
}
Assets/Scripts/Editor/BuildCommand.cs.meta 0 → 100644
+ 11
- 0
  • View file @ da19496d

  • Edit in single-file editor

  • Open in Web IDE

fileFormatVersion: 2
guid: 395078190cdd6477bb6632383537d04e
timeCreated: 1501855165
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
Assets/Scripts/Editor/BuildPostProcess.cs 0 → 100644
+ 71
- 0
  • View file @ da19496d

  • Edit in single-file editor

  • Open in Web IDE

using UnityEditor.Callbacks;
using UnityEditor;
using System.IO;
using UnityEngine;
#if UNITY_IOS
using UnityEditor.iOS.Xcode;
public static class BuildPostProcess
{
private const string PLIST_FILE = "Info.plist";
private const string EXIST_ON_SUSPEND_KEY = "UIApplicationExitsOnSuspend";
private const string VERSIONING_SYSTEM_KEY = "VERSIONING_SYSTEM";
private const string CURRENT_PROJECT_VERSION_KEY = "CURRENT_PROJECT_VERSION";
private const string APPLE_GENERIC_VALUE = "apple-generic";
private const string ENABLE_BITCODE_KEY = "ENABLE_BITCODE";
private const string CODE_SIGN_STYLE_KEY = "CODE_SIGN_STYLE";
private const string PROVISIONING_PROFILE_SPECIFIER_KEY = "PROVISIONING_PROFILE_SPECIFIER";
private const string PROVISIONING_PROFILE_KEY = "PROVISIONING_PROFILE";
[PostProcessBuild(1)]
public static void IOSBuildPostProcess(BuildTarget target, string pathToBuiltProject)
{
RemoveDeprecatedInfoPListKeys(pathToBuiltProject);
string projectPath = PBXProject.GetPBXProjectPath(pathToBuiltProject);
var pbxProject = new PBXProject();
pbxProject.ReadFromFile(projectPath);
#if UNITY_2020_1_OR_NEWER
var guidProject = pbxProject.GetUnityMainTargetGuid();
#else
var guidProject = pbxProject.TargetGuidByName(pbxProject.GetUnityMainTargetGuid());
#endif
Debug.Log("Setting Versioning system to Apple Generic...");
pbxProject.SetBuildProperty(guidProject, VERSIONING_SYSTEM_KEY, APPLE_GENERIC_VALUE);
pbxProject.SetBuildProperty(guidProject, CURRENT_PROJECT_VERSION_KEY, "1");
Debug.Log("Disabling bitcode...");
pbxProject.SetBuildProperty(guidProject, ENABLE_BITCODE_KEY, "NO");
Debug.Log("Setting Code sign style to manual and setup provisioning profile specifier...");
pbxProject.SetBuildProperty(guidProject, CODE_SIGN_STYLE_KEY, "Manual");
pbxProject.SetBuildProperty(guidProject, PROVISIONING_PROFILE_SPECIFIER_KEY, pbxProject.GetBuildPropertyForAnyConfig(guidProject, PROVISIONING_PROFILE_KEY));
pbxProject.WriteToFile(projectPath);
}
private static void RemoveDeprecatedInfoPListKeys(string pathToBuiltProject)
{
string plistPath = Path.Combine(pathToBuiltProject, PLIST_FILE);
PlistDocument plist = new PlistDocument();
plist.ReadFromString(File.ReadAllText(plistPath));
PlistElementDict rootDict = plist.root;
if (rootDict.values.ContainsKey(EXIST_ON_SUSPEND_KEY))
{
Debug.LogFormat("Removing deprecated key \"{0}\" on \"{1}\" file", EXIST_ON_SUSPEND_KEY, PLIST_FILE);
rootDict.values.Remove(EXIST_ON_SUSPEND_KEY);
}
File.WriteAllText(plistPath, plist.WriteToString());
}
}
#endif
Assignee
Дмитрий Макаров's avatar
Дмитрий Макаров
@mentoster
Assign to
Reviewer
Дмитрий Макаров's avatar
Дмитрий Макаров @mentoster
Request review from
Milestone
No milestone
None
None
Time tracking
No estimate or time spent
Labels
0
None
0
None
    Assign labels
  • Manage project labels

Lock merge request
Unlocked
1
1 participant
Дмитрий Макаров
Reference: public-projects/Inversia!19
Source branch: feature/cd_cd

Menu

Projects Groups Snippets
Help