Skip to content

Commit 10a9420

Browse files
authored
Merge pull request #3 from pseudomuto/master
Update
2 parents 5c07d06 + a0aae67 commit 10a9420

File tree

11 files changed

+215
-0
lines changed

11 files changed

+215
-0
lines changed

Diff for: .github/workflows/release.yaml

+15
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,18 @@ jobs:
2929
args: release --rm-dist
3030
env:
3131
GITHUB_TOKEN: ${{ secrets.GH_RELEASE_TOKEN }}
32+
- name: Set up Java
33+
uses: actions/setup-java@v2
34+
with:
35+
java-version: '11'
36+
distribution: 'adopt'
37+
- name: Publish package
38+
uses: gradle/gradle-build-action@v2
39+
with:
40+
gradle-version: 7.4
41+
arguments: publish
42+
env:
43+
MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }}
44+
MAVEN_PASSWORD: ${{ secrets.OSSRH_TOKEN }}
45+
ORG_GRADLE_PROJECT_signingKey: ${{ secrets.ORG_GRADLE_PROJECT_SIGNINGKEY }}
46+
ORG_GRADLE_PROJECT_signingPassword: ${{ secrets.ORG_GRADLE_PROJECT_SIGNINGPASSWORD }}

Diff for: .gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1+
/.gradle
12
/bin
3+
/build
24
/coverage.txt
35
/dist
46
/tmp/

Diff for: CONTRIBUTING.md

+6
Original file line numberDiff line numberDiff line change
@@ -76,3 +76,9 @@ From an up-to-date master, do the following:
7676
1. `git push origin master --tags`.
7777

7878
Once the tag is on GitHub, the release action will handle pushing to docker and creating a release in GitHub.
79+
80+
### Publish the Maven artifacts
81+
82+
1. Head over to https://s01.oss.sonatype.org/#stagingRepositories
83+
1. Verify the contents of the staging repo and close it
84+
1. After successful closing (test suite is run), release the repo

Diff for: README.md

+3
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ If you'd like to install this locally, you can `go get` it.
2121

2222
Alternatively, you can download a pre-built release for your platform from the [releases][] page.
2323

24+
Finally, this plugin is also available on Maven Central. For details about how to use it, check out the [gradle
25+
example](examples/gradle).
26+
2427
## Invoking the Plugin
2528

2629
The plugin is invoked by passing the `--doc_out`, and `--doc_opt` options to the `protoc` compiler. The option has the

Diff for: build.gradle

+113
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
plugins {
2+
id 'maven-publish'
3+
id 'signing'
4+
}
5+
6+
group = 'io.github.pseudomuto'
7+
8+
publishing {
9+
publications {
10+
maven(MavenPublication) {
11+
groupId = 'io.github.pseudomuto'
12+
artifactId = rootProject.name
13+
version = System.getenv("GITHUB_REF_NAME")
14+
// Strip "v" from version number
15+
if (version.startsWith("v")) {
16+
version = version.substring(1)
17+
}
18+
19+
pom {
20+
name = groupId + ':' + rootProject.name
21+
description = 'This is a documentation generator plugin for the Google Protocol Buffers compiler (protoc). The plugin can generate HTML, JSON, DocBook, and Markdown documentation from comments in your .proto files.'
22+
url = 'https://github.com/pseudomuto/protoc-gen-doc'
23+
licenses {
24+
license {
25+
name = 'MIT License'
26+
url = 'https://github.com/pseudomuto/protoc-gen-doc/blob/master/LICENSE.md'
27+
}
28+
}
29+
developers {
30+
developer {
31+
id = 'pseudomuto'
32+
name = 'David Muto'
33+
34+
}
35+
}
36+
scm {
37+
connection = 'scm:git:[email protected]:pseudomuto/protoc-gen-doc.git'
38+
developerConnection = 'scm:git:[email protected]:pseudomuto/protoc-gen-doc.git'
39+
url = 'https://github.com/pseudomuto/protoc-gen-doc'
40+
}
41+
}
42+
43+
//linux 64 arm
44+
artifact("$buildDir/dist/protoc-gen-doc_linux_arm64") {
45+
classifier 'linux-aarch_64'
46+
extension 'exe'
47+
}
48+
//linux 64 intel
49+
artifact("$buildDir/dist/protoc-gen-doc_linux_amd64") {
50+
classifier 'linux-x86_64'
51+
extension 'exe'
52+
}
53+
//mac 64 arm
54+
artifact("$buildDir/dist/protoc-gen-doc_darwin_arm64") {
55+
classifier 'osx-aarch_64'
56+
extension 'exe'
57+
}
58+
//mac 64 intel
59+
artifact("$buildDir/dist/protoc-gen-doc_darwin_amd64") {
60+
classifier 'osx-x86_64'
61+
extension 'exe'
62+
}
63+
//windows 64 arm
64+
artifact("$buildDir/dist/protoc-gen-doc_windows_arm64") {
65+
classifier 'windows-aarch_64'
66+
extension 'exe'
67+
}
68+
//windows 64 intel
69+
artifact("$buildDir/dist/protoc-gen-doc_windows_amd64") {
70+
classifier 'windows-x86_64'
71+
extension 'exe'
72+
}
73+
}
74+
}
75+
76+
repositories {
77+
maven {
78+
name = "OSSRH"
79+
def releasesRepoUrl = "https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/"
80+
def snapshotsRepoUrl = "https://s01.oss.sonatype.org/content/repositories/snapshots/"
81+
url = version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl
82+
credentials {
83+
username = System.getenv("MAVEN_USERNAME")
84+
password = System.getenv("MAVEN_PASSWORD")
85+
}
86+
}
87+
}
88+
}
89+
90+
signing {
91+
def signingKey = project.getProperty('signingKey')
92+
def signingPassword = project.getProperty('signingPassword')
93+
useInMemoryPgpKeys(signingKey, signingPassword)
94+
sign publishing.publications.maven
95+
}
96+
97+
// A strange issue with signing meant that only the first files (with the same name) got signed.
98+
// To workaround this, rename all executables to include architecture.
99+
tasks.register('flattenDistDirectory', Copy) {
100+
from("$projectDir/dist") {
101+
include "**/protoc-gen-doc"
102+
include "**/protoc-gen-doc.exe"
103+
eachFile { file ->
104+
file.name = file.relativePath.parent.lastName
105+
file.relativePath = new RelativePath(true, file.relativePath.segments.drop(1))
106+
}
107+
includeEmptyDirs = false
108+
}
109+
into "$buildDir/dist"
110+
}
111+
112+
publish.dependsOn flattenDistDirectory
113+
signMavenPublication.mustRunAfter flattenDistDirectory

Diff for: examples/gradle/.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
.gradle/
2+
build/

Diff for: examples/gradle/README.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Gradle Example
2+
3+
This is an example project that leverages protoc-gen-doc. You can test it out by running `gradle generateProto`.
4+
5+
After a successful run, you should see `grpc-docs.md` in the _build/generated/source/proto/main/doc_ directory.

Diff for: examples/gradle/build.gradle

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
plugins {
2+
id 'java'
3+
id 'com.google.protobuf' version '0.8.18'
4+
}
5+
6+
protobuf {
7+
protoc {
8+
artifact = "com.google.protobuf:protoc:3.19.4"
9+
}
10+
plugins {
11+
doc {
12+
artifact = "io.github.pseudomuto:protoc-gen-doc:1.5.1"
13+
}
14+
}
15+
16+
generateProtoTasks {
17+
all().each { task ->
18+
task.plugins {
19+
doc {
20+
option 'markdown,grpc-docs.md'
21+
}
22+
}
23+
}
24+
}
25+
}
26+
27+
repositories {
28+
mavenCentral()
29+
}

Diff for: examples/gradle/settings.gradle

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
rootProject.name = 'gradle-demo'

Diff for: examples/gradle/src/main/proto/Demo.proto

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/**
2+
* Demo proto with sample messages.
3+
*
4+
* This file is really just an example. The data model is completely
5+
* fictional.
6+
*
7+
* For examples of more complex protos, see examples/proto in the protoc-gen-doc repo.
8+
*/
9+
syntax = "proto3";
10+
11+
package com.example;
12+
13+
/**
14+
* Represents a mail address.
15+
*/
16+
message Address {
17+
string address_line_1 = 1; /** First address line. */
18+
string address_line_2 = 2; /** Second address line. */
19+
string address_line_3 = 3; /** Second address line. */
20+
21+
string town = 4; /// Address town.
22+
string county = 5; /// Address county, if applicable.
23+
string country = 6; /// Address country.
24+
}
25+
26+
/**
27+
* Represents a customer.
28+
*/
29+
message Customer {
30+
int32 id = 1; /// Unique customer ID.
31+
string first_name = 2; /// Customer first name.
32+
string last_name = 3; /// Customer last name.
33+
string details = 4; /// Customer details.
34+
35+
string email_address = 5; /// Customer e-mail address.
36+
repeated string phone_number = 6; /// Customer phone numbers, primary first.
37+
repeated Address mail_addresses = 7; /// Customer mail addresses, primary first.
38+
}

Diff for: settings.gradle

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
rootProject.name = 'protoc-gen-doc'

0 commit comments

Comments
 (0)