Beispiel #1
0
        /// <summary>
        /// Generate bundle number of build for Android and iOS.<br/>
        /// Format: <![CDATA[<revision><branchId><targetId>]]><br/>
        /// Where <i>revision</i> - parsed number from <see cref="GitRequest.Revision"/>;
        /// <i>branchId</i> - 0 if current branch is equal to <see cref="RELEASE_BRANCH"/>, otherwise 1.<br/>
        /// Example return: "23401" - revision is 234, release branch, targetId is 1.
        /// </summary>
        /// <param name="targetId">Default is 0. Target id for distinguish between builds for different
        /// targets on one platform (e.g. ARMv7 and x86 on Android).</param>
        /// <returns>Generated bundle number</returns>
        public static int GenBundleNumber(int targetId = 0)
        {
            var rev      = GitRequest.Revision(true);
            int branchId = GitRequest.CurrentBranch() == RELEASE_BRANCH ? 0 : 1;

            return(int.Parse(string.Format("{0}{1}{2}", rev, branchId, targetId)));
        }
Beispiel #2
0
        /// <summary>
        /// Generate version of build for current git repository state.<br/>
        /// Format: <![CDATA[<major>.<minor>]]><br/>
        /// There is two type of minor versions:
        /// <list type="bullet">
        ///     <item>
        ///         <description>Minor version is pretty number, e.g. "2.1.234".
        ///         Returned if current branch is equal to <see cref="RELEASE_BRANCH"/></description>
        ///     </item>
        ///     <item>
        ///         <description>Minor version is revision id, e.g. "2.1.d-1685c5a".
        ///         Returned if current branch is <b>not</b> equal to <see cref="RELEASE_BRANCH"/></description>
        ///     </item>
        /// </list>
        /// Major version is a Version in Unity Player Settings (<see cref="PlayerSettings.bundleVersion"/>).
        /// </summary>
        /// <seealso cref="GitRequest.Revision"/>
        /// <returns>Ganerated version</returns>
        public static string GetBuildVersion()
        {
            var    branch = GitRequest.CurrentBranch();
            string version;

            if (branch == RELEASE_BRANCH)
            {
                version = GitRequest.Revision(true);
            }
            else
            {
                Debug.LogWarningFormat("Build development version from '{0}'", branch);
                version = PREFIX_DEVELOP + GitRequest.Revision(false);
            }
            return(PlayerSettings.bundleVersion + "." + version);
        }