Skip to content

Commit

Permalink
Add release workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
Anuraag Agrawal committed Oct 6, 2021
1 parent 2cec180 commit f08ae9c
Show file tree
Hide file tree
Showing 7 changed files with 140 additions and 6 deletions.
38 changes: 38 additions & 0 deletions .github/workflows/main-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: "Main Build"

on:
push:
branches:
- main

jobs:
build:
name: Build
runs-on: ubuntu-20.04
steps:
- uses: actions/[email protected]
with:
fetch-depth: 0
- id: setup-java-17
name: Setup Java 17
uses: actions/setup-java@v2
with:
distribution: adopt
java-version: 17
- uses: burrunan/[email protected]
with:
remote-build-cache-proxy-enabled: false
arguments: build --stacktrace
properties: |
org.gradle.java.installations.paths=${{ steps.setup-java-17.outputs.path }}
- uses: burrunan/[email protected]
with:
remote-build-cache-proxy-enabled: false
arguments: snapshot --stacktrace
properties: |
org.gradle.java.installations.paths=${{ steps.setup-java-17.outputs.path }}
env:
SONATYPE_USER: ${{ secrets.SONATYPE_USER }}
SONATYPE_KEY: ${{ secrets.SONATYPE_KEY }}
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
GPG_PASSWORD: ${{ secrets.GPG_PASSWORD }}
27 changes: 27 additions & 0 deletions .github/workflows/pr-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: "PR Build"

on:
pull_request:
branches:
- main

jobs:
build:
name: Build
runs-on: ubuntu-20.04
steps:
- uses: actions/[email protected]
with:
fetch-depth: 0
- id: setup-java-17
name: Setup Java 17
uses: actions/setup-java@v2
with:
distribution: adopt
java-version: 17
- uses: burrunan/[email protected]
with:
remote-build-cache-proxy-enabled: false
arguments: build --stacktrace
properties: |
org.gradle.java.installations.paths=${{ steps.setup-java-17.outputs.path }}
46 changes: 46 additions & 0 deletions .github/workflows/release-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: "Release Build"

on:
workflow_dispatch:
inputs:
version:
description: The version to tag the release with, e.g., 1.2.0, 1.2.1-alpha.1
required: true

jobs:
build:
name: Build
runs-on: ubuntu-20.04
steps:
- uses: actions/[email protected]
with:
fetch-depth: 0
- id: setup-java-17
name: Setup Java 17
uses: actions/setup-java@v2
with:
distribution: adopt
java-version: 17
- uses: burrunan/[email protected]
with:
remote-build-cache-proxy-enabled: false
arguments: build --stacktrace
properties: |
release.version=${{ github.event.inputs.version }}
org.gradle.java.installations.paths=${{ steps.setup-java-17.outputs.path }}
- uses: burrunan/[email protected]
with:
remote-build-cache-proxy-enabled: false
arguments: final closeAndReleaseSonatypeStagingRepository --stacktrace
properties: |
release.version=${{ github.event.inputs.version }}
org.gradle.java.installations.paths=${{ steps.setup-java-17.outputs.path }}
env:
SONATYPE_USER: ${{ secrets.SONATYPE_USER }}
SONATYPE_KEY: ${{ secrets.SONATYPE_KEY }}
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
GPG_PASSWORD: ${{ secrets.GPG_PASSWORD }}
- run: |
gh release create ${{ github.events.inputs.version }} \
--title ${{ github.events.inputs.version }}-alpha \
--notes "Java Bindings for [OTLP ${{ github.events.inputs.version }}](https://github.com/open-telemetry/opentelemetry-proto/releases/tag/${{ github.events.inputs.version }})"
20 changes: 16 additions & 4 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,17 +1,29 @@
import com.google.protobuf.gradle.*
import de.undercouch.gradle.tasks.download.Download
import de.undercouch.gradle.tasks.download.Verify
import nebula.plugin.release.git.opinion.Strategies
import java.time.Duration

plugins {
id("com.google.protobuf")
id("de.undercouch.download")
id("io.github.gradle-nexus.publish-plugin")
id("nebula.release")

id("otel.java-conventions")
id("otel.publish-conventions")
}

release {
defaultVersionStrategy = Strategies.getSNAPSHOT()
}

tasks {
named("release") {
mustRunAfter("snapshotSetup", "finalSetup")
}
}

description = "Java Bindings for the OpenTelemetry Protocol (OTLP)"

val grpcVersion = "1.41.0"
Expand All @@ -29,9 +41,9 @@ dependencies {
// see: https://github.com/grpc/grpc-java/issues/3633
compileOnly("javax.annotation:javax.annotation-api:1.3.2")

compileOnly("io.grpc:grpc-api:${grpcVersion}")
compileOnly("io.grpc:grpc-protobuf:${grpcVersion}")
compileOnly("io.grpc:grpc-stub:${grpcVersion}")
compileOnly("io.grpc:grpc-api:$grpcVersion")
compileOnly("io.grpc:grpc-protobuf:$grpcVersion")
compileOnly("io.grpc:grpc-stub:$grpcVersion")
}

protobuf {
Expand All @@ -53,7 +65,7 @@ protobuf {
}
}

val protoVersion = version.toString().removeSuffix("-alpha")
val protoVersion = version.toString().removeSuffix("-SNAPSHOT").removeSuffix("-alpha")
// To generate checksum, download the file and run "shasum -a 256 ~/path/to/vfoo.zip"
val protoChecksum = "5e4131064e9471eb09294374db0d55028fdb73898b08aa07a835d17d61e5f017"
val protoArchive = file("$buildDir/archives/opentelemetry-proto-$protoVersion.zip")
Expand Down
12 changes: 12 additions & 0 deletions buildSrc/src/main/kotlin/otel.publish-conventions.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,15 @@ plugins {
publishing {
publications {
register<MavenPublication>("mavenPublication") {
val publication = this
groupId = "io.opentelemetry.proto"
afterEvaluate {
// not available until evaluated.
artifactId = base.archivesName.get()
pom.description.set(project.description)
val versionParts = publication.version.split('-').toMutableList()
versionParts[0] += "-alpha"
publication.version = versionParts.joinToString("-")
}

plugins.withId("java-platform") {
Expand Down Expand Up @@ -55,6 +59,14 @@ publishing {
}
}

afterEvaluate {
val publishToSonatype by tasks.getting
val release by rootProject.tasks.existing
release.configure {
finalizedBy(publishToSonatype)
}
}

if (System.getenv("CI") != null) {
signing {
useInMemoryPgpKeys(System.getenv("GPG_PRIVATE_KEY"), System.getenv("GPG_PASSWORD"))
Expand Down
2 changes: 0 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
version = 0.9.0-alpha

org.gradle.parallel=true
org.gradle.caching=true

Expand Down
1 change: 1 addition & 0 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ pluginManagement {
id("com.google.protobuf") version "0.8.17"
id("de.undercouch.download") version "4.1.2"
id("io.github.gradle-nexus.publish-plugin") version "1.1.0"
id("nebula.release") version "16.0.0"
}
}

Expand Down

0 comments on commit f08ae9c

Please sign in to comment.