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
18 changes: 12 additions & 6 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Publish Library to Artifactory
name: Publish Library to GAR
on:
workflow_dispatch:
inputs:
Expand Down Expand Up @@ -41,9 +41,15 @@ jobs:
java-version: '17'
distribution: 'temurin'
cache: 'gradle'
- name: Publish Library Artifactory
run: ./gradlew --build-cache artifactoryPublish
- name: Authenticate to GCP
uses: google-github-actions/auth@v2
with:
token_format: access_token
workload_identity_provider: 'projects/1038484894585/locations/global/workloadIdentityPools/github-wi-pool/providers/github-wi-provider'
service_account: 'dsp-artifact-registry-push@dsp-artifact-registry.iam.gserviceaccount.com'
- name: Publish client to GAR
run: ./gradlew publish
env:
ARTIFACTORY_USERNAME: ${{ secrets.ARTIFACTORY_USERNAME }}
ARTIFACTORY_PASSWORD: ${{ secrets.ARTIFACTORY_PASSWORD }}
ARTIFACTORY_REPO_KEY: "libs-release-local"
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 mean we can also remove https://github.com/broadinstitute/terraform-ap-deployments/blob/824166e7be8cfa8be5c4954a07c1aa5a9fcab894/github/tfvars/databiosphere-java-pfb.tfvars#L22-L31 ? It might make sense to do a big bulk update in terraform-ap-deployments once we've changed over multiple repos.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Probably, maybe a bulk update is a good idea though. But this comment did bring my attention to directions in the README that need to be updated, thank you!

GOOGLE_CLOUD_PROJECT: dsp-artifact-registry
GAR_LOCATION: us-central1
GAR_REPOSITORY_ID: libs-release-standard
13 changes: 8 additions & 5 deletions library/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,21 @@ implementation "bio.terra:java-pfb-library:<Tagged Version>"
You can find the latest tagged version on [Github](https://github.com/DataBiosphere/java-pfb/tags).

## Publishing the Library
JFrog Artifactory is used to publish libraries to a central Maven repository. The library version number is the version in settings.gradle. We use github actions to bump the version and publish to Artifactory.
Google Artifact Registry (GAR) is used to publish libraries to a central Maven repository. The library version number is the version in settings.gradle. We use github actions to bump the version and publish to GAR.

**The Publishing Procedure**

1) After PR is merged to main branch:
1) A Github Action bumps the minor version in settings.gradle and tags the release in github
2) Github Action publishes to libs-release-local in Artifactory
2) Github Action publishes to libs-release-standard in GAR
2) To bump major version, we need manually update version in settings.gradle value first then create the release.

**Running Publish Locally**
You'll need to have permission under your @broadinstitute account to publish to the registry. If you don't, contact DevOps.
```shell
export ARTIFACTORY_USERNAME=$(vault read -field=username secret/dsp/accts/artifactory/dsdejenkins)
export ARTIFACTORY_PASSWORD=$(vault read -field=password secret/dsp/accts/artifactory/dsdejenkins)
./gradlew artifactoryPublish
export GOOGLE_CLOUD_PROJECT=dsp-artifact-registry
export GAR_LOCATION=us-central1
export GAR_REPOSITORY_ID=libs-release-standard
gcloud auth login <you>@broadinstitute.org
./gradlew publish
```
2 changes: 1 addition & 1 deletion library/build.gradle
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
plugins {
id 'com.srcclr.gradle'
id 'maven-publish'
id 'com.jfrog.artifactory'
id 'bio.terra.pfb.java-library-conventions'
id 'com.github.davidmc24.gradle.plugin.avro' version '1.9.1'
id 'me.champeau.jmh' version '0.7.3'
id 'com.google.cloud.artifactregistry.gradle-plugin' version '2.1.5'
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The latest version is 2.2.5, but that requires java 21 and so the project failed to build. It seemed safer to keep the java version for this PR; if we want to update java we can increase this version as well

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.

can the id 'com.jfrog.artifactory' plugin be removed now, up at line 4?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Ah right I meant to do that and forgot, thanks

}

repositories {
Expand Down
34 changes: 8 additions & 26 deletions library/publishing.gradle
Original file line number Diff line number Diff line change
@@ -1,19 +1,13 @@
def artifactory_repo_key = System.getenv('ARTIFACTORY_REPO_KEY') != null ? System.getenv('ARTIFACTORY_REPO_KEY') : 'libs-release-local'
def artifactory_username = System.getenv('ARTIFACTORY_USERNAME')
def artifactory_password = System.getenv('ARTIFACTORY_PASSWORD')
def garProjectId = System.getenv("GOOGLE_CLOUD_PROJECT")
def garLocation = System.getenv("GAR_LOCATION")
def garRepoId = System.getenv("GAR_REPOSITORY_ID")


java {
// Builds sources into the published package as part of the 'assemble' task.
withSourcesJar()
}

gradle.taskGraph.whenReady { taskGraph ->
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I think this is artifactory-specific and so can be removed entirely instead of updated. My test-run of publishing seemed to work without it, but if you know otherwise, let me know!

if (taskGraph.hasTask(artifactoryPublish) &&
(artifactory_username == null || artifactory_password == null)) {
throw new GradleException('Set env vars ARTIFACTORY_USERNAME and ARTIFACTORY_PASSWORD to publish')
}
}

// Publish jar file to a Maven module/artifact using the maven-publish plugin.
publishing {
publications {
Expand All @@ -24,21 +18,9 @@ publishing {
from components.java
}
}
}

// Upload Maven artifacts to Artifactory using the Artifactory plugin.
artifactory {
publish {
contextUrl = 'https://broadinstitute.jfrog.io/broadinstitute/'
repository {
repoKey = "${artifactory_repo_key}"
username = "${artifactory_username}"
password = "${artifactory_password}"
}
defaults {
publications('javaPfbLibrary')
publishArtifacts = true
publishPom = true
repositories {
maven {
url = uri("artifactregistry://${garLocation}-maven.pkg.dev/${garProjectId}/${garRepoId}")
}
}
}
}