Products
Technologies

Developer resources

Adobe AIR application version auto-increment

Avg. Rating 5.0

Problem

You want the version (build) of your app to auto-increment each time you build an AIR project.

Solution

Use a Ruby script as a Builder before compiling the application.

Detailed explanation

1. Get Ruby, install it to a path of your choice

2. Create a file version.rb in your project's source folder with the following contents:

#!/usr/bin/ruby
require 'rexml/document'
versionSeparator = "."
props = File.new("../.actionScriptProperties")
props_root = REXML::Document.new(props).root
filename = props_root.attributes["mainApplicationPath"].to_s
filename = filename.split(".")[0].to_s + "-app.xml"
file = File.new(filename)
root = REXML::Document.new(file).root
version = root.elements["version"].text.split(versionSeparator)
version[-1] = (version[-1].to_i + 1).to_s
root.elements["version"].text = version.join(versionSeparator)
File.open(filename,'w') do |f| f << root.parent end

3. Open your AIR Project's Properties, go to Builders, and add a new one of type "Program". Name it, say, "VersionIncrementer"

4. In it's "Edit Configuration" window, in the Main tab:

  • Location: the path to your Ruby executable
  • Working directory:  the path to your project's source folder
  • Arguments: version.rb

and in the Refresh tab:

  • Select "Refresh resources upon completion"
  • Select "Specific resources" and Open "Specify Resources"
  • Select the application descriptor file. (The one with a "-app.xml" at its end)

5. Move the Builder to the top of the list.

 

Nota bene: if your version string is not of the type X.X.X you'll have to change the separator variable in the script.

 

 


+
This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License. Permissions beyond the scope of this license, pertaining to the examples of code included within this work are available at Adobe.

Report abuse

Related recipes