#!/home/nick/bin/feathers import java.io.File import java.util.Date import java.text.SimpleDateFormat class Upload() { static val usage = """ Usage : upload.feather Uploads tickle and game zip files upload.feather --javadoc Uploads tickle's API docs (javadoc and dokka formats) upload.feather --test Runs each game in turn. Good to check that the scripts compile! """ static val dir = File( "/home/nick/projects" ) static val gamesDir = File( "/home/nick/games" ) static val destDir = File( "/gidea/documents/public/software" ) static val dateFormat = SimpleDateFormat( "yyyy-MM-dd" ) static val date = "-${dateFormat.format( Date() )}" static val tickleVersion = "0.5" static fun main( argv : String... ) { val games = listOf("higgsAnomaly", "burton", "cavernQuest", "dodgeEm", "drunkinvaders", "dollsHouse" ) if (argv.size() == 0) { distZip( "tickle" ) for (game in games) { zipGame( game ) } } else if ( argv[0] == "--javadoc" ) { javadoc() } else if ( argv[0] == "--test" ) { for (game in games) { println( "Running game $game" ) val command = $( ./build/install/tickle/bin/tickle --verbose ${gamesDir}/$game/$game.tickle ) if ( command.run().exitStatus != 0 ) { println( "Game $game exited abnormally" ) return } } println( "Done" ) } else { println( usage ) println( "Unexpected argument ${argv[0]}" ) } } static fun distZip( name : String ) { val srcDir = File( dir, name ) $( mkdir -p 'src/dist' ).dir( srcDir ).run() $( git log -n 1 > 'src/dist/latestCommit.txt' ).dir( srcDir ).run() $( ./gradlew ).dir( srcDir ).run() // Ensure ClassMetaData is up-to-date before running gradle again. $( ./gradlew distZip ).dir( srcDir ).run() $( cp 'build/distributions/${name}.zip' '$destDir/${name}${tickleVersion}${date}.zip' ).dir( srcDir ).run() } static fun javadoc() { val name = "tickle" val srcDir = File( dir, name ) println( "Generating Javadocs" ) $( ./gradlew dokkaJavadoc ).dir( srcDir ).run() println() println( "Uploading Javadocs" ) $( rsync -r tickle-core/build/dokka/javadoc/ '$destDir/${name}-${tickleVersion}-javadoc' ).dir( srcDir ).run() println( "Generating Dokka" ) $( ./gradlew dokkaHtml).dir( srcDir ).run() println() println( "Uploading Dokka" ) $( rsync -r tickle-core/build/dokka/html/ '$destDir/${name}-${tickleVersion}-dokka' ).dir ( srcDir ).run() } static fun zipGame( name : String ) { val srcDir = File( gamesDir, name ) $( git log -n 1 > 'latestCommit.txt' ).dir( srcDir ).run() val dest = File( destDir, "${srcDir.name}${date}.zip" ) $( rm '$dest' ) // Exclude the git stuff and graphics directory! // "graphics/" holds svg, gimp files and un processed images. // "images/"" is where the game's images are stored. $( zip -r -9 -o '${dest}' '${srcDir.name}' -x '*.git*' -x graphics -x work ).dir( srcDir.parentFile ).run() } }