GitHub操作以自动更新Go导入路径

huangapple go评论96阅读模式
英文:

GitHub Action to auto update Go import paths

问题

有一个名为"auto-update-imports"的GitHub Action可以自动打开一个PR,并将Go导入路径更新到新的主要版本。你可以在GitHub Marketplace上找到这个Action。它会检查你的代码库中的所有Go文件,并将导入路径从github.com/org/example/v1更新为github.com/org/example/v2。如果找不到这个Action,你可以尝试编写一个bash脚本来实现这个功能。希望对你有帮助!

英文:

Is there a GitHub action to auto-open a PR with Go import paths updated to a new major version?

For example, my module is module github.com/org/example/v1

and imports across the repo are import "github.com/org/example/v1/test".

I would like to run an action that will open a PR with all imports + the module updated to v2 like:

`import "github.com/org/example/v2/test"`

Is there one like that?

If not, does anyone have a bash script for doing this?

Thanks in advance!

答案1

得分: 0

我为此编写了一些自定义逻辑:https://github.com/osmosis-labs/osmosis/pull/2094

基本上,它有一个 bash 脚本,遍历所有文件并增加主版本号。

然后,一个自定义的 GA 工作流程从一个新分支运行该脚本,并对目标分支发起拉取请求。

英文:

I wrote some custom logic for this: https://github.com/osmosis-labs/osmosis/pull/2094

Basically, it has a bash script that goes over all files and increases the major version.

A custom GA workflow then runs the script from a new branch and opens a pull request against the target branch.

huangapple
  • 本文由 发表于 2022年7月16日 05:13:17
  • 转载请务必保留本文链接:https://go.coder-hub.com/72999658.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定