前几天在GitHub闲逛,突然发现了Github Packages,当时还想这是什么东东,于是点开链接 https://docs.github.com/en/packages/using-github-packages-with-your-projects-ecosystem/using-github-packages-with-github-actions 之后发现,哎呀,真香~~~
包有好几种类型,先贴docker和maven的

Configuring Docker for use with GitHub Packages
Configuring Apache Maven for use with GitHub Packages

提交工程到maven中央仓库太繁琐了,申请账号啥的还有各种配置。对于只是想简单分享一个小包的需求来说太冗长(其实是懒)

配置起来也简单:
maven 的setting添加:

 <profiles>
    <profile>
      <id>github</id>
      <repositories>
        <repository>
          <id>central</id>
          <url>https://repo1.maven.org/maven2</url>
          <releases><enabled>true</enabled></releases>
          <snapshots><enabled>true</enabled></snapshots>
        </repository>
        <repository>
          <id>github</id>
          <name>GitHub OWNER Apache Maven Packages</name>
          <url>https://maven.pkg.github.com/OWNER/REPOSITORY</url>
        </repository>
      </repositories>
    </profile>
  </profiles>

  <servers>
    <server>
      <id>github</id>
      <username>USERNAME</username>
      <password>TOKEN</password>
    </server>
  </servers>

在pom中添加:

<distributionManagement>
   <repository>
     <id>github</id>
     <name>GitHub OWNER Apache Maven Packages</name>
     <url>https://maven.pkg.github.com/OWNER/REPOSITORY</url>
   </repository>
</distributionManagement>

当然不要忘了吧OWNER和REPOSITORY改成自己的用户名和项目名。
TOKEN在github的settings中找
在这里插入图片描述
创建一个token即可
在这里插入图片描述
然后配置完之后执行mvn deploy命令,成功后:
在这里插入图片描述
是不是很飒~ 666

当然maven比较适合一些工具类的jar包,如果是项目类的还是用docker方便,docker的设置也在上面的链接中,喜欢的小伙伴不妨一试

Logo

腾讯云面向开发者汇聚海量精品云计算使用和开发经验,营造开放的云计算技术生态圈。

更多推荐