Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Publish packages via GitHub Actions #14

Closed
sallyluenoa opened this issue Jul 3, 2021 · 12 comments
Closed

Publish packages via GitHub Actions #14

sallyluenoa opened this issue Jul 3, 2021 · 12 comments
Assignees

Comments

@sallyluenoa
Copy link
Owner

概要

  • ライブラリをGitHub Actions 経由でパッケージ公開する

実装方針

参考資料 or 関連issues

@sallyluenoa sallyluenoa self-assigned this Jul 3, 2021
@sallyluenoa
Copy link
Owner Author

最新の注釈付きタグを取得するコマンド

$ git describe --abbrev=0

ただしタグを打った時点では、前のタグを返してしまうバグがある模様。(現時点では Not Fixed.)
actions/checkout#272

@sallyluenoa
Copy link
Owner Author

タグ名を取得する方法
GITHUB_REF(ワークフローをトリガーしたブランチまたはタグref)でタグ打った時のアクションで使える。
https://github.community/t/how-to-get-just-the-tag-name/16241

@sallyluenoa
Copy link
Owner Author

テスト用に v0.1.0 タグを打った
https://github.com/sallyluenoa/FRExtensions/releases/tag/v0.1.0

@sallyluenoa
Copy link
Owner Author

master branch -> git describe --tag
tag (release) -> GITHUB_REF

で、バージョン取得できそう

sallyluenoa added a commit that referenced this issue Jul 11, 2021
* Create sandbox_build.yml
sallyluenoa added a commit that referenced this issue Jul 11, 2021
sallyluenoa added a commit that referenced this issue Jul 11, 2021
sallyluenoa added a commit that referenced this issue Jul 11, 2021
sallyluenoa added a commit that referenced this issue Jul 11, 2021
@sallyluenoa
Copy link
Owner Author

ビルド番号に悩み中...
GITHUB_RUN_NUMBER はワークフローごとにナンバリングされるため、「master起因のビルド番号>その後でタグリリースした成果物のビルド番号」という逆転事象が起きてしまう。
プロジェクトを通して、ビルド番号をインクリメント(せめてmasterブランチのものとリリース成果物イコールまで)の状態にしたい。

einaregilsson/build-number@v3 が使えるかも?と試したが、タグを打つことでビルド番号を生成している模様。
リリース時にタグ打ちすることでCIトリガーにしたいので、ちょっと用途に合わない

@sallyluenoa
Copy link
Owner Author

これまでに打ったタグでわかるかなと思ったけど、タグ打った時点ではそのタグは無視される不具合があるらしいので微妙かも。
masterブランチトリガーなので、マージコミットをカウントすることでビルド番号にするのはよいかも?

$ git rev-list --merges --count HEAD
10

@sallyluenoa
Copy link
Owner Author

sallyluenoa commented Jul 25, 2021

何度かお試しで作っていることで、Package公開する方法を把握した
https://github.com/sallyluenoa/FRExtensions/packages/913012

ついでに Pages のやり方も別途把握、mdファイルをよしなにhtmlに変換してくれる。
KDocはここに公開でよさそう
https://sallyluenoa.github.io/FRExtensions/

@sallyluenoa
Copy link
Owner Author

sallyluenoa commented Jul 25, 2021

EndBug/add-and-commit@v7 で自動コミット追加できることを把握。
docsの自動アップデートが実現可能そう。
838f83c

ReleaseをトリガーにデプロイCI回すと、↑のコミットでRelease Tagが最新コミットじゃなくなくなってしまう。
Release トリガーじゃなくて一番最後に Release したいかな。

@sallyluenoa
Copy link
Owner Author

sallyluenoa commented Jul 25, 2021

@sallyluenoa
Copy link
Owner Author

リリースデプロイの大まかな流れ

前提

  • master: リリース用ブランチ、root を Pages 指定
  • develop: 開発用ブランチ

トリガー方法

  1. develop にて _version.yml のバージョンを書き換える
  2. develop を master にマージ

GitHub Actions の流れ

  1. 成果物(.aar, apk)生成 + Package公開
    • gradlew assembleRelease publish
  2. ドキュメント(KDoc)生成
    • gradlew dokkaHtml
  3. ドキュメント配置+コミット
    • cp [dokkaPath] ./docs
    • EndBug/add-and-commit
  4. リリース作成
    • create/release
  5. Assetアップロード
    • upload-release-asset
    • .aar, .apk, ./docs(zip)

sallyluenoa added a commit that referenced this issue Aug 1, 2021
* Add library publishing to build.gradle
* Add properties of versionName and versionCode
sallyluenoa added a commit that referenced this issue Aug 1, 2021
* Change YML for test build.
* Target branch: develop
sallyluenoa added a commit that referenced this issue Aug 1, 2021
* Create release_deploy.yml
sallyluenoa added a commit that referenced this issue Aug 1, 2021
* Add _config.yml for page theme
* Add _version.yml for managing version of release deploy
* Add docs/index.html for creating docs directory.
sallyluenoa added a commit that referenced this issue Aug 1, 2021
sallyluenoa added a commit that referenced this issue Aug 1, 2021
* Update version to 0.2.0
sallyluenoa added a commit that referenced this issue Aug 1, 2021
Publish packages via GitHub Actions #14
@sallyluenoa
Copy link
Owner Author

sallyluenoa commented Aug 1, 2021

CI 自動デプロイOK。DOCアップデート、リリースも一通りできている。
https://github.com/sallyluenoa/FRExtensions/actions/runs/1086674597

ただし1点残念なのが、タグのターゲットがマージコミットハッシュのままであること。
DOCアップデートのコミットハッシュ(master最新)が理想。

sallyluenoa added a commit that referenced this issue Aug 1, 2021
* Update release_deploy.yml
sallyluenoa added a commit that referenced this issue Aug 1, 2021
sallyluenoa added a commit that referenced this issue Aug 1, 2021
* Update release_deploy.yml
sallyluenoa added a commit that referenced this issue Aug 1, 2021
Publish packages via GitHub Actions 2 #14
sallyluenoa added a commit that referenced this issue Aug 1, 2021
Update app version to 0.2.1
@sallyluenoa
Copy link
Owner Author

タグの付与先を master に指定することで、想定どおりのデプロイが完成した。
条件を満たしたためcloseする。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant