Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: Publish Flank-scripts to Github #1618

Merged
merged 2 commits into from
Feb 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/release_flank_scripts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:

- uses: gradle/wrapper-validation-action@v1

- name: Gradle Upload to bintray
- name: Gradle Upload to Github packages and Github release
uses: eskatos/gradle-command-action@v1
with:
arguments: "flank-scripts:bintrayUpload -PJFROG_API_KEY=${{ secrets.JFROG_API_KEY }} -PJFROG_USER=${{ secrets.JFROG_USER }}"
arguments: "flank-scripts:releaseFlankScripts"
1 change: 0 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ plugins {
kotlin(Plugins.Kotlin.PLUGIN_JVM) version Versions.KOTLIN
id(Plugins.KTLINT_GRADLE_PLUGIN) version Versions.KTLINT_GRADLE
id(Plugins.BEN_MANES_PLUGIN) version Versions.BEN_MANES
id(Plugins.JFROG_BINTRAY) version Versions.BINTRAY
id(Plugins.NEXUS_STAGING) version Versions.NEXUS_STAGING
}

Expand Down
1 change: 0 additions & 1 deletion buildSrc/src/main/kotlin/Plugins.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ object Plugins {

const val PLUGIN_SHADOW_JAR = "com.github.johnrengelman.shadow"
const val KTLINT_GRADLE_PLUGIN = "org.jmailen.kotlinter"
const val JFROG_BINTRAY = "com.jfrog.bintray"
const val MAVEN_PUBLISH = "maven-publish"
const val NEXUS_STAGING = "io.codearte.nexus-staging"
const val BEN_MANES_PLUGIN = "com.github.ben-manes.versions"
Expand Down
3 changes: 0 additions & 3 deletions buildSrc/src/main/kotlin/Versions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@ object Versions {

const val KTLINT = "0.40.0"

// https://github.com/bintray/gradle-bintray-plugin/releases
const val BINTRAY = "1.8.5"

// https://github.com/Codearte/gradle-nexus-staging-plugin
const val NEXUS_STAGING = "0.22.0"

Expand Down
64 changes: 33 additions & 31 deletions flank-scripts/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
import com.jfrog.bintray.gradle.BintrayExtension
import java.io.ByteArrayOutputStream
import java.nio.file.Files
import java.nio.file.Paths
import java.util.Date

plugins {
application
kotlin(Plugins.Kotlin.PLUGIN_JVM)
kotlin(Plugins.Kotlin.PLUGIN_SERIALIZATION) version Versions.KOTLIN
id(Plugins.PLUGIN_SHADOW_JAR) version Versions.SHADOW
id(Plugins.MAVEN_PUBLISH)
id(Plugins.JFROG_BINTRAY)
}

val artifactID = "flank-scripts"
Expand All @@ -28,7 +26,7 @@ shadowJar.apply {
}
}
// <breaking change>.<feature added>.<fix/minor change>
version = "1.6.3"
version = "1.6.4"
group = "com.github.flank"

application {
Expand All @@ -39,30 +37,17 @@ application {
)
}

bintray {
user = System.getenv("JFROG_USER") ?: properties["JFROG_USER"].toString()
key = System.getenv("JFROG_API_KEY") ?: properties["JFROG_API_KEY"].toString()
publish = true
override = true
setPublications("mavenJava")
pkg(
closureOf<BintrayExtension.PackageConfig> {
repo = "maven"
name = artifactID
userOrg = "flank"
setLicenses("Apache-2.0")
vcsUrl = "https://github.com/Flank/flank.git"
version(
closureOf<BintrayExtension.VersionConfig> {
name = version.name
released = Date().toString()
}
)
}
)
}

publishing {
repositories {
maven {
name = "GitHubPackages"
url = uri("https://maven.pkg.github.com/Flank/flank")
credentials {
username = System.getenv("GITHUB_ACTOR") ?: properties["GITHUB_ACTOR"].toString()
password = System.getenv("GITHUB_TOKEN") ?: properties["GITHUB_TOKEN"].toString()
}
}
}
publications {
create<MavenPublication>("mavenJava") {
groupId = group.toString()
Expand Down Expand Up @@ -132,10 +117,16 @@ val prepareJar by tasks.registering(Copy::class) {
into("$projectDir/bash")
}

tasks.register("download") {
val sourceUrl = "https://dl.bintray.com/flank/maven/com/github/flank/$artifactID/$version/$artifactID-$version.jar"
val destinationFile = Paths.get("bash", "flank-scripts.jar").toFile()
ant.invokeMethod("get", mapOf("src" to sourceUrl, "dest" to destinationFile))
val download by tasks.registering(Exec::class) {
commandLine(
"gh", "release", "download", "flank-scripts-$version", "-D", System.getenv("GITHUB_WORKSPACE") ?: ".."
)
doLast {
Files.copy(
Paths.get( "$artifactID.jar"),
Paths.get("flank-scripts","bash", "$artifactID.jar")
)
}
}

val checkIfVersionUpdated by tasks.registering(Exec::class) {
Expand All @@ -160,6 +151,17 @@ val checkIfVersionUpdated by tasks.registering(Exec::class) {
}
}

val releaseFlankScripts by tasks.registering(Exec::class) {
dependsOn(":flank-scripts:publish")
commandLine(
"gh", "release", "create",
"flank-scripts-$version", "$buildDir/libs/$artifactID.jar",
"-t", "'Flank Scripts $version'",
"-p"
)
}


fun isVersionChangedInBuildGradle(): Boolean {

val localResultsStream = execAndGetStdout("git", "diff", "origin/master", "HEAD", "--", "build.gradle.kts")
Expand Down