Skip to content

Release Notes v0.7.0

This release adds two new packages (checks and tag), extends the pr and release packages with additional functionality, and upgrades the underlying go-github dependency from v81 to v82.

Breaking Changes

go-github Upgrade (v81 → v82)

The go-github dependency has been upgraded from v81 to v82. Update your imports:

// Before
import "github.com/google/go-github/v81/github"

// After
import "github.com/google/go-github/v82/github"

New Features

Checks Package

The new checks package provides functions for working with GitHub Check Runs API, useful for CI/CD status monitoring:

import "github.com/grokify/gogithub/checks"

// List check runs for a PR
checkRuns, err := checks.ListCheckRunsForPR(ctx, gh, "owner", "repo", 123)

// Wait for all checks to complete (with timeout)
checkRuns, allPassed, err := checks.WaitForChecks(ctx, gh, "owner", "repo", "sha",
    10*time.Minute, 30*time.Second)

// Get aggregate status
status := checks.GetChecksStatus(checkRuns)
fmt.Printf("Total: %d, Passed: %d, Failed: %d, Pending: %d\n",
    status.Total, status.Passed, status.Failed, status.Pending)

// Quick check if all passed
if checks.AllChecksPassed(checkRuns) {
    fmt.Println("Ready to merge!")
}

Functions

Function Description
ListCheckRuns List check runs for a commit SHA or branch
ListCheckRunsForPR List check runs for a pull request
GetChecksStatus Get aggregate status (passed/failed/pending counts)
AllChecksPassed Check if all runs completed successfully
WaitForChecks Poll until all checks complete or timeout
GetCheckRun Get a specific check run by ID
ListCheckSuites List check suites for a commit

Types

type ChecksStatus struct {
    Total      int
    Passed     int
    Failed     int
    Pending    int
    AllPassed  bool
    AnyFailed  bool
    AnyPending bool
}

Tag Package

The new tag package provides functions for Git tag operations:

import "github.com/grokify/gogithub/tag"

// List all tags
tags, err := tag.ListTags(ctx, gh, "owner", "repo")

// Get just the names
names, err := tag.GetTagNames(ctx, gh, "owner", "repo")

// Check if a tag exists
exists, err := tag.TagExists(ctx, gh, "owner", "repo", "v1.0.0")

// Get the commit SHA for a tag
sha, err := tag.GetTagSHA(ctx, gh, "owner", "repo", "v1.0.0")

// Create an annotated tag
err = tag.CreateTag(ctx, gh, "owner", "repo", "v1.0.0", sha, "Release v1.0.0")

// Create a lightweight tag
err = tag.CreateLightweightTag(ctx, gh, "owner", "repo", "v1.0.0", sha)

// Delete a tag
err = tag.DeleteTag(ctx, gh, "owner", "repo", "v1.0.0")

Functions

Function Description
ListTags List all tags for a repository with pagination
GetTagSHA Get the commit SHA for a tag
CreateTag Create an annotated tag
CreateLightweightTag Create a lightweight tag (just a reference)
DeleteTag Delete a tag
TagExists Check if a tag exists
GetTagNames Get just the tag names from a repository

Extended PR Package

New functions for PR reviews and merge status:

import "github.com/grokify/gogithub/pr"

// Approve a PR
review, err := pr.ApprovePR(ctx, gh, "owner", "repo", 123, "LGTM!")

// Request changes
review, err := pr.RequestChangesPR(ctx, gh, "owner", "repo", 123, "Please fix...")

// Add a comment review
review, err := pr.CommentPR(ctx, gh, "owner", "repo", 123, "FYI...")

// Check if mergeable
state, err := pr.IsMergeable(ctx, gh, "owner", "repo", 123)
if state.Mergeable {
    fmt.Println("Ready to merge!")
} else {
    fmt.Printf("Cannot merge: %s\n", state.Message)
}

// List all reviews
reviews, err := pr.ListPRReviews(ctx, gh, "owner", "repo", 123)

New Functions

Function Description
ApprovePR Add an approval review to a pull request
RequestChangesPR Request changes on a pull request
CommentPR Add a comment review to a pull request
IsMergeable Check if a PR can be merged with detailed status
ListPRReviews List all reviews on a pull request

New Types

type MergeableState struct {
    Mergeable bool
    State     string // clean, dirty, blocked, behind, unstable, unknown
    Message   string
}

Extended Release Package

New functions for creating and managing releases:

import "github.com/grokify/gogithub/release"

// Create a release with all options
rel := &github.RepositoryRelease{
    TagName:              github.Ptr("v1.0.0"),
    Name:                 github.Ptr("Version 1.0.0"),
    Body:                 github.Ptr("Release notes..."),
    Draft:                github.Ptr(false),
    Prerelease:           github.Ptr(false),
    GenerateReleaseNotes: github.Ptr(true),
}
created, err := release.CreateRelease(ctx, gh, "owner", "repo", rel)

// Or use the simple helper
created, err := release.CreateReleaseSimple(ctx, gh, "owner", "repo",
    "v1.0.0", "Version 1.0.0", "Release notes...", false, false, true)

// Update a release
rel.Body = github.Ptr("Updated notes")
updated, err := release.EditRelease(ctx, gh, "owner", "repo", releaseID, rel)

// Delete a release
err = release.DeleteRelease(ctx, gh, "owner", "repo", releaseID)

New Functions

Function Description
CreateRelease Create a new release for a repository
CreateReleaseSimple Create a release with common options
DeleteRelease Delete a release by ID
EditRelease Update a release

Use Cases

Automated Dependency PR Merging

The new packages work together for automated dependency management:

// 1. Check if CI passed
checkRuns, err := checks.ListCheckRunsForPR(ctx, gh, owner, repo, prNumber)
if !checks.AllChecksPassed(checkRuns) {
    return fmt.Errorf("checks not passed")
}

// 2. Check if mergeable
state, err := pr.IsMergeable(ctx, gh, owner, repo, prNumber)
if !state.Mergeable {
    return fmt.Errorf("not mergeable: %s", state.Message)
}

// 3. Approve and merge
_, err = pr.ApprovePR(ctx, gh, owner, repo, prNumber, "Auto-approved")
_, err = pr.MergePR(ctx, gh, owner, repo, prNumber, "Merge dependency update", nil)

Creating a Release with Tag

// 1. Get the commit to tag
sha, err := repo.GetBranchSHA(ctx, gh, owner, repo, "main")

// 2. Create annotated tag
err = tag.CreateTag(ctx, gh, owner, repo, "v1.2.3", sha, "Release v1.2.3")

// 3. Create GitHub release
rel, err := release.CreateReleaseSimple(ctx, gh, owner, repo,
    "v1.2.3", "v1.2.3", "", false, false, true)

Migration Guide

If you're upgrading from v0.6.0:

  1. Update go-github imports from v81 to v82
  2. Run go mod tidy to update dependencies
  3. No API changes to existing functions - new packages and functions are additive

Dependencies

  • Upgraded github.com/google/go-github from v81 to v82