Skip to content

Commit d4196ea

Browse files
committed
Configure GH Actions to release to Artifactory and release from a feature branch
1 parent 9402969 commit d4196ea

File tree

4 files changed

+49
-56
lines changed

4 files changed

+49
-56
lines changed
Lines changed: 29 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -8,46 +8,43 @@ on:
88
pull_request:
99
branches:
1010
- master
11+
- api-v2
12+
- 7.x # TODO: This is temporary and will be removed once we merge this branch to master branch
1113

1214
env:
13-
PYTHON_DEFAULT_VERSION: 3.8
1415
OUTPUT_DIR: $GITHUB_WORKSPACE/build/outputs
1516
OUTPUT_ZIP: b2-sdk-build-${GITHUB_RUN_NUMBER}.zip
1617
BUILD_NUMBER: ${{ github.run_number }}
17-
# This token was generated under rhryckewicz account
18-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
1918
# These are stored in Bitwarden
2019
B2_ACCOUNT_ID: ${{ secrets.B2_ACCOUNT_ID }}
2120
B2_UPLOAD_BUCKET: ${{ secrets.B2_UPLOAD_BUCKET }}
2221
B2_APPLICATION_KEY: ${{ secrets.B2_APPLICATION_KEY }}
2322

2423
jobs:
2524
build:
26-
runs-on: ubuntu-latest
25+
runs-on: self-hosted
2726
steps:
28-
- uses: actions/checkout@v2
27+
- uses: actions/checkout@v4
2928
with:
3029
fetch-depth: 0
3130

32-
- name: Use jdk8
33-
uses: actions/setup-java@v2
31+
- uses: actions/setup-java@v4
3432
with:
35-
distribution: 'adopt'
36-
java-version: '8'
37-
cache: 'gradle'
33+
distribution: 'temurin'
34+
java-version: '11'
3835

39-
- uses: gradle/wrapper-validation-action@v1
40-
- name: Set up Python ${{ env.PYTHON_DEFAULT_VERSION }}
41-
uses: actions/setup-python@v2
42-
with:
43-
python-version: ${{ env.PYTHON_DEFAULT_VERSION }}
36+
- uses: gradle/actions/wrapper-validation@v4
37+
- name: Setup Gradle
38+
uses: gradle/actions/setup-gradle@v4
4439

45-
- name: Install dependencies
40+
- name: Set up Python
4641
run: |
47-
mkdir -p ~/.gradle && echo "org.gradle.daemon=false" >> ~/.gradle/gradle.properties
42+
python3.8 -m venv env
43+
source env/bin/activate
44+
echo "VIRTUAL ENV:" $VIRTUAL_ENV
4845
# upgrade pip and setuptools so that b2 CLI can be properly installed
49-
python -m pip install --upgrade pip setuptools
50-
python -m pip install b2
46+
pip install --upgrade pip setuptools
47+
pip install b2 pysqlite3
5148
5249
- name: Build the distribution
5350
run: |
@@ -65,37 +62,34 @@ jobs:
6562
zip -r $GITHUB_WORKSPACE/build/${{ env.OUTPUT_ZIP }} *
6663
6764
- name: Deploy to internal Maven repo
68-
if: github.ref == 'refs/heads/master' && github.repository == 'Backblaze/b2-sdk-java-private'
69-
run: $GITHUB_WORKSPACE/gradlew publishMavenPublicationToBzGithubPackagesRepository
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 publishMavenPublicationToBzArtifactoryRepository publishMavenPublicationToBzGithubPackagesRepository
7067
env:
68+
ORG_GRADLE_PROJECT_bzArtifactoryUsername: ${{ secrets.ARTIFACTORY_USERNAME }}
69+
ORG_GRADLE_PROJECT_bzArtifactoryPassword: ${{ secrets.ARTIFACTORY_TOKEN }}
7170
ORG_GRADLE_PROJECT_bzGithubPackagesUsername: ${{ secrets.PACKAGES_USERNAME }}
7271
ORG_GRADLE_PROJECT_bzGithubPackagesPassword: ${{ secrets.PACKAGES_TOKEN }}
7372

74-
- name: Cleanup Gradle Cache
75-
# Remove some files from the Gradle cache, so they aren't cached by GitHub Actions.
76-
# Restoring these files from a GitHub Actions cache might cause problems for future builds.
77-
run: |
78-
rm -f ~/.gradle/caches/modules-2/modules-2.lock
79-
rm -fr ~/.gradle/caches/*/plugin-resolution/
80-
8173
- name: Upload to b2
82-
if: github.ref == 'refs/heads/master'
74+
if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/api-v2' || github.ref == 'refs/heads/7.x'
8375
# upload to b2 (if credentials are provided, as they will be for backblaze's builds, but not pull requests)
84-
# This should be using python 3.4
85-
run: $GITHUB_WORKSPACE/maybe_upload_build_results ${{ env.OUTPUT_ZIP }}
76+
# This should be using python 3.8
77+
run: |
78+
source $GITHUB_WORKSPACE/env/bin/activate
79+
$GITHUB_WORKSPACE/maybe_upload_build_results ${{ env.OUTPUT_ZIP }}
8680
8781
- name: Check GitHub Pages status
8882
if: github.ref == 'refs/heads/master'
89-
uses: crazy-max/ghaction-github-status@v2
83+
uses: crazy-max/ghaction-github-status@v4
9084
with:
9185
pages_threshold: major_outage
9286

93-
- name: Deploy
87+
- name: Deploy Javadoc
9488
# note that i'm only uploading the javadocs for b2-sdk-core.
9589
# that's because i'm lame and building separate javadocs for
9690
# each jar and only uploading one set of javadocs.
97-
if: github.ref == 'refs/heads/master' && success()
98-
uses: crazy-max/ghaction-github-pages@v2
91+
if: (github.ref == 'refs/heads/master' || github.ref == 'refs/heads/api-v2' || github.ref == 'refs/heads/7.x') && success()
92+
uses: crazy-max/ghaction-github-pages@v3
9993
with:
10094
target_branch: gh-pages
10195
build_dir: core/build/docs/javadoc

.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: 9 additions & 5 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,6 +134,10 @@ publishing {
134134
}
135135

136136
repositories {
137+
maven("https://artifactory.backblaze.com/artifactory/maven-private/") {
138+
name = "bzArtifactory"
139+
credentials(PasswordCredentials::class)
140+
}
137141
maven("https://maven.pkg.github.com/Backblaze/repo") {
138142
name = "bzGithubPackages"
139143
credentials(PasswordCredentials::class)
@@ -144,8 +148,8 @@ publishing {
144148
val sonatypeUsername = findProperty("sonatypeUsername")
145149
val sonatypePassword = findProperty("sonatypePassword")
146150

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

150154
if (sonatypeUsername != null && sonatypePassword != null) {
151155
signing {

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Copyright 2022, Backblaze Inc. All Rights Reserved.
22
# License https://www.backblaze.com/using_b2_code.html
33

4-
version=6.4.0-SNAPSHOT
4+
version=6.4.0-PRIVATE
55
group=com.backblaze.b2

0 commit comments

Comments
 (0)