Skip to content

Commit

Permalink
ci: publish flank to maven central (#1614)
Browse files Browse the repository at this point in the history
  • Loading branch information
piotradamczyk5 authored Feb 18, 2021
1 parent 68166db commit 6492914
Show file tree
Hide file tree
Showing 16 changed files with 47 additions and 138 deletions.
32 changes: 13 additions & 19 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ jobs:
echo "MVN_VERSION=$(echo ${GITHUB_REF:11})" >> $GITHUB_ENV
echo "RELEASE_TAG=$(echo ${GITHUB_REF:10})" >> $GITHUB_ENV
else
echo "RELEASE_TAG=flank_snapshot" >> $GITHUB_ENV
echo "MVN_VERSION=flank_snapshot" >> $GITHUB_ENV
echo "RELEASE_TAG=flank-snapshot" >> $GITHUB_ENV
echo "MVN_VERSION=master-SNAPSHOT" >> $GITHUB_ENV
git_short_hash=$(git rev-parse --short "$GITHUB_SHA")
echo "GIT_SHORT_HASH=$(echo $git_short_hash)" >> $GITHUB_ENV
fi;
Expand All @@ -49,26 +49,13 @@ jobs:
echo "$GITHUB_SHA" > ./test_runner/src/main/resources/revision.txt
echo "$RELEASE_TAG" > ./test_runner/src/main/resources/version.txt
- name: Get Jfrog CLI
run: |
brew install jfrog-cli-go
jfrog bt config --user ${{ secrets.JFROG_USER }} --key ${{ secrets.JFROG_API_KEY }} --licenses Apache-2.0
- name: Delete old snapshot
run: flankScripts release delete_snapshot --version=$MVN_VERSION

- name: Gradle Build Flank
uses: eskatos/gradle-command-action@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
HEAD_REF: ${{ github.head_ref }}
with:
arguments: "clean test_runner:build test_runner:shadowJar"

- name: Gradle Upload to bintray
uses: eskatos/gradle-command-action@v1
with:
arguments: "test_runner:bintrayUpload -PJFROG_API_KEY=${{ secrets.JFROG_API_KEY }} -PJFROG_USER=${{ secrets.JFROG_USER }}"

- name: Authenticate to hub
run: |
Expand All @@ -91,21 +78,28 @@ jobs:
run: flankScripts github delete_old_tag --git-tag=$RELEASE_TAG --username=$GITHUB_ACTOR --token=${{ secrets.GITHUB_TOKEN }}

- name: Release snapshot
if: ${{ env.RELEASE_TAG == 'flank_snapshot' }}
if: ${{ env.RELEASE_TAG == 'flank_snapshot' }}
run: flankScripts github make_release --input-file=./test_runner/build/libs/flank.jar --git-tag=$RELEASE_TAG --commit-hash=$GIT_SHORT_HASH --snapshot

- name: Release stable
if: startsWith(github.ref, 'refs/tags/v')
run: flankScripts github make_release --input-file=./test_runner/build/libs/flank.jar --git-tag=$RELEASE_TAG --token=${{ secrets.GITHUB_TOKEN }}

- name: Sync bintray to maven central
run: flankScripts release sync_with_maven_central --maven-tag=$MVN_VERSION
- name: Gradle Upload to MavenCentral
uses: eskatos/gradle-command-action@v1
with:
arguments: |
:test_runner:publishMavenJavaPublicationToMavenCentralRepository
-PMVN_CENTRAL_USER=${{ secrets.MVN_CENTRAL_USER }}
-PMVN_CENTRAL_PASSWORD=${{ secrets.MVN_CENTRAL_PASSWORD }}
-PPGP_SIGNING_KEY=${{ secrets.PGP_SIGNING_KEY }}
closeAndReleaseRepository

- name: Gradle Upload to GitHub packages
uses: eskatos/gradle-command-action@v1
if: startsWith(github.ref, 'refs/tags/v')
with:
arguments: "test_runner:publish -PGITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }}"
arguments: ":test_runner:publishMavenJavaPublicationToGitHubPackagesRepository -PGITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }}"

- name: Post Message of Flank Release
uses: Flank/flank@master
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Flank [![codecov](https://codecov.io/gh/Flank/flank/branch/master/graph/badge.svg)](https://codecov.io/gh/Flank/flank)
# Flank [![codecov](https://codecov.io/gh/Flank/flank/branch/master/graph/badge.svg)](https://codecov.io/gh/Flank/flank) [![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.github.flank/flank/badge.svg)](https://maven-badges.herokuapp.com/maven-central/com.github.flank/flank)

Flank is a [massively parallel Android and iOS test runner](https://docs.google.com/presentation/d/1goan9cXpimSJsS3L60WjljnFA_seUyaWb2e-bezm084/edit#slide=id.p1) for [Firebase Test Lab](https://firebase.google.com/docs/test-lab/).

Expand Down
7 changes: 7 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@ plugins {
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
}

nexusStaging {
username = System.getenv("MVN_CENTRAL_USER") ?: properties["MVN_CENTRAL_USER"].toString()
password = System.getenv("MVN_CENTRAL_PASSWORD") ?: properties["MVN_CENTRAL_PASSWORD"].toString()
packageGroup = "com.github.flank"
}

tasks {
Expand Down
1 change: 1 addition & 0 deletions buildSrc/src/main/kotlin/Plugins.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ object Plugins {
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"
object Kotlin {
const val PLUGIN_JVM = "jvm"
Expand Down
3 changes: 3 additions & 0 deletions buildSrc/src/main/kotlin/Versions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ object Versions {
// 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"

// https://github.com/johnrengelman/shadow/releases
const val SHADOW = "6.1.0"

Expand Down
2 changes: 1 addition & 1 deletion docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -939,7 +939,7 @@ repositories {
}
dependencies {
compile("flank:flank:flank_snapshot")
compile("flank:flank:master-SNAPSHOT")
}
```

Expand Down
5 changes: 2 additions & 3 deletions docs/release_process.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,13 @@ Each push:
## CI Steps
1. Gradle Build flankScripts and add it to PATH
1. Set environment variables
1. Get Jfrog CLI
1. Delete old snapshot
1. Gradle Build Flank
1. Gradle Upload to bintray
1. Authenticate to hub
1. Remove old release
1. Rename old tag
1. Release flank
1. Snapshot for snapshot flow (push to master)
2. Stable for regular flow (push tag `v*`)
12. Sync bintray to maven central
1. Publish binary for Maven Central
1. Publish binary to GithubPackages (non snapshot only)
2 changes: 1 addition & 1 deletion flank-scripts/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ shadowJar.apply {
}
}
// <breaking change>.<feature added>.<fix/minor change>
version = "1.6.2"
version = "1.6.3"
group = "com.github.flank"

application {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ object ReleaseCommand : CliktCommand(
init {
subcommands(
MakeReleaseCommand,
DeleteSnapshotCommand,
SyncWithMavenCentralCommand,
DeleteReleaseCommand,
DeleteOldTagCommand
)
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

47 changes: 18 additions & 29 deletions test_runner/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
import com.jfrog.bintray.gradle.BintrayExtension
import groovy.util.Node
import groovy.util.NodeList
import java.io.ByteArrayOutputStream
import java.nio.file.Paths
import java.util.*
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
import org.gradle.nativeplatform.platform.internal.DefaultNativePlatform
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
Expand All @@ -13,8 +11,8 @@ plugins {
application
jacoco
kotlin(Plugins.Kotlin.PLUGIN_JVM)
id(Plugins.JFROG_BINTRAY)
id(Plugins.MAVEN_PUBLISH)
signing
id(Plugins.PLUGIN_SHADOW_JAR) version Versions.SHADOW
}

Expand Down Expand Up @@ -47,31 +45,6 @@ shadowJar.apply {
}
}

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

java {
withJavadocJar()
withSourcesJar()
Expand All @@ -87,12 +60,22 @@ publishing {
password = System.getenv("GITHUB_TOKEN") ?: properties["GITHUB_TOKEN"].toString()
}
}
maven {
val staging = "https://oss.sonatype.org/service/local/staging/deploy/maven2"
val snapshotsRepoUrl = "https://oss.sonatype.org/content/repositories/snapshots"
url = uri(if (version.toString().endsWith("-SNAPSHOT")) snapshotsRepoUrl else staging)
name = "MavenCentral"
credentials {
username = System.getenv("MVN_CENTRAL_USER") ?: properties["MVN_CENTRAL_USER"].toString()
password = System.getenv("MVN_CENTRAL_PASSWORD") ?: properties["MVN_CENTRAL_PASSWORD"].toString()
}
}
}
publications {
create<MavenPublication>("mavenJava") {
groupId = "com.github.flank"
artifactId = artifactID
version = System.getenv("MVN_VERSION") ?: "local_snapshot"
version = System.getenv("MVN_VERSION") ?: "local-SNAPSHOT"

artifact(shadowJar)
artifact(tasks["javadocJar"])
Expand Down Expand Up @@ -137,6 +120,12 @@ publishing {
}
}

signing {
val pgpSigningKey: String = System.getenv("PGP_SIGNING_KEY") ?: properties["PGP_SIGNING_KEY"].toString()
useInMemoryPgpKeys(pgpSigningKey, "")
sign(publishing.publications["mavenJava"])
}

// http://www.eclemma.org/jacoco/
jacoco {
toolVersion = "0.8.6"
Expand Down

0 comments on commit 6492914

Please sign in to comment.