|
| 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 |
0 commit comments