Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
103 changes: 0 additions & 103 deletions .github/workflows/.ci_cd.yml

This file was deleted.

104 changes: 104 additions & 0 deletions .github/workflows/ci_cd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
# Copyright 2022, Backblaze Inc. All Rights Reserved.
# License https://www.backblaze.com/using_b2_code.html

name: b2-sdk-java ci/cd

on:
push:
pull_request:
branches:
- master
- api-v2
- 7.x # TODO: This is temporary and will be removed once we merge this branch to master branch

env:
OUTPUT_DIR: $GITHUB_WORKSPACE/build/outputs
OUTPUT_ZIP: b2-sdk-build-${GITHUB_RUN_NUMBER}.zip
BUILD_NUMBER: ${{ github.run_number }}
# These are stored in Bitwarden
B2_ACCOUNT_ID: ${{ secrets.B2_ACCOUNT_ID }}
B2_UPLOAD_BUCKET: ${{ secrets.B2_UPLOAD_BUCKET }}
B2_APPLICATION_KEY: ${{ secrets.B2_APPLICATION_KEY }}

jobs:
build:
runs-on: ${{ github.repository == 'Backblaze/b2-sdk-java-private' && 'self-hosted'|| 'ubuntu-latest' }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '11'

- uses: gradle/actions/wrapper-validation@v4
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4

- name: Set up Python
run: |
python3.8 -m venv env
source env/bin/activate
echo "VIRTUAL ENV:" $VIRTUAL_ENV
# upgrade pip and setuptools so that b2 CLI can be properly installed
pip install --upgrade pip setuptools
pip install b2 pysqlite3

- name: Build the distribution
run: |
$GITHUB_WORKSPACE/gradlew build
#
# Prepare the outputs
#

# make the directory
mkdir -p ${{ env.OUTPUT_DIR }}
cp -v */build/libs/b2-sdk-*.{jar,pom,module} ${{ env.OUTPUT_DIR }}

# zip up the outputs
cd ${{ env.OUTPUT_DIR }}
zip -r $GITHUB_WORKSPACE/build/${{ env.OUTPUT_ZIP }} *

- name: Deploy to internal Maven repo
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'
run: $GITHUB_WORKSPACE/gradlew publishMavenPublicationToRemoteRepository
env:
ORG_GRADLE_PROJECT_remoteUsername: ${{ secrets.ARTIFACTORY_USERNAME }}
ORG_GRADLE_PROJECT_remotePassword: ${{ secrets.ARTIFACTORY_TOKEN }}
ORG_GRADLE_PROJECT_publishingUrl: "${{ secrets.JF }}/maven-private/"

- name: Deploy to GH packages
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'
run: $GITHUB_WORKSPACE/gradlew publishMavenPublicationToRemoteRepository
env:
ORG_GRADLE_PROJECT_remoteUsername: ${{ secrets.PACKAGES_USERNAME }}
ORG_GRADLE_PROJECT_remotePassword: ${{ secrets.PACKAGES_TOKEN }}
ORG_GRADLE_PROJECT_publishingUrl: "https://maven.pkg.github.com/Backblaze/repo"

- name: Upload to b2
if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/api-v2' || github.ref == 'refs/heads/7.x'
# upload to b2 (if credentials are provided, as they will be for backblaze's builds, but not pull requests)
# This should be using python 3.8
run: |
source $GITHUB_WORKSPACE/env/bin/activate
$GITHUB_WORKSPACE/maybe_upload_build_results ${{ env.OUTPUT_ZIP }}

- name: Check GitHub Pages status
if: github.ref == 'refs/heads/master'
uses: crazy-max/ghaction-github-status@v4
with:
pages_threshold: major_outage

- name: Deploy Javadoc
# note that i'm only uploading the javadocs for b2-sdk-core.
# that's because i'm lame and building separate javadocs for
# each jar and only uploading one set of javadocs.
if: (github.ref == 'refs/heads/master' || github.ref == 'refs/heads/api-v2' || github.ref == 'refs/heads/7.x') && success()
uses: crazy-max/ghaction-github-pages@v3
with:
target_branch: gh-pages
build_dir: core/build/docs/javadoc
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
25 changes: 10 additions & 15 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,19 @@ jobs:
if: github.repository == 'Backblaze/b2-sdk-java'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Use jdk8
uses: actions/setup-java@v2
- uses: actions/setup-java@v4
with:
distribution: 'adopt'
java-version: '8'
cache: 'gradle'
distribution: 'temurin'
java-version: '11'
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this make the minimum Java version 11 for anyone depending on this library?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, this is just changing the minimum java version on the worker that runs the ci_cd build.


- uses: gradle/actions/wrapper-validation@v4
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4

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

- name: Cleanup Gradle Cache
# Remove some files from the Gradle cache, so they aren't cached by GitHub Actions.
# Restoring these files from a GitHub Actions cache might cause problems for future builds.
run: |
rm -f ~/.gradle/caches/modules-2/modules-2.lock
rm -fr ~/.gradle/caches/*/plugin-resolution/

- name: Get tag name
id: get_tag
shell: bash
run: |
tag_name="$(echo $GITHUB_REF | cut -d / -f 3)"
echo ::set-output name=tag::$tag_name

- name: Create GitHub Release
uses: softprops/action-gh-release@v1
uses: softprops/action-gh-release@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
Expand Down
19 changes: 12 additions & 7 deletions buildSrc/src/main/kotlin/b2sdk.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,10 @@ publishing {
groupId = project.group.toString()
artifactId = project.name

if (System.getenv("RELEASE_BUILD") != null) {
version = project.version.toString()
version = if (System.getenv("RELEASE_BUILD") != null) {
project.version.toString()
} else {
version = when (val buildNum = System.getenv("BUILD_NUMBER")) {
when (val buildNum = System.getenv("BUILD_NUMBER")) {
null -> project.version.toString()
else -> "${project.version}+$buildNum"
}
Expand Down Expand Up @@ -134,8 +134,13 @@ publishing {
}

repositories {
maven("https://maven.pkg.github.com/Backblaze/repo") {
name = "bzGithubPackages"
var publishingUrl = findProperty("publishingUrl")
if (publishingUrl == null) {
publishingUrl = "https://maven.pkg.github.com/Backblaze/repo"
}

maven(publishingUrl.toString()) {
name = "remote"
credentials(PasswordCredentials::class)
}
}
Expand All @@ -144,8 +149,8 @@ publishing {
val sonatypeUsername = findProperty("sonatypeUsername")
val sonatypePassword = findProperty("sonatypePassword")

val gpgSigningKey = System.getenv("GPG_SIGNING_KEY")
val gpgPassphrase = System.getenv("GPG_PASSPHRASE")
val gpgSigningKey: String? = System.getenv("GPG_SIGNING_KEY")
val gpgPassphrase: String? = System.getenv("GPG_PASSPHRASE")

if (sonatypeUsername != null && sonatypePassword != null) {
signing {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ public interface B2Capabilities {

String READ_BUCKET_ENCRYPTION = "readBucketEncryption";
String WRITE_BUCKET_ENCRYPTION = "writeBucketEncryption";

String READ_BUCKET_LOGGING = "readBucketLogging";
String WRITE_BUCKET_LOGGING = "writeBucketLogging";

String BYPASS_GOVERNANCE = "bypassGovernance";
String READ_BUCKET_RETENTIONS = "readBucketRetentions";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ public void testEquals() {
capabilities.add(B2Capabilities.WRITE_BUCKET_RETENTIONS);
capabilities.add(B2Capabilities.READ_FILE_RETENTIONS);
capabilities.add(B2Capabilities.WRITE_FILE_RETENTIONS);
capabilities.add(B2Capabilities.READ_BUCKET_LOGGING);
capabilities.add(B2Capabilities.WRITE_BUCKET_LOGGING);
capabilities.add(B2Capabilities.READ_FILE_LEGAL_HOLDS);
capabilities.add(B2Capabilities.WRITE_FILE_LEGAL_HOLDS);
capabilities.add(B2Capabilities.READ_BUCKET_REPLICATIONS);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@ public CloseableHttpClient create() throws B2Exception {
.setUserAgent(APACHE_HTTP_CLIENT_USER_AGENT)
.setConnectionManager(connectionManager)
.setDefaultRequestConfig(requestConfig)
// Allow connections to be idle for up to 4 seconds before not reusing. This strategy is needed
// because we are seeing connections being closed by the server after 4 seconds, then when we attempt
// to use, the call fails.
.setKeepAliveStrategy((httpResponse, httpContext) -> 4000)
.build();
}

Expand Down
Loading