Skip to content

Conversation

@bdehamer
Copy link
Contributor

Exposes the release asset digest as part of the release view command.

When available, the digest will be included as part of the table of asset information displayed:

$ gh release view v5 --repo bdehamer/delme 

v5
bdehamer released this about 13 days ago

  important release notes                                                                                   


Assets
a.zip  sha256:f7165848f9f5ddc578d7adbd1f566a394169385c73bd88bf60df7e759db8e08d  797 B
b.zip  sha256:8b7eb1572346692ffd3ae01248c70a341ae3aa8be1df8b12346b50acb9002282  5.41 KiB

View on GitHub: https://github.com/bdehamer/delme/releases/tag/v5

Will also appear in the JSON output for release assets:

$ gh release view v5 --repo bdehamer/delme --json assets

{
  "assets": [
    {
      "apiUrl": "https://api.github.com/repos/bdehamer/delme/releases/assets/254398346",
      "contentType": "application/zip",
      "createdAt": "2025-05-13T23:02:36Z",
      "digest": "sha256:f7165848f9f5ddc578d7adbd1f566a394169385c73bd88bf60df7e759db8e08d",
      "downloadCount": 2,
      "id": "RA_kwDONgBHzM4PKc-K",
      "label": "",
      "name": "a.zip",
      "size": 797,
      "state": "uploaded",
      "updatedAt": "2025-05-13T23:02:36Z",
      "url": "https://github.com/bdehamer/delme/releases/download/v5/a.zip"
    },
    {
      "apiUrl": "https://api.github.com/repos/bdehamer/delme/releases/assets/254398345",
      "contentType": "application/zip",
      "createdAt": "2025-05-13T23:02:35Z",
      "digest": "sha256:8b7eb1572346692ffd3ae01248c70a341ae3aa8be1df8b12346b50acb9002282",
      "downloadCount": 2,
      "id": "RA_kwDONgBHzM4PKc-J",
      "label": "",
      "name": "b.zip",
      "size": 5544,
      "state": "uploaded",
      "updatedAt": "2025-05-13T23:02:36Z",
      "url": "https://github.com/bdehamer/delme/releases/download/v5/b.zip"
    }
  ]
}

The digest is a null'able field in the releases API and may not be available for all assets. When not present, a null value will be displayed in the output.

$ gh release view v1.1.0 --repo bdehamer/attest-demo --json assets

{
  "assets": [
    {
      "apiUrl": "https://api.github.com/repos/bdehamer/attest-demo/releases/assets/243811664",
      "contentType": "application/zip",
      "createdAt": "2025-04-05T16:40:13Z",
      "digest": null,
      "downloadCount": 2,
      "id": "RA_kwDOL0GfDc4OiEVQ",
      "label": "",
      "name": "artifact.zip",
      "size": 1639350,
      "state": "uploaded",
      "updatedAt": "2025-04-05T16:40:14Z",
      "url": "https://github.com/bdehamer/attest-demo/releases/download/v1.1.0/artifact.zip"
    }
  ]
}

@bdehamer bdehamer temporarily deployed to cli-automation May 27, 2025 19:52 — with GitHub Actions Inactive
@bdehamer bdehamer marked this pull request as ready for review May 27, 2025 22:12
Copilot AI review requested due to automatic review settings May 27, 2025 22:12
@bdehamer bdehamer requested a review from a team as a code owner May 27, 2025 22:12
@bdehamer bdehamer requested a review from andyfeller May 27, 2025 22:12
@bdehamer bdehamer temporarily deployed to cli-automation May 27, 2025 22:12 — with GitHub Actions Inactive
@cliAutomation cliAutomation added the external pull request originating outside of the CLI core team label May 27, 2025
@cliAutomation
Copy link
Collaborator

Hi! Thanks for the pull request. Please ensure that this change is linked to an issue by mentioning an issue number in the description of the pull request. If this pull request would close the issue, please put the word 'Fixes' before the issue number somewhere in the pull request body. If this is a tiny change like fixing a typo, feel free to ignore this message.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds support for displaying and exporting release asset digests in both the TTY and JSON outputs of the release view command.

  • Introduces a Digest field on ReleaseAsset and includes it in the JSON export.
  • Updates the TTY renderer to print the digest column.
  • Adjusts tests to expect the new digest column in table and JSON outputs.

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
pkg/cmd/release/shared/fetch.go Added Digest *string to ReleaseAsset and included it in ExportData.
pkg/cmd/release/view/view.go Updated TTY rendering to show the digest field.
pkg/cmd/release/view/view_test.go Updated test fixtures to include digest in table and JSON expectations.
Comments suppressed due to low confidence (1)

pkg/cmd/release/view/view_test.go:150

  • [nitpick] The expected TTY output for digest formatting is duplicated across two test cases; you might extract the common table snippet into a helper to simplify future updates.
func Test_viewRun(t *testing.T) {

for _, a := range release.Assets {
table.AddField(a.Name)
if a.Digest == nil {
table.AddField("")
Copy link

Copilot AI May 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Instead of rendering an empty string for missing digests, consider using a visible placeholder (e.g., "-") so users can clearly tell that the digest is unavailable.

Suggested change
table.AddField("")
table.AddField("-")

Copilot uses AI. Check for mistakes.
Copy link
Member

@andyfeller andyfeller left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your patience, @bdehamer! 🙇 The code changes are pretty straight forward but have a handful of questions for other considerations.

fmt.Fprintln(w, cs.Bold("Assets"))
//nolint:staticcheck // SA1019: Showing NAME|SIZE headers adds nothing to table.
table := tableprinter.New(io, tableprinter.NoHeader)
table := tableprinter.New(io, tableprinter.WithHeader("Name", "Digest", "Size"))
Copy link
Member

@andyfeller andyfeller May 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note: I've asked @bdehamer to add the header since we have multiple fields now and am concerned for screen readers.

Copy link
Member

@andyfeller andyfeller left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

shipit-squirrel-fireworks

@andyfeller andyfeller enabled auto-merge May 29, 2025 19:04
@andyfeller andyfeller merged commit 79fc854 into trunk May 29, 2025
16 checks passed
@andyfeller andyfeller deleted the bdehamer/release-asset-digest branch May 29, 2025 19:11
tmeijn pushed a commit to tmeijn/dotfiles that referenced this pull request Jun 13, 2025
This MR contains the following updates:

| Package | Update | Change |
|---|---|---|
| [cli/cli](https://github.com/cli/cli) | minor | `v2.73.0` -> `v2.74.1` |

MR created with the help of [el-capitano/tools/renovate-bot](https://gitlab.com/el-capitano/tools/renovate-bot).

**Proposed changes to behavior should be submitted there as MRs.**

---

### Release Notes

<details>
<summary>cli/cli (cli/cli)</summary>

### [`v2.74.1`](https://github.com/cli/cli/releases/tag/v2.74.1): GitHub CLI 2.74.1

[Compare Source](cli/cli@v2.74.0...v2.74.1)

#### What's Changed

-   Document support for `@copilot` in `gh [pr|issue] edit --add-assignee` and `--remove-assignee` by [@&#8203;timrogers](https://github.com/timrogers) in cli/cli#11056
-   Fix pr edit when URL is provided by [@&#8203;williammartin](https://github.com/williammartin) in cli/cli#11057
-   Fix const in MR finder tests by [@&#8203;babakks](https://github.com/babakks) in cli/cli#11091

**Full Changelog**: cli/cli@v2.74.0...v2.74.1

### [`v2.74.0`](https://github.com/cli/cli/releases/tag/v2.74.0): GitHub CLI 2.74.0

[Compare Source](cli/cli@v2.73.0...v2.74.0)

#### Security

A security vulnerability has been identified in a core `gh` dependency, `go-gh`, where an attacker-controlled GitHub Enterprise Server could result in executing arbitrary commands on a user's machine by replacing HTTP URLs provided by GitHub with local file paths for browsing.

This issue is addressed in this `gh` release by updating `go-gh` to a fixed version.

For more information, see GHSA-g9f5-x53j-h563

#### What's changed

##### ✨ Features

-   Add `preview prompter` command by [@&#8203;BagToad](https://github.com/BagToad) in cli/cli#10745
-   \[gh run watch] Support `--compact` flag by [@&#8203;iamazeem](https://github.com/iamazeem) in cli/cli#10629
-   Fix brew update notifications by [@&#8203;BagToad](https://github.com/BagToad) in cli/cli#11024

##### 🐛 Fixes

-   Revert "\[gh config] Escape pipe symbol in Long desc for website manual" by [@&#8203;BagToad](https://github.com/BagToad) in cli/cli#11004
-   Fix formatting in allowed values for `gh config --help` by [@&#8203;BagToad](https://github.com/BagToad) in cli/cli#11003
-   fix: `gh gist edit` panic when no file in a gist by [@&#8203;phanen](https://github.com/phanen) in cli/cli#10627
-   Add retry logic when fetching TUF content in `gh attestation` commands by [@&#8203;malancas](https://github.com/malancas) in cli/cli#10943

##### 📚 Docs & Chores

-   Update README.md by [@&#8203;irhdab](https://github.com/irhdab) in cli/cli#11022
-   Add tests for `RenderJobs` and `RenderJobsCompact` by [@&#8203;babakks](https://github.com/babakks) in cli/cli#11013
-   Add example usage of `--head` option to `pr list` docs by [@&#8203;babakks](https://github.com/babakks) in cli/cli#10979
-   Mention `pr create` will print the created MR's URL by [@&#8203;babakks](https://github.com/babakks) in cli/cli#10980
-   Add Digest to ReleaseAsset struct by [@&#8203;bdehamer](https://github.com/bdehamer) in cli/cli#11030

##### :dependabot: Dependencies

-   Bump `go-gh` to v2.12.1 by [@&#8203;BagToad](https://github.com/BagToad) in cli/cli#11043
-   chore(deps): bump github.com/gabriel-vasile/mimetype from 1.4.8 to 1.4.9 by [@&#8203;dependabot](https://github.com/dependabot) in cli/cli#10825
-   Update sigstore-go dependency to v1.0.0 by [@&#8203;malancas](https://github.com/malancas) in cli/cli#11028
-   chore(deps): bump github.com/sigstore/protobuf-specs from 0.4.1 to 0.4.2 by [@&#8203;dependabot](https://github.com/dependabot) in cli/cli#10999
-   chore(deps): bump github.com/yuin/goldmark from 1.7.8 to 1.7.12 by [@&#8203;dependabot](https://github.com/dependabot) in cli/cli#11032

#### New Contributors

-   [@&#8203;irhdab](https://github.com/irhdab) made their first contribution in cli/cli#11022
-   [@&#8203;phanen](https://github.com/phanen) made their first contribution in cli/cli#10627

**Full Changelog**: cli/cli@v2.73.0...v2.74.0

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever MR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this MR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this MR, check this box

---

This MR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0MC41MC4wIiwidXBkYXRlZEluVmVyIjoiNDAuNTAuMCIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOlsiUmVub3ZhdGUgQm90Il19-->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

external pull request originating outside of the CLI core team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants