Skip to content

Commit de894ed

Browse files
committed
fix: support repositories with immutable releases enabled
GitHub's immutable releases feature (GA since Oct 2025) prevents modifying release artifacts after the release is created. This broke chart-releaser because it creates the release first, then uploads assets in a separate API call. This fix creates releases as drafts first, uploads assets, then publishes the release. Draft releases can be modified until they are published, which allows the asset upload to succeed. Fixes helm/chart-releaser-action#228 See: https://github.blog/changelog/2025-10-28-immutable-releases-are-now-generally-available/ Signed-off-by: Chris Burr <christopher.burr@cern.ch>
1 parent 2523224 commit de894ed

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

pkg/github/github.go

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,15 +102,22 @@ func (c *Client) GetRelease(_ context.Context, tag string) (*Release, error) {
102102
return result, nil
103103
}
104104

105-
// CreateRelease creates a new release object in the GitHub API
105+
// CreateRelease creates a new release object in the GitHub API.
106+
// To support repositories with immutable releases enabled (see
107+
// https://github.blog/changelog/2025-10-28-immutable-releases-are-now-generally-available/),
108+
// the release is first created as a draft, assets are uploaded, and then
109+
// the release is published. This ensures that assets can be uploaded before
110+
// the release becomes immutable.
106111
func (c *Client) CreateRelease(_ context.Context, input *Release) error {
112+
draft := true
107113
req := &github.RepositoryRelease{
108114
Name: &input.Name,
109115
Body: &input.Description,
110116
TagName: &input.Name,
111117
TargetCommitish: &input.Commit,
112118
GenerateReleaseNotes: &input.GenerateReleaseNotes,
113119
MakeLatest: &input.MakeLatest,
120+
Draft: &draft,
114121
}
115122

116123
release, _, err := c.Repositories.CreateRelease(context.TODO(), c.owner, c.repo, req)
@@ -123,6 +130,17 @@ func (c *Client) CreateRelease(_ context.Context, input *Release) error {
123130
return err
124131
}
125132
}
133+
134+
// Publish the release by setting draft to false
135+
draft = false
136+
req = &github.RepositoryRelease{
137+
Draft: &draft,
138+
}
139+
_, _, err = c.Repositories.EditRelease(context.TODO(), c.owner, c.repo, *release.ID, req)
140+
if err != nil {
141+
return errors.Wrap(err, "failed to publish release")
142+
}
143+
126144
return nil
127145
}
128146

0 commit comments

Comments
 (0)