1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

この続き

バージョン、ハッシュ値、リリース時期の3つがほしいが、リリース時期が前回だと取得できていなかったので続き。

本記事の目的

直近すぎるリリースを指定してしまうのをセキュリティ上の理由から回避したい。

よっていつのリリースかを知りたい。

前回の確認方法ではそれが確認できなかった。

もちろん、該当のタグのページに飛べば確認できるが、
当初の目的である一覧で確認して、その一覧から確認できるようにしたい。

また、該当のページにとんでも、次のように

last monthとの記載のみだったりするので、詳細に確認するのをCLIで楽にやりたい。

試行錯誤

ghコマンド

gh release list -R aws-actions/configure-aws-credentials

gh release list -R actions/checkout
TITLE TYPE TAG NAME PUBLISHED
v6.0.2 Latest v6.0.2 about 4 months ago
v6.0.1 v6.0.1 about 6 months ago
v6.0.0 v6.0.0 about 6 months ago
v4.3.1 v4.3.1 about 6 months ago
v5.0.1 v5.0.1 about 6 months ago
v6-beta Pre-release v6-beta about 6 months ago
v5.0.0 v5.0.0 about 9 months ago
v4.3.0 v4.3.0 about 9 months ago

しかし、これだと、今度はハッシュ値を確認できない。

生成AIにワンライナーを頼む

お願いした。

これ

gh api repos/aws-actions/configure-aws-credentials/tags --paginate \
  --jq '.[] | "\(.name) | \(.commit.sha)"' | while read line; do
    tag=$(echo $line | cut -d' ' -f1)
    sha=$(echo $line | cut -d' ' -f3)
    # 各コミットの日付を取得して結合
    date=$(gh api repos/aws-actions/configure-aws-credentials/commits/$sha --jq '.commit.committer.date')
    echo "$tag | $sha | $date"
done

しかし、これだと変数が2箇所出てきて使いにくい。
指示すると次のような形になった。

これが最終系

REPO="actions/checkout"
gh api repos/$REPO/tags --paginate --jq '.[] | "\(.name) \(.commit.sha)"' | while read -r tag sha; do
    date=$(gh api repos/$REPO/commits/$sha --jq '.commit.committer.date' 2>/dev/null)
    echo "$tag | $sha | $date"
done

このような結果になりほしい3つの情報(バージョン、ハッシュ値、リリース時期)が確認できた。

v6.0.2 | de0fac2e4500dabe0009e67214ff5f5447ce83dd | 2026-01-09T19:42:23Z
v6.0.1 | 8e8c483db84b4bee98b60c0593521ed34d9990e8 | 2025-12-02T02:08:49Z
v6.0.0 | 1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 | 2025-11-20T16:20:04Z
v6 | de0fac2e4500dabe0009e67214ff5f5447ce83dd | 2026-01-09T19:42:23Z
v6-beta | 71cf2267d89c5cb81562390fa70a37fa40b1305e | 2025-11-03T19:40:10Z

以上

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?