Skip to content

Commit ce79794

Browse files
authored
Merge pull request #25 from googleads/pubjob
Prepare project for publishing
2 parents b136aed + 6a39b6a commit ce79794

9 files changed

Lines changed: 185 additions & 34 deletions

File tree

‎.github/workflows/presubmit.yaml‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,16 @@ jobs:
1010
runs-on: ubuntu-latest
1111
steps:
1212
- name: Checkout sources
13-
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6
13+
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
1414
with:
1515
persist-credentials: false
1616
- name: Set up Java
17-
uses: actions/setup-java@1bcf9fb12cf4aa7d266a90ae39939e61372fe520 # v5
17+
uses: actions/setup-java@1bcf9fb12cf4aa7d266a90ae39939e61372fe520 # v5.4.0
1818
with:
19-
java-version: '11'
19+
java-version: '21'
2020
distribution: 'temurin'
2121
- name: Setup Gradle
22-
uses: gradle/actions/setup-gradle@3f131e8634966bd73d06cc69884922b02e6faf92 # v6
22+
uses: gradle/actions/setup-gradle@3f131e8634966bd73d06cc69884922b02e6faf92 # v6.2.0
2323
with:
2424
cache-disabled: true
2525
# TODO(jradcliff): Add a lint step. Currently blocked by https://github.com/abcxyz/actions/issues/107.

‎.kokoro/release.cfg‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Format: //devtools/kokoro/config/proto/build.proto
2+
3+
build_file: "github/data-manager-java/.kokoro/release.sh"
4+
5+
before_action {
6+
fetch_keystore {
7+
keystore_resource {
8+
keystore_config_id: 74347
9+
keyname: "google_ads_java_gpg_secring"
10+
}
11+
}
12+
}

‎.kokoro/release.sh‎

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
#!/bin/bash
2+
set -euo pipefail
3+
set -x
4+
5+
REPO_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
6+
cd "${REPO_DIR}"
7+
8+
# Ensure Java 17 is used on Kokoro Ubuntu 22.04 workers (which default to OpenJDK 11)
9+
if [[ ! -d "/usr/lib/jvm/java-17-openjdk-amd64" ]]; then
10+
echo "ERROR: Kokoro worker missing expected OpenJDK 17 at /usr/lib/jvm/java-17-openjdk-amd64" >&2
11+
exit 1
12+
fi
13+
export JAVA_HOME="/usr/lib/jvm/java-17-openjdk-amd64"
14+
export PATH="${JAVA_HOME}/bin:${PATH}"
15+
16+
# 1. Clean, Test, Sign, and Publish to Artifact Registry
17+
# Keyring / ADC handles authentication via the Kokoro BYOSA service account
18+
# Keystore fetches the PGP signing key from Keystore config 74347
19+
KEYSTORE_GPG_FILE="${KOKORO_KEYSTORE_DIR:-}/74347_google_ads_java_gpg_secring"
20+
if [[ -n "${KOKORO_KEYSTORE_DIR:-}" && -f "${KEYSTORE_GPG_FILE}" ]]; then
21+
export SIGNING_KEY="$(cat "${KEYSTORE_GPG_FILE}")"
22+
fi
23+
24+
if [[ -z "${SIGNING_KEY:-}" ]]; then
25+
echo "ERROR: SIGNING_KEY is not set and Keystore GPG file is missing (${KEYSTORE_GPG_FILE})." >&2
26+
exit 1
27+
fi
28+
29+
./gradlew clean check publish --no-daemon
30+
31+
# 2. DRY_RUN Check
32+
if [[ "${DRY_RUN:-false}" == "true" ]]; then
33+
echo "=== DRY_RUN is enabled. Artifacts staged in Artifact Registry. ==="
34+
echo "Skipping GCS manifest upload to Exit Gate."
35+
exit 0
36+
fi
37+
38+
# 3. Create Exit Gate Release Manifest
39+
# Maven Central manifests require 'namespace' (groupId) and package 'name' (artifactId)
40+
cat <<EOF > manifest.json
41+
{
42+
"publish_all": false,
43+
"publishing_groups": [
44+
{
45+
"namespace": "com.google.api-ads",
46+
"packages": [
47+
{
48+
"name": "data-manager-util"
49+
}
50+
]
51+
}
52+
]
53+
}
54+
EOF
55+
56+
# 4. Trigger Exit Gate Release via GCS Manifest
57+
EXIT_GATE_BUCKET="gs://oss-exit-gate-prod-projects-bucket/measurement-devrel/mavencentral/manifests"
58+
MANIFEST_NAME="manifest-$(date +%Y%m%d%H%M%S).json"
59+
60+
echo "=== Uploading manifest to ${EXIT_GATE_BUCKET}/${MANIFEST_NAME} ==="
61+
gcloud storage cp manifest.json "${EXIT_GATE_BUCKET}/${MANIFEST_NAME}"
62+
63+
echo "=== Release successfully triggered to OSS Exit Gate! ==="

‎data-manager-samples/build.gradle‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,10 @@ plugins {
2020
id 'java-library'
2121
}
2222

23-
sourceCompatibility = 1.8
24-
targetCompatibility = 1.8
23+
java {
24+
sourceCompatibility = JavaVersion.VERSION_1_8
25+
targetCompatibility = JavaVersion.VERSION_1_8
26+
}
2527

2628
repositories {
2729
// Use Maven Central for resolving dependencies.

‎data-manager-util/build.gradle‎

Lines changed: 68 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,81 @@
1717
plugins {
1818
id 'java-library'
1919
id 'maven-publish'
20+
id 'signing'
21+
id 'com.google.cloud.artifactregistry.gradle-plugin' version '2.2.5' apply false
22+
}
23+
24+
def isPublishing = gradle.startParameter.taskNames.any { it.endsWith('publish') || it.contains('ArtifactRegistry') }
25+
if (isPublishing) {
26+
apply plugin: 'com.google.cloud.artifactregistry.gradle-plugin'
2027
}
2128

2229
group = 'com.google.api-ads'
2330
description = 'Utilities for working with the Data Manager API'
2431
version = '0.4.0'
2532

26-
sourceCompatibility = 1.8
27-
targetCompatibility = 1.8
33+
java {
34+
sourceCompatibility = JavaVersion.VERSION_1_8
35+
targetCompatibility = JavaVersion.VERSION_1_8
36+
withSourcesJar()
37+
withJavadocJar()
38+
}
39+
40+
publishing {
41+
publications {
42+
library(MavenPublication) {
43+
from components.java
44+
pom {
45+
name = 'Google Data Manager API Utilities'
46+
description = 'Utilities for working with the Data Manager API'
47+
url = 'https://github.com/googleads/data-manager-java'
48+
licenses {
49+
license {
50+
name = 'The Apache License, Version 2.0'
51+
url = 'https://www.apache.org/licenses/LICENSE-2.0.txt'
52+
}
53+
}
54+
developers {
55+
developer {
56+
id = 'josh'
57+
name = 'Josh Radcliff'
58+
email = 'jradcliff@users.noreply.github.com'
59+
organization = 'Google'
60+
organizationUrl = 'https://www.google.com'
61+
}
62+
developer {
63+
id = 'lindsey'
64+
name = 'Lindsey Volta'
65+
email = 'lindsey-volta@users.noreply.github.com'
66+
organization = 'Google'
67+
organizationUrl = 'https://www.google.com'
68+
}
69+
}
70+
scm {
71+
connection = 'scm:git:git://github.com/googleads/data-manager-java.git'
72+
developerConnection = 'scm:git:ssh://github.com:googleads/data-manager-java.git'
73+
url = 'https://github.com/googleads/data-manager-java'
74+
}
75+
}
76+
}
77+
}
78+
repositories {
79+
if (isPublishing) {
80+
maven {
81+
name = 'ExitGateArtifactRegistry'
82+
url = uri(findProperty('artifact-registry-url') ?: "artifactregistry://us-maven.pkg.dev/oss-exit-gate-prod/measurement-devrel--mavencentral")
83+
}
84+
}
85+
}
86+
}
2887

29-
publishing.publications {
30-
library(MavenPublication).from components.java
88+
signing {
89+
def signingKey = findProperty("signingKey") ?: System.getenv("SIGNING_KEY")
90+
def signingPassword = findProperty("signingPassword") ?: System.getenv("SIGNING_PASSWORD")
91+
if (signingKey) {
92+
useInMemoryPgpKeys(signingKey, signingPassword)
93+
sign publishing.publications.library
94+
}
3195
}
3296

3397
// Creates install "alias".

‎gradle/wrapper/gradle-wrapper.jar‎

-17.6 KB
Binary file not shown.
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.2-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.12-bin.zip
44
networkTimeout=10000
5+
validateDistributionUrl=true
56
zipStoreBase=GRADLE_USER_HOME
67
zipStorePath=wrapper/dists

‎gradlew‎

Lines changed: 20 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎gradlew.bat‎

Lines changed: 12 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)