
import os
import sys


def main():
    if len(sys.argv) != 2:
        print('Usage: %s version' % sys.argv[0])
        os.system('git tag | sort -n | tail -n 1')
        sys.exit()

    version = sys.argv[1]

    with open('floo/version.py', 'r') as fd:
        version_py = fd.read().split('\n')

    version_py[0] = "PLUGIN_VERSION = '%s'" % version

    with open('floo/version.py', 'w') as fd:
        fd.write('\n'.join(version_py))

    os.system('git add packages.json floo/version.py')
    os.system('git commit -m "Tag new release: %s"' % version)
    os.system('git tag %s' % version)
    os.system('git push --tags')
    os.system('git push')


if __name__ == "__main__":
    main()


import os
import re
import sys
from distutils.version import StrictVersion


def main():
    if len(sys.argv) != 2:
        print('Usage: %s version' % sys.argv[0])
        versions = os.popen('git tag').read().split('\n')
        versions = [v for v in versions if re.match("\\d\\.\\d\\.\\d", v)]
        versions.sort(key=StrictVersion)
        print(versions[-1])
        sys.exit()

    version = sys.argv[1]

    with open('floo/version.py', 'r') as fd:
        version_py = fd.read().split('\n')

    version_py[0] = "PLUGIN_VERSION = '%s'" % version

    with open('floo/version.py', 'w') as fd:
        fd.write('\n'.join(version_py))

    os.system('git add packages.json floo/version.py')
    os.system('git commit -m "Tag new release: %s"' % version)
    os.system('git tag %s' % version)
    os.system('git push --tags')
    os.system('git push')


if __name__ == "__main__":
    main()

Tag release script now works with semvers.
Tag release script now works with semvers.

  
  import os
+ import re
  import sys
+ from distutils.version import StrictVersion
  
  
  def main():
      if len(sys.argv) != 2:
          print('Usage: %s version' % sys.argv[0])
-         os.system('git tag | sort -n | tail -n 1')
+         versions = os.popen('git tag').read().split('\n')
+         versions = [v for v in versions if re.match("\\d\\.\\d\\.\\d", v)]
+         versions.sort(key=StrictVersion)
+         print(versions[-1])
          sys.exit()
  
      version = sys.argv[1]
  
      with open('floo/version.py', 'r') as fd:
          version_py = fd.read().split('\n')
  
      version_py[0] = "PLUGIN_VERSION = '%s'" % version
  
      with open('floo/version.py', 'w') as fd:
          fd.write('\n'.join(version_py))
  
      os.system('git add packages.json floo/version.py')
      os.system('git commit -m "Tag new release: %s"' % version)
      os.system('git tag %s' % version)
      os.system('git push --tags')
      os.system('git push')
  
  
  if __name__ == "__main__":
      main()
  
Tag release script now works with semvers.
## Code Before:

import os
import sys


def main():
    if len(sys.argv) != 2:
        print('Usage: %s version' % sys.argv[0])
        os.system('git tag | sort -n | tail -n 1')
        sys.exit()

    version = sys.argv[1]

    with open('floo/version.py', 'r') as fd:
        version_py = fd.read().split('\n')

    version_py[0] = "PLUGIN_VERSION = '%s'" % version

    with open('floo/version.py', 'w') as fd:
        fd.write('\n'.join(version_py))

    os.system('git add packages.json floo/version.py')
    os.system('git commit -m "Tag new release: %s"' % version)
    os.system('git tag %s' % version)
    os.system('git push --tags')
    os.system('git push')


if __name__ == "__main__":
    main()

## Instruction:
Tag release script now works with semvers.
## Code After:

import os
import re
import sys
from distutils.version import StrictVersion


def main():
    if len(sys.argv) != 2:
        print('Usage: %s version' % sys.argv[0])
        versions = os.popen('git tag').read().split('\n')
        versions = [v for v in versions if re.match("\\d\\.\\d\\.\\d", v)]
        versions.sort(key=StrictVersion)
        print(versions[-1])
        sys.exit()

    version = sys.argv[1]

    with open('floo/version.py', 'r') as fd:
        version_py = fd.read().split('\n')

    version_py[0] = "PLUGIN_VERSION = '%s'" % version

    with open('floo/version.py', 'w') as fd:
        fd.write('\n'.join(version_py))

    os.system('git add packages.json floo/version.py')
    os.system('git commit -m "Tag new release: %s"' % version)
    os.system('git tag %s' % version)
    os.system('git push --tags')
    os.system('git push')


if __name__ == "__main__":
    main()
