Skip to content

Commit 94e8b0f

Browse files
authored
Merge branch 'master' into patch-1
2 parents e24324b + 1b174d3 commit 94e8b0f

File tree

112 files changed

+13698
-1436
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

112 files changed

+13698
-1436
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: Generate Java Docs
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
8+
jobs:
9+
build:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- name: Checkout code
14+
uses: actions/checkout@v2
15+
16+
- name: Set up JDK 11
17+
uses: actions/setup-java@v4
18+
with:
19+
java-version: 11
20+
distribution: corretto
21+
22+
- name: Build with Maven
23+
run: mvn clean install
24+
25+
- name: Generate Javadocs
26+
run: mvn javadoc:javadoc
27+
28+
# Publishes Javadocs to GitHub Pages by pushing to `gh-pages` branch
29+
- name: Deploy Javadocs to GitHub Pages
30+
run: |
31+
git config --global user.name 'github-actions[bot]'
32+
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
33+
mvn scm-publish:publish-scm
34+
env:
35+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/release.yml

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,25 +20,24 @@ jobs:
2020
java-version: 11
2121
distribution: corretto
2222
cache: maven
23-
server-id: ossrh # Value of distributionManagement.repository.id field of pom.xml
23+
server-id: central # Value of distributionManagement.repository.id field of pom.xml
2424
server-username: MAVEN_USERNAME
2525
server-password: MAVEN_PASSWORD
2626
settings-path: ${{ github.workspace }} # Location for settings.xml file
27-
gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }}
27+
gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY_ABHI }}
2828
gpg-passphrase: GPG_PASSPHRASE
2929

3030
- name: Publish with Maven deploy
31-
run: >
32-
mvn
33-
--batch-mode
34-
--activate-profiles deploy
35-
--settings $GITHUB_WORKSPACE/settings.xml
36-
-Pcoverage
37-
clean deploy
31+
run: |
32+
if [ "${{ env.ACTIONS_STEP_DEBUG }}" == "true" ]; then
33+
mvn --batch-mode --activate-profiles deploy --settings $GITHUB_WORKSPACE/settings.xml -Pcoverage clean deploy -X
34+
else
35+
mvn --batch-mode --activate-profiles deploy --settings $GITHUB_WORKSPACE/settings.xml -Pcoverage clean deploy
36+
fi
3837
env:
3938
MAVEN_USERNAME: ${{ secrets.NEXUS_USERNAME }}
4039
MAVEN_PASSWORD: ${{ secrets.NEXUS_PASSWORD }}
41-
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
40+
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE_ABHI }}
4241

4342
- name: Upload coverage to Codecov
4443
uses: codecov/codecov-action@v3

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ target
1111
.idea
1212
*.iml
1313

14+
## VS Code
15+
.vscode
16+
1417
## Logs
1518
*.log
1619

@@ -27,3 +30,6 @@ dependency-reduced-pom.xml
2730
# mvn release
2831
pom.xml.releaseBackup
2932
release.properties
33+
34+
# macOS
35+
.DS_Store

CONTRIBUTING.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ alternative to the GitHub API.
55

66
## Getting Started
77

8-
The Github Java Clients's [open issues are here](https://github.com/github-java-client/github-java-client/issues).
8+
The Github Java Clients's [open issues are here](https://github.com/spotify/github-java-client/issues).
99
In time, we'll tag issues that would make a good first pull request for new contributors. An easy
1010
way to get started helping the project is to *file an issue*. Issues can include bugs to fix,
1111
features to add, or documentation that looks outdated.
@@ -39,4 +39,4 @@ feedback for changes that would be required.
3939
[/orgs/{org}/teams/{team_slug}](https://docs.github.com/en/rest/teams/teams?apiVersion=2022-11-28#list-teams) endpoint
4040
- We operate a monkey see, monkey do approach to this library. We understand that there are some inconsistencies in the library
4141
in terms of how the tests and/or endpoints are written but we, with your help, are working on creating a more consistent codebase.
42-
- All bug fixes and new features need to be fully tested.
42+
- All bug fixes and new features need to be fully tested.

README.md

Lines changed: 113 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
![lifecycle: beta](https://img.shields.io/badge/lifecycle-beta-509bf5.svg)
44
[![Maven Central](https://img.shields.io/maven-central/v/com.spotify/github-client)](https://mvnrepository.com/artifact/com.spotify/github-client)
55

6-
76
# github-java-client
87

98
A small Java library for talking to GitHub/GitHub Enterprise and interacting with projects.
@@ -22,11 +21,13 @@ You can find this library in [maven central repository](https://mvnrepository.co
2221
Include the latest version of github-client into your project:
2322

2423
In Maven:
24+
2525
```xml
26+
2627
<dependency>
27-
<groupId>com.spotify</groupId>
28-
<artifactId>github-client</artifactId>
29-
<version>version</version>
28+
<groupId>com.spotify</groupId>
29+
<artifactId>github-client</artifactId>
30+
<version>version</version>
3031
</dependency>
3132
```
3233

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

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

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

6162
It is also possible to provide the installation to the root client.
6263

63-
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.
6467

6568
## Usage
6669

67-
This library attempts to mirror the structure of GitHub API endpoints. As an example, to get details of a Commit, there is
68-
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.
6974

7075
```java
7176
final RepositoryClient repositoryClient = githubClient.createRepositoryClient("my-org", "my-repo");
@@ -74,20 +79,62 @@ log.info(repositoryClient.getCommit("sha").get().htmlUrl());
7479

7580
Another example of the mirrored structure is that some of the APIs are nested under a parent API.
7681
For example, endpoints related to check runs or issues are nested under the Repository client:
82+
7783
```java
7884
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:
95+
8896
```java
8997
final TeamClient teamClient = organisationClient.createTeamClient();
90-
teamClient.getMembership("username");
98+
teamClient.getMembership("username");
99+
```
100+
101+
## Tracing
102+
103+
The GitHub client supports tracing via both OpenCensus and OpenTelemetry. Since OpenCensus is deprecated, we recommend
104+
using OpenTelemetry. Using OpenTelemetry also enables context propagation when using this library.
105+
To enable tracing, you need to provide a tracer when initializing the client.
106+
107+
### OpenTelemetry
108+
109+
```java
110+
import com.spotify.github.tracing.opentelemetry.OpenTelemetryTracer;
111+
112+
final GitHubClient githubClient =
113+
GitHubClient.create(baseUri, accessToken)
114+
// Uses GlobalOpenTelemetry.get() to fetch the default tracer
115+
.withTracer(new OpenTelemetryTracer());
116+
```
117+
118+
You can also provide a custom `OpenTelemetry` object if you want to use a specific one.
119+
120+
```java
121+
import com.spotify.github.tracing.opentelemetry.OpenTelemetryTracer;
122+
123+
final GitHubClient githubClient =
124+
GitHubClient.create(baseUri, accessToken)
125+
// Uses custom openTelemetry object to fetch the tracer
126+
.withTracer(new OpenTelemetryTracer(openTelemetry));
127+
```
128+
129+
### OpenCensus
130+
131+
```java
132+
import com.spotify.github.tracing.opencensus.OpenCensusTracer;
133+
134+
final GitHubClient githubClient =
135+
GitHubClient.create(baseUri, accessToken)
136+
// Uses Tracing.getTracer() to fetch the default tracer
137+
.withTracer(new OpenCensusTracer());
91138
```
92139

93140
## Supported Java versions
@@ -104,9 +151,14 @@ This project uses Maven. To run the tests locally, just run:
104151
mvn clean verify
105152
```
106153

107-
If you are a maintainer, you can release a new version by just triggering the workflow
108-
[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
109160
[web UI](https://github.com/spotify/github-java-client/actions/workflows/prepare-release.yml).
161+
110162
- Select whether the new release should be a `major`, `minor` or `patch` release
111163
- Trigger the release preparation on the `master` branch
112164
- Pushes of this workflow will trigger runs of the
@@ -115,15 +167,56 @@ If you are a maintainer, you can release a new version by just triggering the wo
115167
[github-release](https://github.com/spotify/github-java-client/actions/workflows/release-on-github.yml)
116168
workflow with the automatically created tag
117169

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+
118206
## Notes about maturity
119207

120208
This module was created after existing libraries were evaluated and dismissed, and we found that we were writing similar
121-
code in multiple projects. As such, it at least initially only contains enough functionality for our internal requirements
122-
which reflects that we were working on build system integration with the GitHub pull requests. It has been widely used for 4+
123-
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.
124215
Pull Requests are welcome.
125216
126217
## Code of conduct
127-
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.
128221
129222
[code-of-conduct]: https://github.com/spotify/code-of-conduct/blob/master/code-of-conduct.md

0 commit comments

Comments
 (0)