申請賬號
訪問sonatype并注冊賬號 https://issues.sonatype.org 酌畜,注意要記住賬號密碼
新建項目(github or gitee)
- 新建項目桥胞,上傳到github或者gitee
- 下面創(chuàng)建工單的git源使用
申請權限
-
登錄上面的賬號贩虾,創(chuàng)建工單
image.png 根據(jù)工單的要求伊群,進行對應的工作策精,最終工單變?yōu)橐研迯图纯?/p>
加密驗簽
-
下載gpg來生產(chǎn)秘鑰對
查看是否安裝成功 gpg --version 生成密鑰對 gpg --gen-key 查看公鑰 gpg --list-keys 將公鑰發(fā)布到PGP密鑰服務器 gpg --keyserver hkp://pool.sks-keyservers.net --send-keys 公鑰ID 查詢公鑰是否發(fā)布成功 gpg --keyserver hkp://pool.sks-keyservers.net --recv-keys
創(chuàng)建秘鑰對
-
相關參數(shù) name: XXXX mail: xxxx@163.com password: xxxxx
gpg: /Users/wuwenjie/.gnupg/trustdb.gpg:建立了信任度數(shù)據(jù)庫 gpg: 密鑰 D6BFCDEA66953384 被標記為絕對信任 gpg: 目錄‘/Users/wuwenjie/.gnupg/openpgp-revocs.d’已創(chuàng)建 gpg: 吊銷證書已被存儲為‘/Users/wuwenjie/.gnupg/openpgp-revocs.d/233FA1BE7CACA65156AFCD0ED6BFCDEA66953384.rev’ 公鑰和私鑰已經(jīng)生成并被簽名蔽午。 pub rsa2048 2020-04-26 [SC] [有效至:2022-04-26] 233FA1BE7CACA65156AFCD0ED6BFCDEA66953384 uid kuixin <zjkxtech@163.com> sub rsa2048 2020-04-26 [E] [有效至:2022-04-26]
配置maven與項目的pom文件
maven setting.xml
<server>
<id>oss</id>
<username>kx</username>
<password>oRVJqmU30Rbc%</password>
</server>
pom文件
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.gitee.xxx</groupId>
<artifactId>xx-tools</artifactId>
<version>1.0</version>
<name>xx-tools</name>
<description>Spring Boot tools for phone,ip</description>
<url>https://gitee.com/xxx/xx-tools</url>
<!-- 開源簽名證書 -->
<licenses>
<license>
<name>The MIT License</name>
<url>http://opensource.org/licenses/MIT</url>
</license>
</licenses>
<!-- 開發(fā)人員信息 -->
<developers>
<developer>
<name>xxxx</name>
<email>xxxx@163.com</email>
</developer>
</developers>
<!-- 倉庫信息 -->
<scm>
<connection>scm:git:git://gitee.com:xxxx/xx-tools.git</connection>
<developerConnection>scm:git:git://gitee.com:xxxx/xx-tools.git</developerConnection>
<url>https://gitee.com/xxxx/xx-tools</url>
</scm>
<dependencies>
</dependencies>
<build>
<plugins>
<!-- Source -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>2.2.1</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>jar-no-fork</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- Javadoc -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.10.4</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- GPG -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>1.5</version>
<executions>
<execution>
<phase>verify</phase>
<goals>
<goal>sign</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<distributionManagement>
<snapshotRepository>
<id>oss</id>
<url>https://oss.sonatype.org/content/repositories/snapshots/</url>
</snapshotRepository>
<repository>
<id>oss</id>
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
</repository>
</distributionManagement>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
</project>
打包上傳成功
-
使用maven命令,直接進行打包即可
image.png -
發(fā)布
image.png
錯誤處理
gpg signing failed inappropriate ioctl for device Mac
$ brew install pinentry-mac
$ echo "pinentry-program /usr/local/bin/pinentry-mac" >> ~/.gnupg/gpg-agent.conf
$ killall gpg-agent