Skip to content

Commit cce9012

Browse files
authored
docs: Update the docs about GPG keys (#249)
1 parent f8130c3 commit cce9012

File tree

1 file changed

+71
-19
lines changed

1 file changed

+71
-19
lines changed

README.md

Lines changed: 71 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,13 @@ You can find this library in [maven central repository](https://mvnrepository.co
2121
Include the latest version of github-client into your project:
2222

2323
In Maven:
24+
2425
```xml
26+
2527
<dependency>
26-
<groupId>com.spotify</groupId>
27-
<artifactId>github-client</artifactId>
28-
<version>version</version>
28+
<groupId>com.spotify</groupId>
29+
<artifactId>github-client</artifactId>
30+
<version>version</version>
2931
</dependency>
3032
```
3133

@@ -43,10 +45,10 @@ To authenticate as a GitHub App, you must provide a private key and the App ID,
4345

4446
```java
4547
final GitHubClient githubClient =
46-
GitHubClient.create(
47-
URI.create("https://api.github.com/"),
48-
new File("/path-to-the/private-key.pem"),
49-
APP_ID);
48+
GitHubClient.create(
49+
URI.create("https://api.github.com/"),
50+
new File("/path-to-the/private-key.pem"),
51+
APP_ID);
5052
```
5153

5254
Then, you can scope the client for a specific Installation ID, to do the operations at the installation level.
@@ -59,12 +61,16 @@ final GitHubClient scopedClient = GitHubClient.scopeForInstallationId(githubClie
5961

6062
It is also possible to provide the installation to the root client.
6163

62-
Refer to [GitHub App Authentication Guide](https://developer.github.com/apps/building-github-apps/authenticating-with-github-apps/) for more information.
64+
Refer
65+
to [GitHub App Authentication Guide](https://developer.github.com/apps/building-github-apps/authenticating-with-github-apps/)
66+
for more information.
6367

6468
## Usage
6569

66-
This library attempts to mirror the structure of GitHub API endpoints. As an example, to get details of a Commit, there is
67-
the `GET /repos/:owner/:repo/commits` API call, under the `repos` API. Therefore, the `getCommit` method lives in the RepositoryClient.
70+
This library attempts to mirror the structure of GitHub API endpoints. As an example, to get details of a Commit, there
71+
is
72+
the `GET /repos/:owner/:repo/commits` API call, under the `repos` API. Therefore, the `getCommit` method lives in the
73+
RepositoryClient.
6874

6975
```java
7076
final RepositoryClient repositoryClient = githubClient.createRepositoryClient("my-org", "my-repo");
@@ -79,16 +85,17 @@ final ChecksClient checksClient = repositoryClient.createChecksApiClient();
7985
checksClient.createCheckRun(CHECK_RUN_REQUEST);
8086

8187
final IssueClient issueClient = repositoryClient.createIssueClient();
82-
issueClient.createComment(ISSUE_ID, "comment body")
83-
.thenAccept(comment -> log.info("created comment " + comment.htmlUrl()));
88+
issueClient
89+
.createComment(ISSUE_ID, "comment body")
90+
.thenAccept(comment ->log.info("created comment "+comment.htmlUrl()));
8491

8592
```
8693

8794
And endpoints related to teams and memberships are nested under the Organisation client:
8895

8996
```java
9097
final TeamClient teamClient = organisationClient.createTeamClient();
91-
teamClient.getMembership("username");
98+
teamClient.getMembership("username");
9299
```
93100

94101
## Tracing
@@ -144,8 +151,12 @@ This project uses Maven. To run the tests locally, just run:
144151
mvn clean verify
145152
```
146153

147-
If you are a maintainer, you can release a new version by just triggering the workflow
148-
[prepare-release](./.github/workflows/prepare-release.yml) through the
154+
### Maintainers
155+
156+
#### Publishing a new version
157+
158+
If you are a maintainer, you can release a new version by just triggering the workflow
159+
[prepare-release](./.github/workflows/prepare-release.yml) through the
149160
[web UI](https://github.com/spotify/github-java-client/actions/workflows/prepare-release.yml).
150161

151162
- Select whether the new release should be a `major`, `minor` or `patch` release
@@ -156,15 +167,56 @@ If you are a maintainer, you can release a new version by just triggering the wo
156167
[github-release](https://github.com/spotify/github-java-client/actions/workflows/release-on-github.yml)
157168
workflow with the automatically created tag
158169

170+
The `prepare-release` workflow will also update the snapshot version in the `pom.xml` file to the next version. The
171+
version which will be published to Maven Central will be the one specified in the `pom.xml` file (without the
172+
`-SNAPSHOT` suffix).
173+
174+
#### Updating the GPG signing key
175+
176+
If you need to update the GPG signing key used for signing the releases when the existing key expires, you can do so by
177+
following these steps:
178+
179+
1. Generate a new GPG key pair or use an existing one.
180+
If you don't have a GPG key pair, you can generate one using the following command:
181+
```bash
182+
gpg --full-generate-key
183+
```
184+
Follow the prompts to create your key pair. Make sure to remember the passphrase you set.
185+
2. List your GPG keys to find the key ID:
186+
```bash
187+
gpg --list-keys
188+
```
189+
Look for the `pub` line, which will show the key ID in the format `XXXXXXXX`.
190+
3. Export the public key to a file:
191+
```bash
192+
gpg --armor --export <KEY_ID> > publickey.asc
193+
```
194+
4. export the private key to a file:
195+
```bash
196+
gpg --armor --export-secret-key <KEY_ID> > privatekey.asc
197+
```
198+
5. Upload the private key to the GitHub repository secrets in `GPG_PRIVATE_KEY` and paste the contents of
199+
`privatekey.asc`.
200+
6. Update the passphrase in the `GPG_PASSPHRASE` secret with the passphrase you set when generating the key.
201+
7. Upload the public key to the OpenGpg key server at https://keys.openpgp.org/
202+
8. Make sure to verify the public key with your email address on OpenGPG and that it is available on the key server.
203+
9. Make sure that the release workflow is configured to use the `GPG_PRIVATE_KEY` and `GPG_PASSPHRASE` secrets.
204+
10. Run the release workflow to publish a new version of the library.
205+
159206
## Notes about maturity
160207

161208
This module was created after existing libraries were evaluated and dismissed, and we found that we were writing similar
162-
code in multiple projects. As such, it at least initially only contains enough functionality for our internal requirements
163-
which reflects that we were working on build system integration with the GitHub pull requests. It has been widely used for 4+
164-
years. It's important to notice that it does not cover all GitHub v3 API. Adding missing endpoints should be very straightforward.
209+
code in multiple projects. As such, it at least initially only contains enough functionality for our internal
210+
requirements
211+
which reflects that we were working on build system integration with the GitHub pull requests. It has been widely used
212+
for 4+
213+
years. It's important to notice that it does not cover all GitHub v3 API. Adding missing endpoints should be very
214+
straightforward.
165215
Pull Requests are welcome.
166216
167217
## Code of conduct
168-
This project adheres to the [Open Code of Conduct][code-of-conduct]. By participating, you are expected to honor this code.
218+
219+
This project adheres to the [Open Code of Conduct][code-of-conduct]. By participating, you are expected to honor this
220+
code.
169221
170222
[code-of-conduct]: https://github.com/spotify/code-of-conduct/blob/master/code-of-conduct.md

0 commit comments

Comments
 (0)