[英]Create release zip file on Github without tag name in it
I have this repo on Github - https://github.com/ronakg/awesome-flickr-gallery-plugin . 我在Github上有这个仓库-https: //github.com/ronakg/awesome-flickr-gallery-plugin 。 It's a wordpress plugin for creating a photo gallery from your photos stored on Flickr. 这是一个wordpress插件,用于根据存储在Flickr上的照片创建相册。
Now what I want to achieve is - when I create a new release zip for my plugin, it should not use the tag name. 现在,我要实现的是-为插件创建新的发行版zip时,它不应使用标签名称。
For example, I create releases 3.5.0 and 3.6.0. 例如,我创建版本3.5.0和3.6.0。 The folder structure for both the releases should be same. 两个版本的文件夹结构应该相同。
awesome-flickr-gallery-plugin
/index.php
/README.txt
.
.
Right now it creates the release zipfiles like this: 现在,它会创建如下发布的zip文件:
awesome-flickr-gallery-plugin-3.5.0
/index.php
/README.txt
.
.
This is important for me as I want to serve this zip files directly as WordPress plugin updates for my users. 这对我很重要,因为我想直接为用户为WordPress插件更新提供此zip文件。 This different file structure breaks the plugin update process in WordPress. 这种不同的文件结构破坏了WordPress中的插件更新过程。
Any ideas? 有任何想法吗?
I faced a similar problem with the prefix -master
and solved with the following filter upgrader_source_selection
. 我遇到了前缀-master
的类似问题 ,并使用以下过滤器upgrader_source_selection
解决了。 My repository is github-plugin-for-wordpress
, adjust for your own. 我的存储库是github-plugin-for-wordpress
,可以根据自己的需要进行调整。
/**
* Access this plugin’s working instance
*
* @wp-hook plugins_loaded
* @return object of this class
*/
public function plugin_setup()
{
add_filter( 'upgrader_source_selection', array( $this, 'rename_github_zip' ), 1, 3);
}
/**
* Removes the prefix "-master" when updating from GitHub zip files
*
* See: https://github.com/YahnisElsts/plugin-update-checker/issues/1
*
* @param string $source
* @param string $remote_source
* @param object $thiz
* @return string
*/
public function rename_github_zip( $source, $remote_source, $thiz )
{
if( strpos( $source, 'github-plugin-for-wordpress') === false )
return $source;
$path_parts = pathinfo( $source );
$newsource = trailingslashit( $path_parts['dirname'] ) . trailingslashit( 'github-plugin-for-wordpress' );
rename( $source, $newsource );
return $newsource;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.