|
1 | 1 | # Publishing
|
2 | 2 |
|
3 |
| -## Prerequisites |
4 |
| - |
5 |
| -> Both methods can be mixed because if a variable is not found, it will try to get it using the |
6 |
| -> another method. |
7 |
| -
|
8 |
| -### Using Gradle properties method |
9 |
| - |
10 |
| -> It is recommended to set the next properties in the `$home/.gradle/gradle.properties` file instead |
11 |
| -> of using the project `gradle.properties`. |
12 |
| -> |
13 |
| -> Another alternative is setting them via CLI, i.e.: |
14 |
| -> `./gradlew -P"signing.gnupg.keyName"="[keyName]"`. |
15 |
| -
|
16 |
| -1. Generate key: `gpg --full-generate-key` |
17 |
| -2. Check key name: `gpg --list-signatures` |
18 |
| -3. Upload to server: `gpg --keyserver hkps://keys.openpgp.org --send-keys [keyName]` |
19 |
| -4. Show the private key: `gpg --armor --export-secret-keys [keyName]` |
20 |
| -5. Add Nexus user: `oss.user=[user]` |
21 |
| -6. Add Nexus token: `oss.token=[token]` |
22 |
| -7. Add Nexus profileId: `oss.stagingProfileId=[stagingProfileId]` |
23 |
| - 1. Visit this [link](https://oss.sonatype.org/#stagingProfiles), select your profile and copy |
24 |
| - `SOME_NUMBER` from the url `https://oss.sonatype.org/#stagingProfiles;SOME_NUMBERS` |
25 |
| -8. Add KeyName (optional with `useInMemoryPgpKeys`): `signing.gnupg.keyName=[keyName]` |
26 |
| -9. Add KeyId (optional with `useInMemoryPgpKeys` and `useCpgCmd`): `signing.gnupg.keyId=[keyId]` |
27 |
| -10. Add Key (replace line breaks with `\n`, optional with `useGpgCmd`): `signing.gnupg.key=[key]` |
28 |
| -11. Add Passphrase: `signing.gnupg.passphrase=[passphrase]` |
29 |
| - |
30 |
| -### Using environment variables method |
31 |
| - |
32 |
| -1. Generate key: `gpg --full-generate-key` |
33 |
| -2. Check key id: `gpg --list-signatures` |
34 |
| -3. Upload to server: `gpg --keyserver hkps://keys.openpgp.org --send-keys [keyId]` |
35 |
| -4. Add Nexus user: `OSS_USER` |
36 |
| -5. Add Nexus token: `OSS_TOKEN` |
37 |
| -6. Add Nexus profileId: `OSS_STAGING_PROFILE_ID` |
38 |
| - 1. Visit this [link](https://oss.sonatype.org/#stagingProfiles), select your profile and copy |
39 |
| - `SOME_NUMBER` from the url `https://oss.sonatype.org/#stagingProfiles;SOME_NUMBERS` |
40 |
| -7. Add KeyName (optional with `useInMemoryPgpKeys`): `SIGNING_KEY_NAME=[keyName]` |
41 |
| -8. Add KeyId (optional with `useInMemoryPgpKeys` and `useCpgCmd`): `SIGNING_KEY_ID=[keyId]` |
42 |
| -9. Add Key (replace line breaks with `\n`, optional with `useGpgCmd`): `SIGNING_KEY=[key]` |
43 |
| - 1. If it is used as secret in GitHub, it is not necessary to replace all line breaks with `\n` |
44 |
| -10. Add Passphrase: `SIGNING_KEY_PASSPHRASE=[passphrase]` |
45 |
| - |
46 |
| -### Minimum amount of secrets for publishing via GitHub Actions |
47 |
| - |
48 |
| -- With `useInMemoryPgpKeys` (used by default): |
49 |
| - |
50 |
| -1. `OSS_USER` |
51 |
| -2. `OSS_TOKEN` |
52 |
| -3. `OSS_STAGING_PROFILE_ID` |
53 |
| -4. `SIGNING_KEY_PASSPHRASE` |
54 |
| -5. `SIGNING_KEY` |
55 |
| -6. `SIGNING_KEY_ID` (optional) |
56 |
| - |
57 |
| -- With `useCpgCmd` (if the previous method fails, this will be used): |
58 |
| - |
59 |
| -1. `OSS_USER` |
60 |
| -2. `OSS_TOKEN` |
61 |
| -3. `OSS_STAGING_PROFILE_ID` |
62 |
| -4. `SIGNING_KEY_NAME` |
63 |
| -5. `SIGNING_KEY_PASSPHRASE` |
64 |
| -6. `SIGNING_KEY` |
65 |
| - |
66 |
| -> You can use these utilities: |
67 |
| -> - Kleopatra, GUI for Windows |
68 |
| -> - GPG Suite (GPGTools), GUI for macOS |
69 |
| -> - `crazy-max/ghaction-import-gpg` action to import the GPG key. |
70 |
| -
|
71 |
| -## Publish the artifacts |
72 |
| - |
73 |
| -`useInMemoryPgpKeys` will be used by the default, if it crashes, `useGpgCmd` will be used. |
74 |
| - |
75 |
| -### Snapshot |
76 |
| - |
77 |
| -The version should end with `-SNAPSHOT` |
78 |
| - |
79 |
| -``` |
80 |
| -./gradlew publishToSonatype -P"reckon.stage"="snapshot" |
81 |
| -``` |
82 |
| - |
83 |
| -### Release |
84 |
| - |
85 |
| -``` |
86 |
| -./gradlew publishToSonatype -P"reckon.stage"="[stage]" -P"reckon.scope"="[scope]" |
87 |
| -``` |
| 3 | +Check [publishing](https://github.com/JavierSegoviaCordoba/gradle-plugins/blob/main/.github/PUBLISHING.md) |
| 4 | +from [JavierSC Gradle plugins](https://github.com/JavierSegoviaCordoba/gradle-plugins/) |
0 commit comments