Skip to content

Conversation

suzuki-shunsuke
Copy link
Contributor

@suzuki-shunsuke suzuki-shunsuke commented Jul 19, 2025

Close #3627

https://github.blog/changelog/2025-06-03-releases-now-expose-digests-for-release-assets/
https://docs.github.com/en/rest/releases/releases?apiVersion=2022-11-28#get-a-release

The Get a Release API returns digests of assets.
To get digests, this commit adds the field Digest and the method GetDigest to ReleaseAsset.

https://github.blog/changelog/2025-06-03-releases-now-expose-digests-for-release-assets/
https://docs.github.com/en/rest/releases/releases?apiVersion=2022-11-28#get-a-release

The `Get a Release` API returns digests of assets.
To get digests, this commit adds the field `Digest` and the method `GetDigest` to `ReleaseAsset`.
@suzuki-shunsuke
Copy link
Contributor Author

Test has passed.

$ ./script/test.sh
testing .
ok  	github.com/google/go-github/v73/github	3.617s	coverage: 99.1% of statements
	github.com/google/go-github/v73/test/fields		coverage: 0.0% of statements
?   	github.com/google/go-github/v73/test/integration	[no test files]
testing example
	github.com/google/go-github/v73/example/actionpermissions		coverage: 0.0% of statements
	github.com/google/go-github/v73/example/appengine		coverage: 0.0% of statements
	github.com/google/go-github/v73/example/basicauth		coverage: 0.0% of statements
	github.com/google/go-github/v73/example/codespaces/newreposecretwithxcrypto		coverage: 0.0% of statements
	github.com/google/go-github/v73/example/codespaces/newusersecretwithxcrypto		coverage: 0.0% of statements
	github.com/google/go-github/v73/example/commitpr		coverage: 0.0% of statements
	github.com/google/go-github/v73/example/listenvironments		coverage: 0.0% of statements
	github.com/google/go-github/v73/example/migrations		coverage: 0.0% of statements
	github.com/google/go-github/v73/example/newfilewithappauth		coverage: 0.0% of statements
	github.com/google/go-github/v73/example/newrepo		coverage: 0.0% of statements
	github.com/google/go-github/v73/example/newreposecretwithxcrypto		coverage: 0.0% of statements
	github.com/google/go-github/v73/example/ratelimit		coverage: 0.0% of statements
	github.com/google/go-github/v73/example/simple		coverage: 0.0% of statements
	github.com/google/go-github/v73/example/tokenauth		coverage: 0.0% of statements
	github.com/google/go-github/v73/example/topics		coverage: 0.0% of statements
	github.com/google/go-github/v73/example/verifyartifact		coverage: 0.0% of statements
testing scrape
ok  	github.com/google/go-github/scrape	1.234s	coverage: 59.4% of statements
	github.com/google/go-github/scrape/example/scrape		coverage: 0.0% of statements
testing tools
ok  	tools/metadata	1.280s	coverage: 81.7% of statements
testing tools/sliceofpointers
ok  	tools/sliceofpointers	1.452s	coverage: 94.7% of statements

@suzuki-shunsuke
Copy link
Contributor Author

I've confirmed the fix works as expected.

package main

import (
	"context"
	"encoding/json"
	"log"
	"os"

	"github.com/google/go-github/v73/github"
	"golang.org/x/oauth2"
)

func main() {
	if err := run(); err != nil {
		log.Fatal(err)
	}
}

func run() error {
	ctx := context.Background()
	httpClient := oauth2.NewClient(ctx, oauth2.StaticTokenSource(
		&oauth2.Token{AccessToken: os.Getenv("GITHUB_TOKEN")},
	))
	client := github.NewClient(httpClient).Repositories
	release, _, err := client.GetRelease(ctx, "aquaproj", "aqua", 233010212)
	if err != nil {
		return err
	}
	encoder := json.NewEncoder(os.Stdout)
	encoder.SetIndent("", "  ")
	if err := encoder.Encode(release); err != nil {
		return err
	}
	return nil
}
module foo

go 1.24.5

require (
	github.com/google/go-github/v73 v73.0.0
	golang.org/x/oauth2 v0.30.0
)

replace github.com/google/go-github/v73 => github.com/suzuki-shunsuke/go-github/v73 v73.0.1-0.20250719051818-956a007e23fa

require github.com/google/go-querystring v1.1.0 // indirect
GITHUB_TOKEN=$(gh auth token) go run main.go

Copy link

codecov bot commented Jul 19, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 91.33%. Comparing base (69f5bc7) to head (956a007).
Report is 1 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #3628   +/-   ##
=======================================
  Coverage   91.33%   91.33%           
=======================================
  Files         184      184           
  Lines       16174    16174           
=======================================
  Hits        14773    14773           
  Misses       1227     1227           
  Partials      174      174           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@gmlewis gmlewis changed the title feat: add the field to Digest to ReleaseAsset feat: Add the Digest field to ReleaseAsset Jul 19, 2025
@gmlewis
Copy link
Contributor

gmlewis commented Jul 19, 2025

Thank you, @suzuki-shunsuke and @alexandear!
LGTM.
Merging.

@gmlewis gmlewis merged commit 18877d9 into google:master Jul 19, 2025
7 checks passed
@github-project-automation github-project-automation bot moved this to Done in main Jul 19, 2025
@suzuki-shunsuke suzuki-shunsuke deleted the feat-add-digest-to-release-asset branch July 19, 2025 12:18
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

Successfully merging this pull request may close these issues.

Add the field Digest to ReleaseAsset
3 participants