Skip to content

Commit e3c1b20

Browse files
authored
Merge pull request #207 from Backblaze/mergePrivateChangesBranch
Merge private changes branch
2 parents c197e20 + 77f9efa commit e3c1b20

File tree

7 files changed

+135
-125
lines changed

7 files changed

+135
-125
lines changed

.github/workflows/.ci_cd.yml

Lines changed: 0 additions & 103 deletions
This file was deleted.

.github/workflows/ci_cd.yml

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
# Copyright 2022, Backblaze Inc. All Rights Reserved.
2+
# License https://www.backblaze.com/using_b2_code.html
3+
4+
name: b2-sdk-java ci/cd
5+
6+
on:
7+
push:
8+
pull_request:
9+
branches:
10+
- master
11+
- api-v2
12+
- 7.x # TODO: This is temporary and will be removed once we merge this branch to master branch
13+
14+
env:
15+
OUTPUT_DIR: $GITHUB_WORKSPACE/build/outputs
16+
OUTPUT_ZIP: b2-sdk-build-${GITHUB_RUN_NUMBER}.zip
17+
BUILD_NUMBER: ${{ github.run_number }}
18+
# These are stored in Bitwarden
19+
B2_ACCOUNT_ID: ${{ secrets.B2_ACCOUNT_ID }}
20+
B2_UPLOAD_BUCKET: ${{ secrets.B2_UPLOAD_BUCKET }}
21+
B2_APPLICATION_KEY: ${{ secrets.B2_APPLICATION_KEY }}
22+
23+
jobs:
24+
build:
25+
runs-on: ${{ github.repository == 'Backblaze/b2-sdk-java-private' && 'self-hosted'|| 'ubuntu-latest' }}
26+
steps:
27+
- uses: actions/checkout@v4
28+
with:
29+
fetch-depth: 0
30+
31+
- uses: actions/setup-java@v4
32+
with:
33+
distribution: 'temurin'
34+
java-version: '11'
35+
36+
- uses: gradle/actions/wrapper-validation@v4
37+
- name: Setup Gradle
38+
uses: gradle/actions/setup-gradle@v4
39+
40+
- name: Set up Python
41+
run: |
42+
python3.8 -m venv env
43+
source env/bin/activate
44+
echo "VIRTUAL ENV:" $VIRTUAL_ENV
45+
# upgrade pip and setuptools so that b2 CLI can be properly installed
46+
pip install --upgrade pip setuptools
47+
pip install b2 pysqlite3
48+
49+
- name: Build the distribution
50+
run: |
51+
$GITHUB_WORKSPACE/gradlew build
52+
#
53+
# Prepare the outputs
54+
#
55+
56+
# make the directory
57+
mkdir -p ${{ env.OUTPUT_DIR }}
58+
cp -v */build/libs/b2-sdk-*.{jar,pom,module} ${{ env.OUTPUT_DIR }}
59+
60+
# zip up the outputs
61+
cd ${{ env.OUTPUT_DIR }}
62+
zip -r $GITHUB_WORKSPACE/build/${{ env.OUTPUT_ZIP }} *
63+
64+
- name: Deploy to internal Maven repo
65+
if: (github.ref == 'refs/heads/master' || github.ref == 'refs/heads/api-v2' || github.ref == 'refs/heads/7.x') && github.repository == 'Backblaze/b2-sdk-java-private'
66+
run: $GITHUB_WORKSPACE/gradlew publishMavenPublicationToRemoteRepository
67+
env:
68+
ORG_GRADLE_PROJECT_remoteUsername: ${{ secrets.ARTIFACTORY_USERNAME }}
69+
ORG_GRADLE_PROJECT_remotePassword: ${{ secrets.ARTIFACTORY_TOKEN }}
70+
ORG_GRADLE_PROJECT_publishingUrl: "${{ secrets.JF }}/maven-private/"
71+
72+
- name: Deploy to GH packages
73+
if: (github.ref == 'refs/heads/master' || github.ref == 'refs/heads/api-v2' || github.ref == 'refs/heads/7.x') && github.repository == 'Backblaze/b2-sdk-java-private'
74+
run: $GITHUB_WORKSPACE/gradlew publishMavenPublicationToRemoteRepository
75+
env:
76+
ORG_GRADLE_PROJECT_remoteUsername: ${{ secrets.PACKAGES_USERNAME }}
77+
ORG_GRADLE_PROJECT_remotePassword: ${{ secrets.PACKAGES_TOKEN }}
78+
ORG_GRADLE_PROJECT_publishingUrl: "https://maven.pkg.github.com/Backblaze/repo"
79+
80+
- name: Upload to b2
81+
if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/api-v2' || github.ref == 'refs/heads/7.x'
82+
# upload to b2 (if credentials are provided, as they will be for backblaze's builds, but not pull requests)
83+
# This should be using python 3.8
84+
run: |
85+
source $GITHUB_WORKSPACE/env/bin/activate
86+
$GITHUB_WORKSPACE/maybe_upload_build_results ${{ env.OUTPUT_ZIP }}
87+
88+
- name: Check GitHub Pages status
89+
if: github.ref == 'refs/heads/master'
90+
uses: crazy-max/ghaction-github-status@v4
91+
with:
92+
pages_threshold: major_outage
93+
94+
- name: Deploy Javadoc
95+
# note that i'm only uploading the javadocs for b2-sdk-core.
96+
# that's because i'm lame and building separate javadocs for
97+
# each jar and only uploading one set of javadocs.
98+
if: (github.ref == 'refs/heads/master' || github.ref == 'refs/heads/api-v2' || github.ref == 'refs/heads/7.x') && success()
99+
uses: crazy-max/ghaction-github-pages@v3
100+
with:
101+
target_branch: gh-pages
102+
build_dir: core/build/docs/javadoc
103+
env:
104+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/deploy.yml

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,19 @@ jobs:
1212
if: github.repository == 'Backblaze/b2-sdk-java'
1313
runs-on: ubuntu-latest
1414
steps:
15-
- uses: actions/checkout@v2
15+
- uses: actions/checkout@v4
1616
with:
1717
fetch-depth: 0
1818

19-
- name: Use jdk8
20-
uses: actions/setup-java@v2
19+
- uses: actions/setup-java@v4
2120
with:
22-
distribution: 'adopt'
23-
java-version: '8'
24-
cache: 'gradle'
21+
distribution: 'temurin'
22+
java-version: '11'
23+
24+
- uses: gradle/actions/wrapper-validation@v4
25+
- name: Setup Gradle
26+
uses: gradle/actions/setup-gradle@v4
2527

26-
- uses: gradle/wrapper-validation-action@v1
2728
- name: Deploy to Maven Central
2829
run: ./gradlew publishToSonatype closeAndReleaseSonatypeStagingRepository createBundle --no-daemon --stacktrace
2930
env:
@@ -33,21 +34,15 @@ jobs:
3334
ORG_GRADLE_PROJECT_sonatypeUsername: ${{ secrets.SONATYPE_USERNAME }}
3435
ORG_GRADLE_PROJECT_sonatypePassword: ${{ secrets.SONATYPE_PASSWORD }}
3536

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-
4337
- name: Get tag name
4438
id: get_tag
4539
shell: bash
4640
run: |
4741
tag_name="$(echo $GITHUB_REF | cut -d / -f 3)"
4842
echo ::set-output name=tag::$tag_name
43+
4944
- name: Create GitHub Release
50-
uses: softprops/action-gh-release@v1
45+
uses: softprops/action-gh-release@v2
5146
env:
5247
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
5348
with:

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

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -90,10 +90,10 @@ publishing {
9090
groupId = project.group.toString()
9191
artifactId = project.name
9292

93-
if (System.getenv("RELEASE_BUILD") != null) {
94-
version = project.version.toString()
93+
version = if (System.getenv("RELEASE_BUILD") != null) {
94+
project.version.toString()
9595
} else {
96-
version = when (val buildNum = System.getenv("BUILD_NUMBER")) {
96+
when (val buildNum = System.getenv("BUILD_NUMBER")) {
9797
null -> project.version.toString()
9898
else -> "${project.version}+$buildNum"
9999
}
@@ -134,8 +134,13 @@ publishing {
134134
}
135135

136136
repositories {
137-
maven("https://maven.pkg.github.com/Backblaze/repo") {
138-
name = "bzGithubPackages"
137+
var publishingUrl = findProperty("publishingUrl")
138+
if (publishingUrl == null) {
139+
publishingUrl = "https://maven.pkg.github.com/Backblaze/repo"
140+
}
141+
142+
maven(publishingUrl.toString()) {
143+
name = "remote"
139144
credentials(PasswordCredentials::class)
140145
}
141146
}
@@ -144,8 +149,8 @@ publishing {
144149
val sonatypeUsername = findProperty("sonatypeUsername")
145150
val sonatypePassword = findProperty("sonatypePassword")
146151

147-
val gpgSigningKey = System.getenv("GPG_SIGNING_KEY")
148-
val gpgPassphrase = System.getenv("GPG_PASSPHRASE")
152+
val gpgSigningKey: String? = System.getenv("GPG_SIGNING_KEY")
153+
val gpgPassphrase: String? = System.getenv("GPG_PASSPHRASE")
149154

150155
if (sonatypeUsername != null && sonatypePassword != null) {
151156
signing {

core/src/main/java/com/backblaze/b2/client/structures/B2Capabilities.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ public interface B2Capabilities {
3737

3838
String READ_BUCKET_ENCRYPTION = "readBucketEncryption";
3939
String WRITE_BUCKET_ENCRYPTION = "writeBucketEncryption";
40+
41+
String READ_BUCKET_LOGGING = "readBucketLogging";
42+
String WRITE_BUCKET_LOGGING = "writeBucketLogging";
4043

4144
String BYPASS_GOVERNANCE = "bypassGovernance";
4245
String READ_BUCKET_RETENTIONS = "readBucketRetentions";

core/src/test/java/com/backblaze/b2/client/structures/B2ApplicationKeyTest.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ public void testEquals() {
2828
capabilities.add(B2Capabilities.WRITE_BUCKET_RETENTIONS);
2929
capabilities.add(B2Capabilities.READ_FILE_RETENTIONS);
3030
capabilities.add(B2Capabilities.WRITE_FILE_RETENTIONS);
31+
capabilities.add(B2Capabilities.READ_BUCKET_LOGGING);
32+
capabilities.add(B2Capabilities.WRITE_BUCKET_LOGGING);
3133
capabilities.add(B2Capabilities.READ_FILE_LEGAL_HOLDS);
3234
capabilities.add(B2Capabilities.WRITE_FILE_LEGAL_HOLDS);
3335
capabilities.add(B2Capabilities.READ_BUCKET_REPLICATIONS);

httpclient/src/main/java/com/backblaze/b2/client/webApiHttpClient/HttpClientFactoryImpl.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,10 @@ public CloseableHttpClient create() throws B2Exception {
7676
.setUserAgent(APACHE_HTTP_CLIENT_USER_AGENT)
7777
.setConnectionManager(connectionManager)
7878
.setDefaultRequestConfig(requestConfig)
79+
// Allow connections to be idle for up to 4 seconds before not reusing. This strategy is needed
80+
// because we are seeing connections being closed by the server after 4 seconds, then when we attempt
81+
// to use, the call fails.
82+
.setKeepAliveStrategy((httpResponse, httpContext) -> 4000)
7983
.build();
8084
}
8185

0 commit comments

Comments
 (0)