Skip to content

Commit 0e91280

Browse files
committed
Merge branch 'b2-sdk-java/master' into 'b2-sdk-java-private/master'
2 parents 641627a + 01da4d1 commit 0e91280

File tree

8 files changed

+132
-9
lines changed

8 files changed

+132
-9
lines changed

.github/workflows/.ci_cd.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ jobs:
3636
java-version: '8'
3737
cache: 'gradle'
3838

39+
- uses: gradle/wrapper-validation-action@v1
3940
- name: Set up Python ${{ env.PYTHON_DEFAULT_VERSION }}
4041
uses: actions/setup-python@v2
4142
with:
@@ -64,7 +65,7 @@ jobs:
6465
zip -r $GITHUB_WORKSPACE/build/${{ env.OUTPUT_ZIP }} *
6566
6667
- name: Deploy to internal Maven repo
67-
if: github.ref == 'refs/heads/master'
68+
if: github.ref == 'refs/heads/master' && github.repository == 'Backblaze/b2-sdk-java-private'
6869
run: $GITHUB_WORKSPACE/gradlew publishMavenPublicationToBzGithubPackagesRepository
6970
env:
7071
ORG_GRADLE_PROJECT_bzGithubPackagesUsername: ${{ secrets.PACKAGES_USERNAME }}

.github/workflows/deploy.yml

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# Copyright 2022, Backblaze Inc. All Rights Reserved.
2+
# License https://www.backblaze.com/using_b2_code.html
3+
4+
name: b2-sdk-java Maven Central deployment
5+
on:
6+
push:
7+
tags: ['v*']
8+
9+
jobs:
10+
deploy:
11+
name: Deploy
12+
if: github.repository == 'Backblaze/b2-sdk-java'
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v2
16+
with:
17+
fetch-depth: 0
18+
19+
- name: Use jdk8
20+
uses: actions/setup-java@v2
21+
with:
22+
distribution: 'adopt'
23+
java-version: '8'
24+
cache: 'gradle'
25+
26+
- uses: gradle/wrapper-validation-action@v1
27+
- name: Deploy to Maven Central
28+
run: ./gradlew publishToSonatype closeAndReleaseSonatypeStagingRepository createBundle --no-daemon --stacktrace
29+
env:
30+
RELEASE_BUILD: true
31+
GPG_SIGNING_KEY: ${{ secrets.GPG_SIGNING_KEY }}
32+
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
33+
ORG_GRADLE_PROJECT_sonatypeUsername: ${{ secrets.SONATYPE_USERNAME }}
34+
ORG_GRADLE_PROJECT_sonatypePassword: ${{ secrets.SONATYPE_PASSWORD }}
35+
36+
- name: Cleanup Gradle Cache
37+
# Remove some files from the Gradle cache, so they aren't cached by GitHub Actions.
38+
# Restoring these files from a GitHub Actions cache might cause problems for future builds.
39+
run: |
40+
rm -f ~/.gradle/caches/modules-2/modules-2.lock
41+
rm -fr ~/.gradle/caches/*/plugin-resolution/
42+
43+
- name: Get tag name
44+
id: get_tag
45+
shell: bash
46+
run: |
47+
tag_name="$(echo $GITHUB_REF | cut -d / -f 3)"
48+
echo ::set-output name=tag::$tag_name
49+
- name: Create GitHub Release
50+
uses: softprops/action-gh-release@v1
51+
env:
52+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
53+
with:
54+
tag_name: ${{ steps.get_tag.outputs.tag }}
55+
name: ${{ steps.get_tag.outputs.tag }}
56+
prerelease: false
57+
draft: false
58+
files: |
59+
core/build/libs/bundle-*.jar
60+
httpclient/build/libs/bundle-*.jar
61+
samples/build/libs/bundle-*.jar

build.gradle.kts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
1-
// This file is empty as we don't need any project configuration at this level.
2-
// However, some tools don't work unless there is a build.gradle.kts file present,
3-
// as they don't know to look for settings.gradle.kts too. So this file is here just
4-
// to satisfy those tools.
1+
plugins {
2+
id("io.github.gradle-nexus.publish-plugin") version "1.1.0"
3+
}
4+
5+
nexusPublishing {
6+
repositories {
7+
sonatype {
8+
nexusUrl.set(uri("https://oss.sonatype.org/service/local/"))
9+
}
10+
}
11+
}

buildSrc/build.gradle.kts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,26 @@
11
// Copyright 2021, Backblaze Inc. All Rights Reserved.
22
// License https://www.backblaze.com/using_b2_code.html
33

4+
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
5+
46
plugins {
57
`kotlin-dsl`
68
}
79

810
repositories {
911
mavenCentral()
1012
}
13+
14+
java {
15+
toolchain {
16+
languageVersion.set(JavaLanguageVersion.of(11))
17+
}
18+
}
19+
20+
tasks.withType<JavaCompile>().configureEach {
21+
options.release.set(8)
22+
}
23+
24+
tasks.withType<KotlinCompile>().configureEach {
25+
kotlinOptions.jvmTarget = "1.8"
26+
}

buildSrc/src/main/kotlin/b2sdk.gradle.kts

Lines changed: 40 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@
22
// License https://www.backblaze.com/using_b2_code.html
33

44
import org.gradle.api.credentials.PasswordCredentials
5+
import org.gradle.api.publish.internal.PublicationInternal
56

67
plugins {
78
java
9+
signing
810
`maven-publish`
911
}
1012

@@ -87,9 +89,13 @@ publishing {
8789
groupId = project.group.toString()
8890
artifactId = project.name
8991

90-
version = when (val buildNum = providers.environmentVariable("BUILD_NUMBER").forUseAtConfigurationTime().orNull) {
91-
null -> project.version.toString()
92-
else -> "${project.version}+$buildNum"
92+
if (System.getenv("RELEASE_BUILD") != null) {
93+
version = project.version.toString()
94+
} else {
95+
version = when (val buildNum = System.getenv("BUILD_NUMBER")) {
96+
null -> project.version.toString()
97+
else -> "${project.version}+$buildNum"
98+
}
9399
}
94100

95101
withoutBuildIdentifier()
@@ -133,3 +139,34 @@ publishing {
133139
}
134140
}
135141
}
142+
143+
val sonatypeUsername = findProperty("sonatypeUsername")
144+
val sonatypePassword = findProperty("sonatypePassword")
145+
146+
val gpgSigningKey = System.getenv("GPG_SIGNING_KEY")
147+
val gpgPassphrase = System.getenv("GPG_PASSPHRASE")
148+
149+
signing {
150+
setRequired {
151+
gradle.taskGraph.hasTask("publishToSonatype") || gradle.taskGraph.hasTask("createBundle")
152+
}
153+
154+
if (gpgSigningKey != null && gpgPassphrase != null) {
155+
useInMemoryPgpKeys(gpgSigningKey, gpgPassphrase)
156+
} else {
157+
useGpgCmd()
158+
}
159+
160+
sign(publishing.publications["maven"])
161+
}
162+
163+
tasks.register<Jar>("createBundle") {
164+
archiveBaseName.set("bundle-for-${project.name}")
165+
from((project.publishing.publications["maven"] as PublicationInternal<*>).publishableArtifacts.files) {
166+
rename {
167+
it
168+
.replace("pom-default.xml", "${project.name}-${project.version}.pom")
169+
.replace("module.json", "${project.name}-${project.version}.module")
170+
}
171+
}
172+
}

gradle/wrapper/gradle-wrapper.jar

285 Bytes
Binary file not shown.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-bin.zip
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists

httpclient/build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,6 @@ dependencies {
2222
because("earlier versions have a known vulnerability")
2323
}
2424
}
25+
2526
api("commons-logging:commons-logging:1.2")
2627
}

0 commit comments

Comments
 (0)