发布composer包到 Packagist,并设置自动同步(从github到Packagist)

一、发布composer包

 
1、将我们写好的项目包发布到github上

这一步不赘述,应该都会。

但是需要注意的是,我们一定要为我们的项目包打上tag之后再提交,否则 我们composer require时可能会报错 Could not find a version of package。

# 设置版本号
git tag v1.0.0

# 推送源码
git push

# 推送版本号
git push origin --tags

如果你已经提交过了,则随便编辑个文件提交,这时,如果你设置了自动github同步更新到packageist,则composer require不会再报错。


 
2、登录 https://packagist.org/packages/submit ,并提交我们的github项目地址

3、点击check


4、确认提交


 
二、设置自动同步

github更新时,packages同步更新

1、获取 packagist 的 Payload URL 和 Packagist API Token(在Packagist中获取)。

点击 https://packagist.org/about#how-to-update-packages ,搜索 How to update packages(也可以一直拉倒最下面),出现下图

 

记住 Payload URL,然后点击 Packagist API Token 进去获取api token。

现在我们有了这两个参数。

 
2、到 github 上设置同步

登录 https://github.com/haveyb/tiny-laravel/settings/hooks ,这里的haveyb换成你的用户名,tiny-laravel 换成你的项目名。

然后点击 Add webhooks。


填入相关参数之后,点击下面的Add webhook。


到此,自动同步也设置完成。


原文地址:https://www.haveyb.com/article/161

发布了137 篇原创文章 · 获赞 174 · 访问量 255万+

猜你喜欢

转载自blog.csdn.net/m_nanle_xiaobudiu/article/details/104231469