diff --git a/.fernignore b/.fernignore
index f1c176f1..3aa9b05c 100644
--- a/.fernignore
+++ b/.fernignore
@@ -5,12 +5,11 @@
#
# publish-main.yml is hand-written: it releases com.whop.api:whop-java when a merge to main
# lands a gradle.properties version that is not yet published, and it is meant to be the
-# only publish path. It has two targets behind one set of guards — GitHub Packages
-# (whopio-internal, authenticated with the run's own GITHUB_TOKEN, no namespace to
-# register) and the Sonatype Central Portal (public, blocked on DNS verification and a
-# signing key). RELEASE_TARGET sets the default, a workflow_dispatch input overrides it,
-# and every pull request rehearses both so neither path rots while the other is the live
-# one.
+# only publish path. Public Maven hosting on GitHub Pages is the default; the same
+# verified bundle can also target GitHub Packages or Maven Central. Maven Central
+# requires namespace verification and main-only signing/publishing credentials.
+# Public release bytes and provenance are retained on the maven branch; reruns reuse
+# that version only for the same source commit and verify the stored hashes.
#
# stamp-version.py is that workflow's version stamp: gradle.properties, every source file
# carrying X-Fern-SDK-Version, and .fern/metadata.json. It is a file rather than a script
@@ -86,3 +85,8 @@ src/test/java/com/whop/api/helpers/
.gitattributes
# Remove when Fern emits and tests equivalent Android consumer rules.
src/main/resources/META-INF/proguard/whop-java.pro
+
+# Remove when Fern provides immutable public Maven hosting and equivalent checks.
+.github/public-maven.py
+.github/test_public_maven.py
+INSTALL.md
diff --git a/.github/package-smoke/pom.xml b/.github/package-smoke/pom.xml
new file mode 100644
index 00000000..8ceafef5
--- /dev/null
+++ b/.github/package-smoke/pom.xml
@@ -0,0 +1,40 @@
+
+ 4.0.0
+ com.whop.smoke
+ installed-sdk-consumer
+ 1.0.0
+
+ 17
+ UTF-8
+
+
+
+ whop-sdk
+ ${sdkRepository}
+
+
+
+
+ com.whop.api
+ whop-java
+ ${sdkVersion}
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+ 3.14.1
+
+
+ org.codehaus.mojo
+ exec-maven-plugin
+ 3.6.3
+
+ PackageConsumer
+
+
+
+
+
diff --git a/.github/public-maven.py b/.github/public-maven.py
new file mode 100644
index 00000000..a8493cbd
--- /dev/null
+++ b/.github/public-maven.py
@@ -0,0 +1,99 @@
+import datetime
+import hashlib
+import json
+import pathlib
+import re
+import shutil
+import sys
+import xml.etree.ElementTree as ET
+
+COORDINATE = pathlib.Path('com/whop/api/whop-java')
+VERSION = re.compile(r'(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-([0-9A-Za-z]+(?:[.-][0-9A-Za-z]+)*))?')
+
+
+def version_key(version):
+ match = VERSION.fullmatch(version)
+ if not match:
+ raise ValueError('invalid public Maven version: ' + version)
+ prerelease = match[4]
+ rank = (1,) if prerelease is None else (0, tuple(
+ (0, int(part)) if part.isdigit() else (1, part)
+ for part in prerelease.split('.')
+ ))
+ return tuple(map(int, match.group(1, 2, 3))), rank
+
+
+def hashes(directory):
+ result = {}
+ for file in sorted(directory.iterdir()):
+ if file.is_symlink() or not file.is_file():
+ raise ValueError('release entries must be regular files: ' + str(file))
+ if file.name != 'release.json':
+ result[file.name] = hashlib.sha256(file.read_bytes()).hexdigest()
+ return result
+
+
+def prepare(bundle, site, version, commit):
+ version_key(version)
+ if not re.fullmatch(r'[0-9a-f]{40}', commit):
+ raise ValueError('the source commit must be a full Git SHA')
+ incoming = bundle / COORDINATE / version
+ for suffix in ('.jar', '-sources.jar', '-javadoc.jar', '.pom'):
+ if not (incoming / ('whop-java-' + version + suffix)).is_file():
+ raise ValueError('incomplete release bundle: ' + str(incoming))
+ root = ET.parse(incoming / ('whop-java-' + version + '.pom')).getroot()
+ ns = {'m': 'http://maven.apache.org/POM/4.0.0'}
+ for key, expected in (('groupId', 'com.whop.api'), ('artifactId', 'whop-java'), ('version', version)):
+ if root.findtext('m:' + key, namespaces=ns) != expected:
+ raise ValueError('the release POM has the wrong ' + key)
+ incoming_hashes = hashes(incoming)
+ target = site / COORDINATE / version
+ if target.exists():
+ record = json.loads((target / 'release.json').read_text())
+ if record.get('sourceCommit') != commit or record.get('version') != version:
+ raise ValueError('refusing to replace an immutable release from a different commit')
+ if record.get('sha256') != hashes(target):
+ raise ValueError('the stored immutable release does not match its checksums')
+ if (target / ('whop-java-' + version + '.pom')).read_bytes() != (incoming / ('whop-java-' + version + '.pom')).read_bytes():
+ raise ValueError('the retry changes the immutable release POM')
+ else:
+ existing = [path.name for path in target.parent.iterdir() if path.is_dir()] if target.parent.exists() else []
+ if any(version_key(other) > version_key(version) for other in existing):
+ raise ValueError('refusing to publish a version older than an existing release')
+ target.parent.mkdir(parents=True, exist_ok=True)
+ shutil.copytree(incoming, target)
+ (target / 'release.json').write_text(json.dumps({
+ 'coordinate': 'com.whop.api:whop-java:' + version,
+ 'version': version,
+ 'sourceCommit': commit,
+ 'sha256': incoming_hashes,
+ }, indent=2, sort_keys=True) + '\n')
+ versions = sorted((path.name for path in target.parent.iterdir() if path.is_dir()), key=version_key)
+ metadata = ET.Element('metadata')
+ ET.SubElement(metadata, 'groupId').text = 'com.whop.api'
+ ET.SubElement(metadata, 'artifactId').text = 'whop-java'
+ versioning = ET.SubElement(metadata, 'versioning')
+ ET.SubElement(versioning, 'latest').text = versions[-1]
+ stable = [value for value in versions if VERSION.fullmatch(value)[4] is None]
+ if stable:
+ ET.SubElement(versioning, 'release').text = stable[-1]
+ entries = ET.SubElement(versioning, 'versions')
+ for value in versions:
+ ET.SubElement(entries, 'version').text = value
+ ET.SubElement(versioning, 'lastUpdated').text = datetime.datetime.now(datetime.timezone.utc).strftime('%Y%m%d%H%M%S')
+ ET.indent(metadata)
+ data = ET.tostring(metadata, encoding='utf-8', xml_declaration=True) + b'\n'
+ path = target.parent / 'maven-metadata.xml'
+ path.write_bytes(data)
+ for algorithm in ('md5', 'sha1', 'sha256', 'sha512'):
+ pathlib.Path(str(path) + '.' + algorithm).write_text(hashlib.new(algorithm, data).hexdigest())
+ (site / '.nojekyll').touch()
+ (site / 'index.html').write_text('
Whop Java SDK Maven repositoryWhop Java SDK
Public Maven repository for com.whop.api:whop-java.
Installation instructions
\n')
+ print('Prepared immutable com.whop.api:whop-java:' + version + ' from ' + commit)
+
+
+if __name__ == '__main__':
+ try:
+ prepare(pathlib.Path(sys.argv[1]), pathlib.Path(sys.argv[2]), sys.argv[3], sys.argv[4])
+ except (ValueError, OSError, KeyError, ET.ParseError) as error:
+ raise SystemExit('::error::' + str(error))
diff --git a/.github/release.gradle b/.github/release.gradle
index d211a935..b22f4421 100644
--- a/.github/release.gradle
+++ b/.github/release.gradle
@@ -38,6 +38,19 @@ gradle.projectsLoaded {
connection = 'scm:git:https://github.com/whopio/whopsdk-java.git'
developerConnection = 'scm:git:ssh://git@github.com/whopio/whopsdk-java.git'
}
+ withXml {
+ def okhttp = root.configurations.api.dependencies.find {
+ it.group == 'com.squareup.okhttp3' && it.name == 'okhttp'
+ }
+ if (okhttp == null || !okhttp.version) {
+ throw new GradleException('Cannot derive the OkHttp JVM dependency for Maven consumers')
+ }
+ def dependency = asNode().dependencies[0].appendNode('dependency')
+ dependency.appendNode('groupId', okhttp.group)
+ dependency.appendNode('artifactId', 'okhttp-jvm')
+ dependency.appendNode('version', okhttp.version)
+ dependency.appendNode('scope', 'compile')
+ }
}
}
}
diff --git a/.github/test_public_maven.py b/.github/test_public_maven.py
new file mode 100644
index 00000000..e6e3282c
--- /dev/null
+++ b/.github/test_public_maven.py
@@ -0,0 +1,103 @@
+import hashlib
+import importlib.util
+import json
+import pathlib
+import tempfile
+import unittest
+import xml.etree.ElementTree as ET
+
+spec = importlib.util.spec_from_file_location('public_maven', pathlib.Path(__file__).with_name('public-maven.py'))
+public_maven = importlib.util.module_from_spec(spec)
+spec.loader.exec_module(public_maven)
+
+
+class PublicMavenTest(unittest.TestCase):
+ def setUp(self):
+ self.temporary = tempfile.TemporaryDirectory()
+ self.addCleanup(self.temporary.cleanup)
+ self.root = pathlib.Path(self.temporary.name)
+ self.bundle = self.root / 'bundle'
+ self.site = self.root / 'site'
+ self.commit = 'a' * 40
+
+ def bundle_version(self, version):
+ directory = self.bundle / public_maven.COORDINATE / version
+ directory.mkdir(parents=True, exist_ok=True)
+ for suffix in ('.jar', '-sources.jar', '-javadoc.jar'):
+ (directory / ('whop-java-' + version + suffix)).write_bytes(b'jar-' + version.encode())
+ (directory / ('whop-java-' + version + '.pom')).write_text(
+ 'com.whop.apiwhop-java' + version + ''
+ )
+ return directory
+
+ def publish(self, version, commit=None):
+ public_maven.prepare(self.bundle, self.site, version, commit or self.commit)
+ return self.site / public_maven.COORDINATE / version
+
+ def test_preserves_old_versions_and_updates_metadata(self):
+ self.bundle_version('2.8.1')
+ first = self.publish('2.8.1')
+ before = public_maven.hashes(first)
+ self.bundle_version('2.9.0')
+ self.publish('2.9.0', 'b' * 40)
+ self.assertEqual(before, public_maven.hashes(first))
+ metadata = first.parent / 'maven-metadata.xml'
+ root = ET.parse(metadata).getroot()
+ self.assertEqual('2.9.0', root.findtext('versioning/release'))
+ self.assertEqual(['2.8.1', '2.9.0'], [node.text for node in root.findall('versioning/versions/version')])
+ self.assertEqual(hashlib.sha256(metadata.read_bytes()).hexdigest(), pathlib.Path(str(metadata) + '.sha256').read_text())
+
+ def test_retry_reuses_original_artifact_bytes(self):
+ incoming = self.bundle_version('2.8.1')
+ target = self.publish('2.8.1')
+ (incoming / 'whop-java-2.8.1.jar').write_bytes(b'rebuilt-with-different-zip-times')
+ self.publish('2.8.1')
+ self.assertEqual(b'jar-2.8.1', (target / 'whop-java-2.8.1.jar').read_bytes())
+
+ def test_rejects_new_commit_for_existing_version(self):
+ self.bundle_version('2.8.1')
+ self.publish('2.8.1')
+ with self.assertRaisesRegex(ValueError, 'different commit'):
+ self.publish('2.8.1', 'b' * 40)
+
+ def test_rejects_corrupt_stored_artifact(self):
+ self.bundle_version('2.8.1')
+ target = self.publish('2.8.1')
+ (target / 'whop-java-2.8.1.jar').write_bytes(b'corrupt')
+ with self.assertRaisesRegex(ValueError, 'checksums'):
+ self.publish('2.8.1')
+
+ def test_rejects_pom_changes_on_retry(self):
+ incoming = self.bundle_version('2.8.1')
+ self.publish('2.8.1')
+ pom = incoming / 'whop-java-2.8.1.pom'
+ pom.write_text(pom.read_text().replace('', 'changed'))
+ with self.assertRaisesRegex(ValueError, 'POM'):
+ self.publish('2.8.1')
+
+ def test_rejects_version_regression(self):
+ self.bundle_version('2.9.0')
+ self.publish('2.9.0')
+ self.bundle_version('2.8.1')
+ with self.assertRaisesRegex(ValueError, 'older'):
+ self.publish('2.8.1')
+
+ def test_rejects_incomplete_and_wrong_coordinate_bundles(self):
+ incoming = self.bundle_version('2.8.1')
+ (incoming / 'whop-java-2.8.1-sources.jar').unlink()
+ with self.assertRaisesRegex(ValueError, 'incomplete'):
+ self.publish('2.8.1')
+ self.bundle_version('2.8.1')
+ pom = incoming / 'whop-java-2.8.1.pom'
+ pom.write_text(pom.read_text().replace('com.whop.api', 'other.group'))
+ with self.assertRaisesRegex(ValueError, 'groupId'):
+ self.publish('2.8.1')
+
+ def test_rejects_unsafe_version_paths(self):
+ for version in ('../../other', '2.8.1/other', '02.8.1'):
+ with self.assertRaisesRegex(ValueError, 'invalid'):
+ self.publish(version)
+
+ def test_semver_precedence(self):
+ versions = ['2.8.1', '2.8.1-rc.10', '2.8.1-rc.2', '2.8.0', '2.8.1-alpha']
+ self.assertEqual(['2.8.0', '2.8.1-alpha', '2.8.1-rc.2', '2.8.1-rc.10', '2.8.1'], sorted(versions, key=public_maven.version_key))
diff --git a/.github/workflows/publish-main.yml b/.github/workflows/publish-main.yml
index 5402cae5..0ca57644 100644
--- a/.github/workflows/publish-main.yml
+++ b/.github/workflows/publish-main.yml
@@ -17,6 +17,7 @@ on:
default: default
options:
- default
+ - public-maven
- github-packages
- maven-central
- both
@@ -30,7 +31,7 @@ concurrency:
queue: max
env:
- RELEASE_TARGET: github-packages
+ RELEASE_TARGET: public-maven
GROUP_ID: com.whop.api
ARTIFACT_ID: whop-java
PLACEHOLDER_VERSION: 0.0.0
@@ -43,6 +44,7 @@ env:
INIT_SCRIPT: .github/release.gradle
BUNDLE_DIR: build/bundle
JAVA_VERSION: "17"
+ PUBLIC_BASE: https://whopio.github.io/whopsdk-java
CENTRAL_BASE: https://repo1.maven.org/maven2
PORTAL_BASE: https://central.sonatype.com/api/v1/publisher
PUBLISHING_TYPE: AUTOMATIC
@@ -63,6 +65,7 @@ jobs:
target: ${{ steps.gate.outputs.target }}
central: ${{ steps.gate.outputs.central }}
packages: ${{ steps.gate.outputs.packages }}
+ public: ${{ steps.gate.outputs.public }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1
with:
@@ -169,16 +172,22 @@ jobs:
target="$RELEASE_TARGET"
fi
+ want_public=false
case "$target" in
+ public-maven) want_central=false; want_packages=false; want_public=true ;;
github-packages) want_central=false; want_packages=true ;;
maven-central) want_central=true; want_packages=false ;;
both) want_central=true; want_packages=true ;;
*)
- echo "::error::'${target}' is not a release target. Use github-packages, maven-central or both."
+ echo "::error::'${target}' is not a release target. Use public-maven, github-packages, maven-central or both."
exit 1
;;
esac
+ if [ "$EVENT" = "pull_request" ]; then
+ want_public=true
+ fi
+
emit target "$target"
echo "event=$EVENT dry=$dry target=$target ref=$GITHUB_REF"
@@ -312,6 +321,36 @@ jobs:
esac
fi
+ public_published=unknown
+ if [ "$want_public" = "true" ]; then
+ metadata_status=$(curl -sS -o "${RUNNER_TEMP}/public-metadata.xml" -w '%{http_code}' "${PUBLIC_BASE}/${GROUP_PATH}/${ARTIFACT_ID}/maven-metadata.xml")
+ case "$metadata_status" in
+ 200)
+ python3 - "${RUNNER_TEMP}/public-metadata.xml" > "${RUNNER_TEMP}/public-versions.txt" <<'PYTHON'
+ import sys
+ import xml.etree.ElementTree as ET
+ root = ET.parse(sys.argv[1]).getroot()
+ if root.findtext("groupId") != "com.whop.api" or root.findtext("artifactId") != "whop-java":
+ raise SystemExit("::error::the public repository metadata has the wrong coordinate")
+ for node in root.findall("versioning/versions/version"):
+ print(node.text)
+ PYTHON
+ while IFS= read -r published_version; do
+ [ -n "$published_version" ] || continue
+ guard_against "the public Maven repository" "$published_version"
+ done < "${RUNNER_TEMP}/public-versions.txt"
+ ;;
+ 404) ;;
+ *) refuse "public Maven metadata returned HTTP ${metadata_status}; refusing to guess the published version." ;;
+ esac
+ public_status=$(curl -sS -o /dev/null -w '%{http_code}' "${PUBLIC_BASE}/${GROUP_PATH}/${ARTIFACT_ID}/${version}/${ARTIFACT_ID}-${version}.pom")
+ case "$public_status" in
+ 200) public_published=yes ;;
+ 404) public_published=no ;;
+ *) refuse "public Maven POM returned HTTP ${public_status}; refusing to guess whether ${version} is published." ;;
+ esac
+ fi
+
packages_published=unknown
if [ "$want_packages" = "true" ]; then
: > "${RUNNER_TEMP}/package_versions.txt"
@@ -381,11 +420,13 @@ jobs:
emit release true
emit central "$want_central"
emit packages "$want_packages"
+ emit public "$want_public"
exit 0
fi
release_central=false
release_packages=false
+ release_public=false
if [ "$want_central" = "true" ]; then
if [ "$central_published" = "yes" ]; then
@@ -403,10 +444,15 @@ jobs:
fi
fi
+ if [ "$want_public" = "true" ] && [ "$public_published" != "yes" ]; then
+ release_public=true
+ fi
+
+ emit public "$release_public"
emit central "$release_central"
emit packages "$release_packages"
- if [ "$release_central" = "false" ] && [ "$release_packages" = "false" ]; then
+ if [ "$release_central" = "false" ] && [ "$release_packages" = "false" ] && [ "$release_public" = "false" ]; then
emit release false
exit 0
fi
@@ -553,6 +599,10 @@ jobs:
+ " in the POM; an api dependency has to reach the consumer's compile classpath"
)
+ okhttp = declared.get("com.squareup.okhttp3:okhttp")
+ if not okhttp or declared.get("com.squareup.okhttp3:okhttp-jvm") != (okhttp[0], "compile"):
+ problems.append("Maven consumers need okhttp-jvm at the generated OkHttp version and compile scope")
+
if problems:
raise SystemExit("::error::" + "; ".join(problems))
@@ -595,6 +645,14 @@ jobs:
echo "bundle verified:"
find "$BUNDLE_DIR" -type f | sort
+ - name: Verify immutable public repository updates
+ env:
+ VERSION: ${{ needs.decide.outputs.version }}
+ run: |
+ set -euo pipefail
+ python3 -m unittest discover -s .github -p 'test_public_maven.py'
+ python3 .github/public-maven.py "$BUNDLE_DIR" "${RUNNER_TEMP}/public-site" "$VERSION" "$GITHUB_SHA"
+
- name: Verify an installed Maven consumer
env:
VERSION: ${{ needs.decide.outputs.version }}
@@ -603,6 +661,16 @@ jobs:
./gradlew --no-daemon -p .github/package-smoke run \
-PsdkRepository="$PWD/$BUNDLE_DIR" -PsdkVersion="$VERSION" --args="$VERSION"
+ - name: Verify an installed Maven CLI consumer
+ env:
+ VERSION: ${{ needs.decide.outputs.version }}
+ run: |
+ set -euo pipefail
+ mvn --batch-mode --no-transfer-progress -f .github/package-smoke/pom.xml \
+ -Dmaven.repo.local="${RUNNER_TEMP}/maven-consumer" \
+ -DsdkRepository="file://$PWD/$BUNDLE_DIR" -DsdkVersion="$VERSION" \
+ compile exec:java -Dexec.args="$VERSION"
+
- name: Match the POM against the one the build job verified
env:
VERSION: ${{ needs.decide.outputs.version }}
@@ -965,9 +1033,94 @@ jobs:
echo "::notice::${GROUP_ID}:${ARTIFACT_ID}:${VERSION} resolves from ${PACKAGES_BASE} and serves the POM the build job verified."
+ publish-public:
+ needs: [decide, build]
+ if: needs.decide.outputs.public == 'true' && needs.decide.outputs.dry == 'false' && github.ref == 'refs/heads/main' && github.event_name != 'pull_request'
+ runs-on: ubuntu-latest
+ environment:
+ name: github-pages
+ url: ${{ steps.deployment.outputs.page_url }}
+ permissions:
+ contents: write # Preserve every immutable release on the maven branch.
+ pages: write # Deploy the public Maven repository.
+ id-token: write # Prove the main-only Pages deployment's identity.
+ steps:
+ - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1
+ with:
+ path: source
+ persist-credentials: false
+
+ - uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c
+ with:
+ name: bundle
+ path: bundle/
+
+ - name: Preserve the verified release and older versions
+ env:
+ VERSION: ${{ needs.decide.outputs.version }}
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ run: |
+ set -euo pipefail
+ git init site
+ git -C site remote add origin "${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}.git"
+ if git -C site ls-remote --exit-code origin refs/heads/maven; then
+ git -C site fetch --no-tags --depth=1 origin refs/heads/maven
+ git -C site checkout -B maven FETCH_HEAD
+ else
+ git -C site checkout --orphan maven
+ fi
+ python3 source/.github/public-maven.py bundle site "$VERSION" "$GITHUB_SHA"
+ git -C site config user.name 'github-actions[bot]'
+ git -C site config user.email '41898282+github-actions[bot]@users.noreply.github.com'
+ git -C site add .
+ if ! git -C site diff --cached --quiet; then
+ git -C site commit -m "Release com.whop.api:whop-java:${VERSION} from ${GITHUB_SHA}"
+ export GIT_CONFIG_COUNT=1
+ export GIT_CONFIG_KEY_0="http.${GITHUB_SERVER_URL}/.extraheader"
+ GIT_CONFIG_VALUE_0="AUTHORIZATION: basic $(printf 'x-access-token:%s' "$GITHUB_TOKEN" | base64 -w0)"
+ export GIT_CONFIG_VALUE_0
+ git -C site push origin HEAD:refs/heads/maven
+ fi
+ rm -rf site/.git
+
+ - uses: actions/upload-pages-artifact@5f327015a708106f6f1b7c9a633901af30fe80cb
+ with:
+ path: site/
+
+ - name: Deploy the public Maven repository
+ id: deployment
+ uses: actions/deploy-pages@368f82528645a54fb793d4d04e342629a3f51346
+
+ verify-public:
+ needs: [decide, publish-public]
+ if: needs.publish-public.result == 'success'
+ runs-on: ubuntu-latest
+ permissions:
+ contents: read
+ steps:
+ - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1
+ with:
+ persist-credentials: false
+ - uses: actions/setup-java@b6effb05e454b25005698d916606bdc6ffcbf961
+ with:
+ distribution: temurin
+ java-version: ${{ env.JAVA_VERSION }}
+ - name: Verify an anonymous installed consumer
+ env:
+ VERSION: ${{ needs.decide.outputs.version }}
+ GRADLE_USER_HOME: ${{ runner.temp }}/public-consumer-gradle
+ run: |
+ set -euo pipefail
+ ./gradlew --no-daemon --refresh-dependencies -p .github/package-smoke run \
+ -PsdkRepository="$PUBLIC_BASE" -PsdkVersion="$VERSION" --args="$VERSION"
+ mvn --batch-mode --no-transfer-progress -f .github/package-smoke/pom.xml \
+ -Dmaven.repo.local="${RUNNER_TEMP}/public-consumer-maven" \
+ -DsdkRepository="$PUBLIC_BASE" -DsdkVersion="$VERSION" \
+ compile exec:java -Dexec.args="$VERSION"
+
tag:
- needs: [decide, build, publish, publish-github-packages]
- if: always() && needs.decide.outputs.dry == 'false' && needs.decide.outputs.version != '' && needs.decide.outputs.version != '0.0.0' && github.ref == 'refs/heads/main' && github.event_name != 'pull_request'
+ needs: [decide, build, publish, publish-github-packages, verify-public]
+ if: always() && (needs.decide.outputs.target != 'public-maven' || needs.verify-public.result == 'success') && needs.decide.outputs.dry == 'false' && needs.decide.outputs.version != '' && needs.decide.outputs.version != '0.0.0' && github.ref == 'refs/heads/main' && github.event_name != 'pull_request'
runs-on: ubuntu-latest
permissions:
contents: write
@@ -984,10 +1137,18 @@ jobs:
set -euo pipefail
central_pom="${CENTRAL_BASE}/${GROUP_PATH}/${ARTIFACT_ID}/${VERSION}/${ARTIFACT_ID}-${VERSION}.pom"
+ public_pom="${PUBLIC_BASE}/${GROUP_PATH}/${ARTIFACT_ID}/${VERSION}/${ARTIFACT_ID}-${VERSION}.pom"
packages_pom="${PACKAGES_BASE}/${GROUP_PATH}/${ARTIFACT_ID}/${VERSION}/${ARTIFACT_ID}-${VERSION}.pom"
resolvable() {
local status
+ if [ "$TARGET" = "public-maven" ]; then
+ [ "${{ needs.verify-public.result }}" = "success" ] || return 1
+ status=$(curl -sS -o /dev/null -w '%{http_code}' "$public_pom")
+ echo " Public Maven: HTTP ${status}"
+ [ "$status" = "200" ]
+ return
+ fi
if [ "$TARGET" != "maven-central" ]; then
status=$(curl -sSL -o /dev/null -w '%{http_code}' \
--header "Authorization: Bearer ${GITHUB_TOKEN}" "$packages_pom" || echo 000)
diff --git a/INSTALL.md b/INSTALL.md
new file mode 100644
index 00000000..49aebb2e
--- /dev/null
+++ b/INSTALL.md
@@ -0,0 +1,84 @@
+# Install the Whop Java SDK
+
+The public Maven repository needs no GitHub token or registry account. It serves `com.whop.api:whop-java`; Maven Central supplies the SDK's dependencies. The POM includes OkHttp's JVM artifact for Maven users; Gradle selects the platform variant through module metadata.
+
+## Android and Gradle
+
+Add to `settings.gradle.kts`:
+
+```kotlin
+dependencyResolutionManagement {
+ repositories {
+ google()
+ mavenCentral()
+ maven {
+ url = uri("https://whopio.github.io/whopsdk-java/")
+ content { includeGroup("com.whop.api") }
+ }
+ }
+}
+```
+
+Add to the app module's dependencies:
+
+```kotlin
+implementation("com.whop.api:whop-java:2.8.1")
+```
+
+The SDK's OkHttp 5 dependency requires Android API 21 or newer. Enable core library desugaring for `java.time` and Java 8 APIs on older Android versions:
+
+```kotlin
+android {
+ compileOptions {
+ sourceCompatibility = JavaVersion.VERSION_1_8
+ targetCompatibility = JavaVersion.VERSION_1_8
+ isCoreLibraryDesugaringEnabled = true
+ }
+}
+
+dependencies {
+ coreLibraryDesugaring("com.android.tools:desugar_jdk_libs:2.1.5")
+}
+```
+
+Declare the `android.permission.INTERNET` permission in your manifest. R8 consumer rules ship inside the SDK JAR; no app-owned SDK keep rules are needed.
+
+## Server-side Java and Maven
+
+Use Java 8 or newer. Add this repository and dependency to `pom.xml`:
+
+```xml
+
+
+ whop-public
+ https://whopio.github.io/whopsdk-java/
+
+
+
+
+ com.whop.api
+ whop-java
+ 2.8.1
+
+
+```
+
+## Use the sandbox
+
+```java
+import com.whop.api.WhopApiClient;
+import com.whop.api.core.Environment;
+
+WhopApiClient client = WhopApiClient.builder()
+ .token(sandboxToken)
+ .environment(Environment.SANDBOX)
+ .build();
+```
+
+Android callers must run synchronous SDK methods off the main thread or use `AsyncWhopApiClient`. Keep privileged business API keys on your server; do not embed them in a shipped mobile app. For personal sandbox testing, supply a scoped sandbox token at runtime.
+
+Products, variants, checkout configurations, and payments are exposed as `client.products()`, `client.variants()`, `client.checkoutConfigurations()`, and `client.payments()`. See [reference.md](reference.md) for typed request builders and [MIGRATING.md](MIGRATING.md) for API naming changes.
+
+## Release provenance
+
+Each version directory includes `release.json` with the source commit and SHA-256 hashes of the artifacts. Releases retain their original bytes. The [release workflow](.github/workflows/publish-main.yml) verifies installation from this public repository before creating the version tag.
diff --git a/MIGRATING.md b/MIGRATING.md
index 12921244..6ec3b187 100644
--- a/MIGRATING.md
+++ b/MIGRATING.md
@@ -53,8 +53,10 @@ Without the filter rule, an optimized app can read API responses but fail while
## Installing and releasing the package
-This change builds and tests the SDK without publishing it. `gradle.properties` keeps `version=0.0.0`, and the release workflow refuses to publish that placeholder. Generated metadata records the generator's input version; the release workflow stamps the artifact, source headers, and metadata from `gradle.properties` before building them.
+See [INSTALL.md](INSTALL.md) for public Gradle and Maven installation. The coordinate is `com.whop.api:whop-java`, served without credentials from `https://whopio.github.io/whopsdk-java/`.
-After this change is merged, release with a separate pull request that changes only `version=0.0.0` to the approved version in `gradle.properties` (for example, `version=2.8.1`). Merging that version-only change publishes to GitHub Packages by default. Pull request runs always rehearse the release without uploading. Java releases use an explicit version and are outside the shared SDK release train.
+Release with a separate pull request that changes only the version property in `gradle.properties`. The placeholder `0.0.0` never publishes. The workflow stamps source headers, metadata, and artifact version from that file, runs the SDK tests and an installed Maven consumer, preserves the immutable bundle on the `maven` branch, and deploys the repository to GitHub Pages. An anonymous consumer must pass before the release is tagged. Pull request runs rehearse without write permissions or uploads. Java releases use an explicit version and are outside the shared SDK release train.
-GitHub Packages consumers use `com.whop.api:whop-java:` with the repository `https://maven.pkg.github.com/whopio/whopsdk-java` and GitHub package-read credentials. A public Maven Central release additionally needs verified ownership of the `com.whop` namespace and signing/publishing credentials in a main-only `maven-central` GitHub Environment. Select the Maven Central target only after those prerequisites are configured.
+Configure GitHub Pages with the GitHub Actions publishing source and a `github-pages` Environment restricted to `main` before the first release. A retry from the same source commit reuses verified stored artifact bytes. It refuses to replace an existing version from another commit or publish a version older than an existing one.
+
+The optional GitHub Packages target uses `https://maven.pkg.github.com/whopio/whopsdk-java` and requires package-read credentials for consumers. The optional Maven Central target additionally needs verified ownership of the `com.whop` namespace and signing/publishing credentials in a main-only `maven-central` GitHub Environment. Select that target only after those prerequisites are configured.
diff --git a/README.md b/README.md
index 183dcf5b..75b9f005 100644
--- a/README.md
+++ b/README.md
@@ -30,6 +30,10 @@ API reference documentation is available [here](https://docs.whop.com/api-refere
A full reference for this library is available [here](./reference.md).
+## Installation
+
+See [INSTALL.md](INSTALL.md) for public Gradle, Android, and Maven installation instructions.
+
## Usage
Instantiate and use the client with the following: