Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2639887c authored by Marten Gajda's avatar Marten Gajda
Browse files

Add task to publish the current version number, implements #550

parent df5b1876
Loading
Loading
Loading
Loading
+19 −1
Original line number Diff line number Diff line
@@ -117,3 +117,21 @@ if (project.hasProperty('PLAY_STORE_SERVICE_ACCOUNT_CREDENTIALS')) {
        }
    }
}

task postVersion {
    doLast {
        if (project.hasProperty('OPENTASKS_API_KEY')) {
            // publish version number on api.opentasks.app
            ((HttpURLConnection) new URL('https://opentasks-app.appspot.com/v1/app/latest_version/').openConnection()).with({
                requestMethod = 'POST'
                doOutput = true
                setRequestProperty('Content-Type', 'application/x-www-form-urlencoded')
                setRequestProperty('Authorization', "Token token=\"${OPENTASKS_API_KEY}\"")
                outputStream.withPrintWriter({ printWriter ->
                    printWriter.write("version_code=${project.android.defaultConfig.versionCode}&version_name=${project.android.defaultConfig.versionName}")
                })
                content
            })
        }
    }
}