Skip to content

Commit

Permalink
Updated github workflow for dispatch release
Browse files Browse the repository at this point in the history
  • Loading branch information
sksamuel committed Aug 10, 2020
1 parent 2e439ff commit 47520a3
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 24 deletions.
66 changes: 66 additions & 0 deletions .github/workflows/release.yml
@@ -0,0 +1,66 @@
name: release

on:
workflow_dispatch:
inputs:
version:
description: "The release version"
required: true

jobs:
deploy-linux-and-common:
runs-on: ubuntu-latest

steps:
- name: Checkout the repo
uses: actions/checkout@v2
with:
fetch-depth: 0

- name: deploy to sonatype
run: ./gradlew publish
env:
RELEASE_VERSION: ${{ github.event.inputs.version }}
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}
ORG_GRADLE_PROJECT_signingKey: ${{ secrets.SIGNING_KEY }}
ORG_GRADLE_PROJECT_signingPassword: ${{ secrets.SIGNING_PASSWORD }}

deploy-mac:
runs-on: macOS-latest

steps:
- name: Checkout the repo
uses: actions/checkout@v2
with:
fetch-depth: 0

- name: deploy to sonatype
run: ./gradlew publishMacosX64PublicationToDeployRepository
env:
RELEASE_VERSION: ${{ github.event.inputs.version }}
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}
ORG_GRADLE_PROJECT_signingKey: ${{ secrets.SIGNING_KEY }}
ORG_GRADLE_PROJECT_signingPassword: ${{ secrets.SIGNING_PASSWORD }}

deploy-windows:
runs-on: windows-latest

steps:
- name: Checkout the repo
uses: actions/checkout@v2
with:
fetch-depth: 0

- name: deploy to sonatype
run: ./gradlew publishMingwX64PublicationToDeployRepository
env:
RELEASE_VERSION: ${{ github.event.inputs.version }}
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}
ORG_GRADLE_PROJECT_signingKey: ${{ secrets.SIGNING_KEY }}
ORG_GRADLE_PROJECT_signingPassword: ${{ secrets.SIGNING_PASSWORD }}

env:
GRADLE_OPTS: -Dorg.gradle.configureondemand=true -Dorg.gradle.parallel=true -Dkotlin.incremental=false -Dorg.gradle.jvmargs="-Xmx3g -XX:MaxPermSize=2048m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8"
33 changes: 9 additions & 24 deletions buildSrc/src/main/kotlin/Ci.kt
@@ -1,33 +1,18 @@
object Ci {

private const val lastRelease = "4.1.2"

// this is the version used for building snapshots
// .buildnumber-snapshot will be appended
private const val snapshotBase = "4.2.0"

private val githubBuildNumber: String = System.getenv("GITHUB_RUN_NUMBER") ?: "0"
private val snapshotVersion = "$snapshotBase.${githubBuildNumber}-SNAPSHOT"

private val releaseTag = detectReleaseTag().apply {
println("Release tag: $this")
}
private val githubBuildNumber = System.getenv("GITHUB_RUN_NUMBER")

private fun detectReleaseTag(): String? {
return try {
val process = Runtime.getRuntime().exec("git log -1 --pretty=%B")
val reader = process.inputStream.bufferedReader()
val tag: String? = reader.readLine()
if (tag != null && tag.isNotBlank() && tag.trim().startsWith("v")) tag.trim().removePrefix("v") else null
} catch (e: Exception) {
println("git tag failed " + e.message)
e.printStackTrace()
null
}
private val snapshotVersion = when (githubBuildNumber) {
null -> "$snapshotBase-LOCAL"
else -> "$snapshotBase.${githubBuildNumber}-SNAPSHOT"
}

val isRelease = releaseTag != null
private val releaseVersion = System.getenv("RELEASE_VERSION")

val publishVersion: String = when (releaseTag) {
null -> snapshotVersion
else -> releaseTag
}
val isRelease = releaseVersion != null
val publishVersion = releaseVersion ?: snapshotVersion
}

0 comments on commit 47520a3

Please sign in to comment.