Skip to content

Commit e7c9e9d

Browse files
rix0rrrmrgraingithub-actions
authored
fix: support new Maven central publishing method (#1667)
* fix: support new Maven central publishing method Maven Central is deprecating its old Nexus 2 OSSRH endpoint, replacing it with a new plugin and protocol, and a compatibility endpoint. I just want to migrate to the new publishing mode ------------------------------------------------- To migrate, do the following: * Configure `MAVEN_SERVER_ID=central-ossrh`, * Log in to <https://central.sonatype.com/> * Generate a new username and password on the new publisher using the **Generate User Token** feature. * Configure `MAVEN_STAGING_PROFILE_ID` with your package namespace (register it first if necessary) I'm going to review this PR --------------------------- Because the new plugin doesn't support our 2-stage publishing method yet, we are using the compatibility endpoint. The compatibility endpoint works mostly with the `nexus-staging-maven-plugin` for uploading jars, but the "release" command doesn't work because of a protocol incompatibility. So instead, we are using a new custom HTTP request for the very final "release" command, which is a slightly different version of what the Nexus plugin sends, but *is* accepted by the endpoint. Because the old script was in bash and hard to understand and modify, I've rewritten it to TypeScript with zx, to at least get better type checking and parameter modeling. Also described the various parameters better in the README. * Update README.md Co-authored-by: Momo Kornher <[email protected]> * chore: self mutation Signed-off-by: github-actions <[email protected]> * chore: self mutation Signed-off-by: github-actions <[email protected]> * Bit o' clarification * Update README.md * Better way of passing the same vars --------- Signed-off-by: github-actions <[email protected]> Co-authored-by: Momo Kornher <[email protected]> Co-authored-by: github-actions <[email protected]>
1 parent 8047a93 commit e7c9e9d

File tree

16 files changed

+1204
-713
lines changed

16 files changed

+1204
-713
lines changed

.eslintrc.json

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

.github/workflows/pull-request-lint.yml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.github/workflows/release.yml

Lines changed: 1 addition & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.projen/deps.json

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

.projen/tasks.json

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

.projenrc.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ const project = new cdklabs.CdklabsTypeScriptProject({
1616
'ts-node',
1717
'@aws-sdk/client-sts',
1818
'@types/glob',
19-
'@types/node@^14.17.0',
19+
'@types/node@^18.17.0',
2020
'@types/yargs@^17',
2121
'cdklabs-projen-project-types',
2222
],
@@ -27,12 +27,16 @@ const project = new cdklabs.CdklabsTypeScriptProject({
2727
'@aws-sdk/types',
2828
'[email protected]', // Can't use a newer version of glob, it adds a CLI that depends on 'jackspeak' which has crazy dependencies
2929
'yargs@^17',
30+
'zx',
3031
'p-queue@6', // Last non-ESM version
3132
],
3233
enablePRAutoMerge: true,
3334
setNodeEngineVersion: false,
3435
});
3536

37+
// Necessary to work around a typing issue in transitive dependency lru-cache@10 now that we've moved to a modern TS
38+
project.package.addPackageResolutions('lru-cache@^11');
39+
3640
// we can't use 9.x because it doesn't work with node 10.
3741
const fsExtraVersion = '^8.0.0';
3842

CONTRIBUTING.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# How to work on this repository
2+
3+
## Testing Maven publishing
4+
5+
- Create a Sonatype account at <https://central.sonatype.com/account>. You can use GitHub to sign in.
6+
- Generate a user token, note the username and password.
7+
- Generate an empty project and give it a jsii config. Example:
8+
9+
```
10+
{
11+
"jsii": {
12+
"versionFormat": "full",
13+
"targets": {
14+
"java": {
15+
"package": "test.test",
16+
"maven": {
17+
"groupId": "test.test",
18+
"artifactId": "test"
19+
}
20+
}
21+
},
22+
"outdir": "dist"
23+
},
24+
}
25+
```
26+
27+
Follow the instructions in the README for creating and exporting a GPG key.
28+
29+
Then run the following command:
30+
31+
```
32+
env MAVEN_GPG_PRIVATE_KEY_FILE=$PWD/mykey.priv MAVEN_GPG_PRIVATE_KEY_PASSPHRASE=mypassphrase MAVEN_STAGING_PROFILE_ID=com.sonatype.software MAVEN_SERVER_ID=central-ossrh MAVEN_USERNAME=**** MAVEN_PASSWORD=**** /path/to/publib/bin/publib-maven
33+
```

0 commit comments

Comments
 (0)