Version Number Creation Hell



  • So, the boss asked me to change the structure of the version information displayed in the about box. Previously, it showed date information. We need to move to a more version-number way for reasons that don't really matter.

    So, I start digging.

    public void showAboutBox() {
      Properties version_props = new Properties();
      String file_name = System.getProperty("APP_HOME", "/prod/app") + "/" + "release.info";
      try {
        version_props.load(new FileInputStream(file_name));
      } catch (Exception e) {
        e.printStackTrace();
      }
    

    String about = ABOUT_MESSAGE + version_props.getProperty("Release_Identifier", "no version found");

    Utilities.showInternalMessageDialog(this, about, "About App", JOptionPane.INFORMATION_MESSAGE);

    }

    Um ... okay ... so, where does this "release.info" file get created? Ant config, probably? Aha, yes! build.xml:

    <target name="release-info" depends="init">
    

    <exec executable="cvs" output="temp1.fil">
    <arg value="log" />
    <arg value="${basedir}/build.xml" />
    </exec>

    <exec executable="grep" output="temp2.fil">
    <arg value="-v" />
    <arg value="candidate_release_" />
    <arg value="temp1.fil" />
    </exec>

    <exec executable="grep" output="temp1.fil">
    <arg value="release_" />
    <arg value="temp2.fil" />
    <exec>

    <exec executable="sed" output="temp2.fil">
    <arg value="-e" />
    <arg value="s/^.release_/release_/;s/:.$//" />
    <arg value="temp1.fil" />
    </exec>

    <exec executable="nawk" output="temp1.fil">
    <arg value="BEGIN{x=0};{x++;if(x==1) print $0}" />
    <arg value="temp2.fil" />
    </exec>

    <loadfile srcFile="${basedir}/temp1.fil" property="releaseId">
    <filterchain>
    <filterreader classname="org.apache.tools.ant.filters.LineContainsRegExp">
    <param type="regexp" value="release_[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]" />
    </filterreader>
    </filterchain>
    </loadfile>

    <echo
    message="Project Name: ${project}${line.separator}"
    file="${dist}/release.info" />

    <echo
    message="Release_Identifier=${releaseId}"
    file="${dist}/release.info"
    append="true" />

    <echo
    message="Build Timestamp: "
    file="${dist}/release.info"
    append="true" />

    <exec executable="date" output="${dist}/release.info" append="true" />

    <delete file="temp1.fil" verbose="false" />
    <delete file="temp2.fil" verbose="true" />

    <exec executable="cat" output="${dist}/application.info">
    <arg value="${dist}/release.info" />
    <arg value="${lib.dist}/release.info" />
    </exec>
    </target>

    :headdesk:

    Essentially, search for the first tag in CVS, strip off the 'release' word and stuff it into the release ID and create the file with that info?

    So, if I don't want to break these fragile relationships, I change the regex in the filterreader to recognize [0-9].[0-9],[0-9], start using that format in the tags, and I'm done?

    But what if I want to overhaul this whole process? How do you guys do this kind of thing? There's got to be a simpler way to do this, right?



  • That is heinous. Ant is good for some things but when you're doing shell scripting in it you should ask yourself "Is there a better way"?



  • @zelmak said:

    But what if I want to overhaul this whole process? How do you guys do this kind of thing? There's got to be a simpler way to do this, right?
    Our repository is set up as a trunk that we release from and project/feature branches, so we keep a file in the repository that represents the major and minor versions and another file with the build number.  The build script increments number in the build number file and then major and minor version numbers are modified by hand.  Our version number format is Mojor.Minor.Build.Revision with "Revision" being the SubVersion revision number of the latest change to that project in the repository.



  • They're wanting to move from Solaris to Windows, client-side.

    I'm waiting to yell and scream when they want us to move development to Windows as well.

    Recently, I created a ticket to have a java -> c-shell -> sqlplus -> database process (with requisite hard-coded passwords in the shell script) changed to a java -> database process.

    Morbs / Blakey ... where (geographically) do you work and are there openings? As insane as either of you are, it would feel like Eden working in/around your environment compared to here.



  • @Jaime said:

    @zelmak said:

    But what if I want to overhaul this whole process? How do you guys do this kind of thing? There's got to be a simpler way to do this, right?
    Our repository is set up as a trunk that we release from and project/feature branches, so we keep a file in the repository that represents the major and minor versions and another file with the build number.  The build script increments number in the build number file and then major and minor version numbers are modified by hand.  Our version number format is Mojor.Minor.Build.Revision with "Revision" being the SubVersion revision number of the latest change to that project in the repository.

    Sadly, I've yet to figure out how to get a single magic number from CVS ... since version numbers are on individual files instead of the repository / project as a whole. How ugly is your build script which increments this number? Does it sit and wait for user input for the major/minor numbers or do you have to edit (and commit) the file before the build process?



  • @zelmak said:

    How ugly is your build script which increments this number? Does it sit and wait for user input for the major/minor numbers or do you have to edit (and commit) the file before the build process?
    We manually edit and commit the major/minor number.  The script is medium-ugly, but that's mostly due to the fact that we build shared libraries from source, so every build has five or more versioned files, all with different version numbers.  The main output always increments the build number, but shared outputs only increment the build number if there has been a commit since the last build.  That way the same source always maps to the same version number.



  •  I just feel sorry for you that you're still using CVS in this day and age.  WTF?



  • @zelmak said:

    Morbs / Blakey ... where (geographically) do you work and are there openings? As insane as either of you are, it would feel like Eden working in/around your environment compared to here.

    I'm the most sane person on this board. Now excuse me while I spend 6 hours trying to get my cat to pose in her My Little Ponies outfit, so I can add that as a shield icon in Skyrim.


  • Discourse touched me in a no-no place

    @zelmak said:

    Morbs / Blakey ... where (geographically) do you work and are there openings?
    As insane as either of you are, it would feel like Eden working in/around
    your environment compared to here.

    I, for some reason, feel you're missing out Snoofle in your requirements document....



  • @zelmak said:

    Morbs / Blakey ... where (geographically) do you work and are there openings? As insane as either of you are, it would feel like Eden working in/around your environment compared to here.

    I work for a Bay Area company. I'm in the middle of relocating permanently to one of the two non-contiguous states. I have a place to live but I still have to take care of some stuff where I'm living now.



  • @morbiuswilters said:

    @zelmak said:
    Morbs / Blakey ... where (geographically) do you work and are there openings? As insane as either of you are, it would feel like Eden working in/around your environment compared to here.

    I work for a Bay Area company. I'm in the middle of relocating permanently to one of the two non-contiguous states. I have a place to live but I still have to take care of some stuff where I'm living now.

    The one that Microsoft Flight models, or the one with polar bears?



  • @morbiuswilters said:

    @zelmak said:
    Morbs / Blakey ... where (geographically) do you work and are there openings? As insane as either of you are, it would feel like Eden working in/around your environment compared to here.

    I work for a Bay Area company. I'm in the middle of relocating permanently to one of the two non-contiguous states. I have a place to live but I still have to take care of some stuff where I'm living now.

     Hey, Im based out of NY, but have been stuck in Milpitas for the past 6 months (just outside San Jose for those not familiar). I have family who until recently lived in HAwaii (my assumption as to where you are going) and have spend time in Alaska (great to visit...but...) myself.



  • @blakeyrat said:

    @morbiuswilters said:
    @zelmak said:
    Morbs / Blakey ... where (geographically) do you work and are there openings? As insane as either of you are, it would feel like Eden working in/around your environment compared to here.

    I work for a Bay Area company. I'm in the middle of relocating permanently to one of the two non-contiguous states. I have a place to live but I still have to take care of some stuff where I'm living now.

    The one that Microsoft Flight models, or the one with polar bears?

    The one from which you cannot see Russia.



  • @TheCPUWizard said:

    Hey, Im based out of NY

    I used to be based out of Cambridge but decided to look for jobs closer to the non-contiguous state I would be moving to.

    @TheCPUWizard said:

    I have family who until recently lived in HAwaii

    Which island?



  • @morbiuswilters said:

    @TheCPUWizard said:
    Hey, Im based out of NY

    I used to be based out of Cambridge but decided to look for jobs closer to the non-contiguous state I would be moving to.

    @TheCPUWizard said:

    I have family who until recently lived in HAwaii

    Which island?

    Maui, in Kihei (athough for a time they live in Lahaina)



  • @TheCPUWizard said:

    Maui, in Kihei (athough for a time they live in Lahaina)

    Ah, I love Lahaina; it's probably my second favorite town after Paia. They're all nice, though.



  • @TheCPUWizard said:

    spend time in Alaska (great to visit...but...)
     

    AK is an awesome place to live, plus it would help most on this board blend in as their crazy wouldn't stand out as much.



  • @locallunatic said:

    @TheCPUWizard said:

    spend time in Alaska (great to visit...but...)
     

    AK is an awesome place to live, plus it would help most on this board blend in as their crazy wouldn't stand out as much.

     My sister is moving up there (just outside Anchorage) next year... Personally I like the "faster pace", which is why I will probably never move out of Manhattan (again).



  • @TheCPUWizard said:

    My sister is moving up there (just outside Anchorage) next year
     

    Oh?  Which direction from Anchortown, Girdwood or Eagle River/Wasilla/Palmer way?



  • @locallunatic said:

    @TheCPUWizard said:

    My sister is moving up there (just outside Anchorage) next year
     

    Oh?  Which direction from Anchortown, Girdwood or Eagle River/Wasilla/Palmer way?

     Not exactly known. She is a teacher and there are opportunities up in that area. Location will depend on where she gets hired.



  • @TheCPUWizard said:

    Not exactly known. She is a teacher and there are opportunities up in that area. Location will depend on where she gets hired.
     

    Then if not in Anchorage but close by it's almost certainly going to be Eagle River/Wasilla/Palmer way, Girdwood is too small to have many spots and is right at the foot of a good slope so I'm sure there is fighting over any spots there.  Of course it could also be Alaska close by and not lower 48 close in which case the options expand a lot.



  • @morbiuswilters said:

    The one from which you cannot see Russia.

    Hope you enjoy spam. And sushi made from spam.



  • @blakeyrat said:

    @morbiuswilters said:
    The one from which you cannot see Russia.

    Hope you enjoy spam. And sushi made from spam.

    I find their love of Spam amusing, but no, I probably won't be eating any. I've never actually had it but even when I ate meat it didn't look appetizing.



  • @morbiuswilters said:

    I've never actually had it but even when I ate meat it didn't look appetizing.

    I've eaten SPAM quite a few times. You can of course just slice it and put it in a sandwich as-is, but it definitely tastes best after gentle shallow-frying over a medium to low heat until it's turned golden on the outside. I'm not trying to pretend it's as good as (say) a gammon steak, but it's not the worst thing I've ever eaten, either.



  • @blakeyrat said:

    I'm the most sane person on this board. Now excuse me while I spend 6 hours trying to get my cat to pose in her My Little Ponies outfit, so I can add that as a shield icon in Skyrim.

     It's easier if you just use the cat's skin.



  • Here's what my group does...
    We have a release script we use for building our releases. 
    Our release script will TAG the release.
    
    We always use the format of vX.XX (it's manually maintained).
    
    Then the build scripts checkouts the TAG.
    That way each CVS directory has Tag file indicating the build number.
    
    In our build scripts we read in the build number.
    LINUX method:
    export releasetag=`cat CVS/Tag`
    
    WINDOWS method:
    SET CVSFOLDER="%~dp0CVS\Tag"
    set releasetag=
    IF EXIST %CVSFOLDER% (
     FOR /F "usebackq eol=; tokens=* delims=" %%i in (%CVSFOLDER%) do set releasetag=%%i
    )
    
    Then in our ANT XML file we have:
    	<condition property="env.releasetag" else="HEAD">
    		<isset property="env.releasetag" />
    	</condition>
    	<tstamp>
    		<format property="env.buildDate" pattern="yyyy-MM-dd hh:mm aa" unit="hour"/>
      	</tstamp>
    
    		<delete file="out/version.info"/>
    		<copy file="templates/version.info" todir="out/version.info" filtering="on">
    			<filterset>
    					<filter token="releaseTag" value="${env.releasetag}"/>
    					<filter token="buildDate" value="${env.buildDate}"/>
    			</filterset>
    		</copy>
    


  • @PJH said:

    @zelmak said:

    Morbs / Blakey ... where (geographically) do you work and are there openings? As insane as either of you are, it would feel like Eden working in/around your environment compared to here.

    I, for some reason, feel you're missing out Snoofle in your requirements document....

    No no ... those people are bat-shit crazy.

    Oh, wait ... hrm ...

    No, I think they're still crazier at snoofle's place of work. The problem here is a 'too many cooks, with no design over 12 years' problem ...



  • @morbiuswilters said:

    @TheCPUWizard said:
    Hey, Im based out of NY
    I used to be based out of Cambridge but decided to look for jobs closer to the non-contiguous state I would be moving to.

    @TheCPUWizard said:
    I have family who until recently lived in HAwaii
    Which island?

    I was on Oahu for three years at Hickam. (I'm retired USAF.)



  • Oh, and thanks all for your hints how to overhaul our process.



  • @blakeyrat said:

    Now excuse me while I spend 6 hours trying to get my cat to pose in her My Little Ponies outfit, so I can add that as a shield icon in Skyrim.
     

    They make those in cat sizes?!


Log in to reply