【问题标题】:how to auto increment release(production) version number (CFBundleShortVersionString )?如何自动增加发布(生产)版本号(CFBundleShortVersionString)?
【发布时间】:2014-07-22 07:06:32
【问题描述】:

我们的发布过程是使用 ci 服务器完成的。
现在我想做的是自动增加发布(生产)版本号(CFBundleShortVersionString),除了例外情况(主要版本或补丁版本)。

想象一下我当前的发布版本 1.1,我想将其自动递增到 1.2。

任何知道如何使用 Xcode 或任何脚本执行此操作的人都非常感谢它。

我不是在谈论内部版本号 (CFBundleVersion)。

【问题讨论】:

    标签: python ios xcode perl shell


    【解决方案1】:
    #!/bin/bash
    
    buildPlist="${PRODUCT_NAME}-Info.plist"
    
    buildNumber=$(/usr/libexec/PlistBuddy -c "Print CFBuildNumber" $buildPlist)
    
    # Increment the buildNumber
    buildNumber=$(($buildNumber + 1))
    
    # Set the version numbers in the buildPlist
    /usr/libexec/PlistBuddy -c "Set :CFBundleLongVersionString $buildNumber" $buildPlist
    

    Source 的修改版本。您可以通过为$buildNumber 设置默认值以及将增量值从1 修改为您想要的任何值来修改它。

    【讨论】:

    • 我不是在谈论内部版本号(CFBundleVersion)
    • 在那里使用任何自定义值,它只是一个变量。最终你设置Set :CFBundleLongVersionString
    【解决方案2】:
    import sys
    
    import click
    
    MIN_DIGITS = 2
    MAX_DIGITS = 3
    
    
    @click.command()
    @click.argument('version')
    @click.option('--major', 'bump_idx', flag_value=0, help='Increment major number.')
    @click.option('--minor', 'bump_idx', flag_value=1, help='Increment minor number.')
    @click.option('--patch', 'bump_idx', flag_value=2, default=True, help='Increment patch number.')
    def cli(version, bump_idx):
        """Bumps a MAJOR.MINOR.PATCH version string at the specified index location or 'patch' digit. An
        optional 'v' prefix is allowed and will be included in the output if found."""
        prefix = version[0] if version[0].isalpha() else ''
        digits = version.lower().lstrip('v').split('.')
    
        if len(digits) > MAX_DIGITS:
            click.secho('ERROR: Too many digits', fg='red', err=True)
            sys.exit(1)
    
        digits = (digits + ['0'] * MAX_DIGITS)[:MAX_DIGITS]  # Extend total digits to max.
        digits[bump_idx] = str(int(digits[bump_idx]) + 1)  # Increment the desired digit.
    
        # Zero rightmost digits after bump position.
        for i in range(bump_idx + 1, MAX_DIGITS):
            digits[i] = '0'
        digits = digits[:max(MIN_DIGITS, bump_idx + 1)]  # Trim rightmost digits.
        click.echo(prefix + '.'.join(digits), nl=False)
    
    
    if __name__ == '__main__':
        cli()
    

    GitHub Source

    【讨论】:

      猜你喜欢
      • 2019-06-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多