MH4GF / gh-prj

An extension to browse projects
MIT License
3 stars 0 forks source link

GitHub CLI Extensionの実装でやるべきことを理解する #4

Closed MH4GF closed 2 years ago

MH4GF commented 2 years ago

What

参考

https://cli.github.com/manual/gh_extension

MH4GF commented 2 years ago

ドキュメントを読んでいく https://docs.github.com/en/github-cli/github-cli/creating-github-cli-extensions

The repository must have an executable file at its root with the same name as the repository or a set of precompiled binary executables attached to a release.

今回の場合、 リポジトリルートに gh-prj という名前の実行可能ファイルを用意するか、コンパイル済みのバイナリをリリースにアタッチしておくかの二択になる

MH4GF commented 2 years ago

適当なディレクトリで gh extension create を試す https://docs.github.com/en/github-cli/github-cli/creating-github-cli-extensions#creating-a-non-go-precompiled-extension-with-gh-extension-create

gh extension create
? Extension name: gh-prj
? What kind of extension? Other Precompiled (C++, Rust, etc)
✓ Created directory gh-prj
✓ Initialized git repository
✓ Set up extension scaffolding

gh-prj is ready for development!

Next Steps
- run 'cd gh-prj; gh extension install .' to install your extension locally
- fill in script/build.sh with your compilation script for automated builds
- compile a gh-prj binary locally and run 'gh prj' to see changes
- commit and use 'gh repo create' to share your extension with others

For more information on writing extensions:
https://docs.github.com/github-cli/github-cli/creating-github-cli-extensions

extension名とコンパイル方法を対話的に設定できる。scaffoldとして script/build.sh.github/workflows/release.yml が生成された。build.shにクロスコンパイルを考慮したバイナリのビルド手順を記載しろとのこと。 release.ymlでは cli/gh-extension-precompile@v1 が利用されている。こちらを見ていく。

MH4GF commented 2 years ago

https://github.com/cli/gh-extension-precompile

gh extension用に、ソースコードをビルドしてGitHub ReleasesにアップロードしてくれるAction. CHANGELOGの生成や署名などもやってくれているようだ。処理の中身はここにある。 https://github.com/cli/gh-extension-precompile/blob/trunk/build_and_release.sh

特に変なことはせず、素直にこのインターフェースに従って script/build.sh を用意する形にしたほうがよさそうだ。

MH4GF commented 2 years ago

とりあえずやるべきことは以下のようだ。