diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 998c77d..0c0acbc 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -88,7 +88,11 @@ jobs:
test -s "$file"
done
grep -F 'Decision: PUBLISHED PUBLIC BETA.' docs/RELEASE.md
- - name: Build release candidate
+ - name: Verify publication guard
+ # The publisher uses only Python's standard library and is not part of the Java runtime.
+ shell: bash
+ run: python3 -B -m unittest discover -s scripts/tests -v
+ - name: Build release artifacts
shell: bash
run: ./mvnw --batch-mode --no-transfer-progress -Prelease-candidate -DskipTests verify
- name: Check reviewed public API signatures
diff --git a/.github/workflows/publish-release.yml b/.github/workflows/publish-release.yml
new file mode 100644
index 0000000..1a9034a
--- /dev/null
+++ b/.github/workflows/publish-release.yml
@@ -0,0 +1,60 @@
+name: Publish reviewed Maven Central deployment
+
+on:
+ workflow_dispatch:
+ inputs:
+ version:
+ description: Final semantic version of the reviewed signed release
+ required: true
+ type: string
+ deployment_id:
+ description: Exact validated Central deployment UUID whose bundle was reviewed
+ required: true
+ type: string
+ mode:
+ description: Inspect or publish the reviewed immutable version
+ required: true
+ default: inspect
+ type: choice
+ options: [inspect, publish]
+
+permissions:
+ contents: read
+
+concurrency:
+ group: maven-central-publication
+ cancel-in-progress: false
+
+jobs:
+ publish:
+ runs-on: ubuntu-latest
+ environment: maven-central
+ timeout-minutes: 5
+ steps:
+ - uses: actions/checkout@v7
+ with:
+ fetch-depth: 0
+ - name: Verify release inputs and signed tag
+ shell: bash
+ env:
+ VERSION: ${{ inputs.version }}
+ SIGNER: 8F7C42989C49216FA75523251BB3BFA38C776312
+ run: |
+ set -euo pipefail
+ test "$GITHUB_REF_TYPE" = branch
+ test "$GITHUB_REF_NAME" = main
+ [[ "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]
+ test "$(git cat-file -t "refs/tags/v$VERSION")" = tag
+ git merge-base --is-ancestor "refs/tags/v$VERSION" HEAD
+ curl --fail --silent --show-error \
+ "https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x$SIGNER" | gpg --batch --import
+ git verify-tag --raw "v$VERSION" 2>"$RUNNER_TEMP/tag-status"
+ grep -F "[GNUPG:] VALIDSIG $SIGNER " "$RUNNER_TEMP/tag-status"
+ - name: Inspect or publish the exact validated deployment
+ env:
+ MAVEN_CENTRAL_USERNAME: ${{ secrets.MAVEN_CENTRAL_USERNAME }}
+ MAVEN_CENTRAL_PASSWORD: ${{ secrets.MAVEN_CENTRAL_PASSWORD }}
+ VERSION: ${{ inputs.version }}
+ DEPLOYMENT_ID: ${{ inputs.deployment_id }}
+ MODE: ${{ inputs.mode }}
+ run: python3 scripts/publish-central.py --version "$VERSION" --deployment-id "$DEPLOYMENT_ID" --mode "$MODE"
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index 42078c1..7898555 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -73,7 +73,10 @@ jobs:
- name: Verify the exact release candidate
shell: bash
run: ./mvnw --batch-mode --no-transfer-progress -Prelease-candidate verify
- - name: Upload a signed user-managed Central deployment
+ - name: Check reviewed release API signatures
+ shell: pwsh
+ run: ./scripts/check-public-api.ps1
+ - name: Upload the verified Central bundle
shell: bash
env:
MAVEN_CENTRAL_USERNAME: ${{ secrets.MAVEN_CENTRAL_USERNAME }}
diff --git a/CHANGELOG.md b/CHANGELOG.md
index bf0f11d..1bb5900 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -7,6 +7,8 @@ uses semantic versioning for public releases.
### Added
+- protected inspection/publication of reviewed Maven Central deployments with exact-coordinate
+ checks and environment-backed credentials;
- declarative type/package cycle rules with `kind=cycles` in the properties/JUnit integration;
- an explicit v1 compatibility scope and public/protected API signature regression gate.
diff --git a/docs/RELEASE.md b/docs/RELEASE.md
index e573625..b1acc08 100644
--- a/docs/RELEASE.md
+++ b/docs/RELEASE.md
@@ -126,3 +126,9 @@ failure occurs only after bundle creation; CI then verifies the signed primary,
POM entries in `central-bundle.zip`. This exercises the bundler while making a remote upload
impossible. The protected release workflow performs the corresponding credentialed upload with
`autoPublish=false`.
+
+After reviewing the retained bundle, `publish-release.yml` can inspect or publish the exact
+deployment ID using the same protected environment. It verifies the signed release tag and
+accepts only the expected Maven coordinate in a validated or already publishing state. Credentials
+remain environment-backed; inspect mode never requests publication. Once published, confirm the
+public artifacts from a clean Maven repository before marking the GitHub release stable.
diff --git a/pom.xml b/pom.xml
index 5b368bf..ebe7836 100644
--- a/pom.xml
+++ b/pom.xml
@@ -8,7 +8,7 @@
archunitjava
1.0.0-SNAPSHOT
ArchUnitJava
- Public-beta static architecture analysis and executable architecture policies for Java
+ Static architecture analysis and executable architecture policies for Java
https://github.com/dragonsec-ai/ArchUnitJava
diff --git a/scripts/publish-central.py b/scripts/publish-central.py
new file mode 100644
index 0000000..550969f
--- /dev/null
+++ b/scripts/publish-central.py
@@ -0,0 +1,75 @@
+"""Inspect or publish one reviewed Central deployment using environment-backed credentials."""
+
+import argparse
+import base64
+import json
+import os
+import re
+import urllib.error
+import urllib.parse
+import urllib.request
+import uuid
+
+BASE_URL = "https://central.sonatype.com/api/v1/publisher"
+
+
+def validate_inputs(deployment_id, version):
+ if str(uuid.UUID(deployment_id)) != deployment_id:
+ raise ValueError("Expected a canonical deployment UUID")
+ if not re.fullmatch(r"[0-9]+\.[0-9]+\.[0-9]+", version):
+ raise ValueError("Expected a final semantic release version")
+
+
+def validate_status(status, deployment_id, version):
+ """Accept only the exact component in a validated or already publishing state."""
+ validate_inputs(deployment_id, version)
+ if not isinstance(status, dict) or status.get("deploymentId") != deployment_id:
+ raise ValueError("Central returned a different deployment ID")
+ expected = f"pkg:maven/io.github.tristankruse/archunitjava@{version}"
+ if status.get("purls") != [expected]:
+ raise ValueError("Deployment must contain exactly the expected Maven coordinate")
+ if status.get("deploymentState") not in {"VALIDATED", "PUBLISHING", "PUBLISHED"}:
+ raise ValueError("Deployment has not passed validation")
+ return status["deploymentState"]
+
+
+class NoRedirects(urllib.request.HTTPRedirectHandler):
+ def redirect_request(self, req, fp, code, msg, headers, newurl):
+ raise RuntimeError("Central redirects are not accepted")
+
+
+def request(path, token):
+ req = urllib.request.Request(BASE_URL + path, method="POST",
+ headers={"Authorization": "Bearer " + token})
+ try:
+ with urllib.request.build_opener(NoRedirects()).open(req, timeout=60) as response:
+ data = response.read(1_048_577)
+ if len(data) > 1_048_576:
+ raise ValueError("Central response exceeded the size limit")
+ return data
+ except urllib.error.HTTPError as error:
+ # Never echo headers, credentials or arbitrary server bodies into CI logs.
+ raise RuntimeError(f"Central request failed with HTTP {error.code}") from None
+
+
+def main():
+ parser = argparse.ArgumentParser(description=__doc__)
+ parser.add_argument("--deployment-id", required=True)
+ parser.add_argument("--version", required=True)
+ parser.add_argument("--mode", choices=("inspect", "publish"), default="inspect")
+ args = parser.parse_args()
+ validate_inputs(args.deployment_id, args.version)
+ credentials = os.environ["MAVEN_CENTRAL_USERNAME"] + ":" + os.environ["MAVEN_CENTRAL_PASSWORD"]
+ token = base64.b64encode(credentials.encode("utf-8")).decode("ascii")
+ status = json.loads(request("/status?" + urllib.parse.urlencode({"id": args.deployment_id}), token))
+ state = validate_status(status, args.deployment_id, args.version)
+ print(json.dumps({"deploymentId": args.deployment_id, "version": args.version, "state": state}))
+ if args.mode == "publish" and state == "VALIDATED":
+ request("/deployment/" + args.deployment_id, token)
+ print("Publication requested for the reviewed, validated deployment.")
+ elif args.mode == "publish":
+ print("Publication already requested; no duplicate request sent.")
+
+
+if __name__ == "__main__":
+ main()
diff --git a/scripts/tests/test_publish_central.py b/scripts/tests/test_publish_central.py
new file mode 100644
index 0000000..ea1abb0
--- /dev/null
+++ b/scripts/tests/test_publish_central.py
@@ -0,0 +1,68 @@
+import importlib.util
+from pathlib import Path
+import unittest
+from unittest.mock import patch
+import json
+
+spec = importlib.util.spec_from_file_location(
+ "publish_central", Path(__file__).resolve().parents[1] / "publish-central.py")
+central = importlib.util.module_from_spec(spec)
+spec.loader.exec_module(central)
+DEPLOYMENT = "12dfc7c7-4015-4fbf-887e-bc3103ff6560"
+
+
+class PublicationGuardTest(unittest.TestCase):
+ def status(self):
+ return {"deploymentId": DEPLOYMENT, "deploymentState": "VALIDATED",
+ "purls": ["pkg:maven/io.github.tristankruse/archunitjava@1.0.0"]}
+
+ def test_exact_validated_or_published_component_is_accepted(self):
+ for state in ("VALIDATED", "PUBLISHING", "PUBLISHED"):
+ self.assertEqual(state, central.validate_status(
+ {**self.status(), "deploymentState": state}, DEPLOYMENT, "1.0.0"))
+
+ def test_wrong_id_version_package_and_extra_components_are_rejected(self):
+ for key, value in (
+ ("deploymentId", "00000000-0000-0000-0000-000000000000"),
+ ("purls", ["pkg:maven/io.github.tristankruse/archunitjava@0.1.0"]),
+ ("purls", ["pkg:maven/other/package@1.0.0"]),
+ ("purls", self.status()["purls"] * 2),
+ ("purls", []),
+ ):
+ with self.subTest(key=key, value=value), self.assertRaises(ValueError):
+ central.validate_status({**self.status(), key: value}, DEPLOYMENT, "1.0.0")
+
+ def test_unvalidated_missing_and_failed_states_are_rejected(self):
+ for state in (None, "FAILED", "PENDING", "VALIDATING", "DELETED"):
+ with self.subTest(state=state), self.assertRaises(ValueError):
+ central.validate_status({**self.status(), "deploymentState": state}, DEPLOYMENT, "1.0.0")
+
+ def test_nonfinal_versions_and_noncanonical_ids_are_rejected(self):
+ for version in ("1.0.0-SNAPSHOT", "1.0.0-rc.1", "1.0.0\n", "../1.0.0"):
+ with self.subTest(version=version), self.assertRaises(ValueError):
+ central.validate_status(self.status(), DEPLOYMENT, version)
+ for deployment in ("../release", DEPLOYMENT.upper(), "not-a-uuid"):
+ with self.subTest(deployment=deployment), self.assertRaises(ValueError):
+ central.validate_status(self.status(), deployment, "1.0.0")
+
+ def run_main(self, mode, status):
+ with patch("sys.argv", ["publish-central.py", "--deployment-id", DEPLOYMENT,
+ "--version", "1.0.0", "--mode", mode]), \
+ patch.dict("os.environ", {"MAVEN_CENTRAL_USERNAME": "test", "MAVEN_CENTRAL_PASSWORD": "test"}), \
+ patch.object(central, "request", return_value=json.dumps(status).encode()) as request, \
+ patch("builtins.print"):
+ central.main()
+ return [call.args[0] for call in request.call_args_list]
+
+ def test_inspect_does_not_publish_and_publish_is_idempotent(self):
+ self.assertEqual(1, len(self.run_main("inspect", self.status())))
+ self.assertEqual("/deployment/" + DEPLOYMENT, self.run_main("publish", self.status())[-1])
+ self.assertEqual(1, len(self.run_main("publish", {**self.status(), "deploymentState": "PUBLISHED"})))
+
+ def test_mismatched_deployment_is_never_published(self):
+ with self.assertRaises(ValueError):
+ self.run_main("publish", {**self.status(), "purls": []})
+
+
+if __name__ == "__main__":
+ unittest.main()