Skip to content

Commit

Permalink
Release publishing
Browse files Browse the repository at this point in the history
  • Loading branch information
cretz committed Sep 10, 2024
1 parent 5ddbdef commit 266070c
Show file tree
Hide file tree
Showing 2 changed files with 151 additions and 0 deletions.
91 changes: 91 additions & 0 deletions .github/workflows/prepare-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
name: Prepare Release
on:
pull_request:

env:
NEXUS_SDK_REF: release-publishing
NEXUS_SDK_TAG: v0.1.0-alpha1
# workflow_dispatch:
# inputs:
# tag:
# type: string
# description: "Release version tag (e.g. v1.2.3)"
# required: true
# ref:
# type: string
# description: "Git ref from which to release"
# required: true
# default: "main"
# do_publish_jars:
# type: boolean
# description: "Publish Java artifacts for staging"
# required: true
# default: "true"
# env:
# NEXUS_SDK_REF: ${{ github.event.inputs.ref }}
# NEXUS_SDK_TAG: ${{ github.event.inputs.tag }}

jobs:
create_draft_release:
name: Create Github draft release
runs-on: ubuntu-latest
steps:
- name: Audit gh version
run: gh --version

- name: Check for existing release
id: check_release
run: |
echo "::echo::on"
gh release view --repo "$GITHUB_REPOSITORY" "$NEXUS_SDK_TAG" \
&& echo "::set-output name=already_exists::true" \
|| echo "::set-output name=already_exists::false"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Checkout repo
if: steps.check_release.outputs.already_exists == 'false'
uses: actions/checkout@v4
with:
ref: ${{ env.NEXUS_SDK_REF }}

- name: Create release
if: steps.check_release.outputs.already_exists == 'false'
run: >
gh release create
"$NEXUS_SDK_REF"
--draft
--repo "$GITHUB_REPOSITORY"
--title "$NEXUS_SDK_TAG"
--target "$NEXUS_SDK_REF"
--generate-notes
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

publish_java_artifacts:
name: Publish Java artifacts
# if: ${{ github.event.inputs.do_publish_jars == 'true' }}
runs-on: ubuntu-latest
needs: create_draft_release
steps:
- name: Checkout repo
uses: actions/checkout@v4
with:
ref: ${{ env.NEXUS_SDK_REF }}

- name: Set up Java
uses: actions/setup-java@v4
with:
java-version: "11"
distribution: "temurin"

- name: Set up Gradle
uses: gradle/actions/setup-gradle@v3

- name: Stage
run: ./gradlew nexus-sdk:publishToMavenCentral --no-configuration-cache
env:
ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.MAVEN_CENTRAL_USERNAME }}
ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.MAVEN_CENTRAL_PASSWORD }}
ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.SIGNING_IN_MEMORY_KEY }}
ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.SIGNING_IN_MEMORY_KEY_PASSWORD }}
60 changes: 60 additions & 0 deletions nexus-sdk/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
plugins {
id 'java-library'
id 'com.diffplug.spotless'
id 'com.vanniktech.maven.publish' version '0.29.0'
}

dependencies {
Expand Down Expand Up @@ -30,3 +31,62 @@ spotless {
}

classes.dependsOn 'spotlessApply'

ext.getVersionName = { ->
def version = System.getenv('NEXUS_SDK_TAG')
if (version == null || version.isEmpty()) {
return null
}

// Remove "v" prefix if present
if (version.startsWith("v")) {
version = version.substring(1)
}
return version
}

group = 'io.nexusrpc'
version = getVersionName()

import com.vanniktech.maven.publish.SonatypeHost

mavenPublishing {
publishToMavenCentral(SonatypeHost.CENTRAL_PORTAL)

signAllPublications()

pom {
name = 'Nexus Java SDK'
description = 'Java SDK for working with Nexus RPC'
url = 'https://github.com/nexus-rpc/sdk-java'
licenses {
license {
name = 'MIT License'
url = 'https://opensource.org/license/mit'
}
}
scm {
connection = 'scm:git@github.com:nexus-rpc/sdk-java.git'
developerConnection = 'scm:git@github.com:nexus-rpc/sdk-java.git'
url = 'https://github.com/nexus-rpc/sdk-java.git'
}
developers {
developer {
id = 'team-sdk'
name = 'Temporal.io SDK Team'
email = 'team-sdk@temporal.io'
}
}
}
}

// Make sure there is a tag at publish time
tasks.whenTaskAdded { task ->
if (task.name == 'generateMetadataFileForMavenPublication') {
task.doFirst {
if (getVersionName() == null) {
throw new GradleException('Must set NEXUS_SDK_TAG env var')
}
}
}
}

0 comments on commit 266070c

Please # to comment.