Skip to content

Release asset uploads with specific and accurate mime types #15088

Open

Description

@eighty4

Code of Proposed Design

Resolving mime types of Release assets is done here.

Proposed Design

Currently, uploaded asset mime types are only resolved by the extensions of the assets. It would be valuable to have a consistent gh release create experience whether releasing tarballs or cross-platform binaries built by a Rust or Zig toolchain by uploading the artifacts with specific and detailed mime types for the uploaded artifacts.

This proposed change would be adding a check with the file command on darwin/linux systems. First an extension-based mime type would be quickly resolved without forking a process. If the mime type is unresolved and the process is on appropriate systems, fork a file -b --mime-type "$_filename" process to get an accurate mime type.

The current workaround to achieve accurate mime types for application binaries is gh release create without asset uploads and then upload all assets in a bash loop with curl and file commands. This proposed design would enhance gh release create to correctly resolve application/x-pie-executable and application/x-mach-binary and allow a great simplification in CICD release pipelines.

Mockup

Here is a primitive impl that executes file on darwin/linux and uses that if detected:

func typeForFilename(fn string, fp string) string {
	ext := fileExt(fn)
	switch ext {
	case ".zip":
		return "application/zip"
	case ".js":
		return "application/javascript"
	case ".tar":
		return "application/x-tar"
	case ".tgz", ".tar.gz":
		return "application/x-gtar"
	case ".bz2":
		return "application/x-bzip2"
	case ".dmg":
		return "application/x-apple-diskimage"
	case ".rpm":
		return "application/x-rpm"
	case ".deb":
		return "application/x-debian-package"
	}

	if t := mime.TypeByExtension(ext); t != "" {
		return t
	}
	if runtime.GOOS != "windows" {
		out, err := exec.Command("file", "-b", "--mime-type", "--", fp).Output()
		if err == nil {
			if ct := strings.TrimSpace(string(out)); detected != "" {
				return ct
			}
		}
	}
	return "application/octet-stream"
}

See #15089 for a demonstration implemtation.

Activity

  1. cli-triage commented on Nov 17, 2026

    @cli-triage

    Thanks for the detailed proposal. I checked GitHub CLI 2.104.0, where release asset uploads still choose the Content-Type from the filename extension and use application/octet-stream when no extension mapping exists. The release commands do not currently offer a flag to override that value. This means extensionless Rust or Zig binaries cannot receive the more specific executable media types through gh release create or gh release upload alone. The requested content-based fallback is therefore a current feature gap, while the existing extension-based behavior would remain the fast path.

    Supporting reports

    Generated by issue triage.

  2. added
    enhancement
    gh-release
    on Nov 17, 2026
  3. github-actions commented on Nov 17, 2026

    @github-actions
    Contributor

    Thank you for your issue! We have categorized it as an enhancement (feature or improvement) request, and it has been added to our backlog. In doing so, we are not committing to implementing this feature at this time, but, we will consider it for future releases based on community feedback and our own product roadmap.

    Unless you see the help wanted Contributions welcome label, we are not currently looking for external contributions for this feature.

    If you come across this issue and would like to see it implemented, please add a thumbs up! This will help us prioritize the feature. Please only comment if you have additional information or viewpoints to contribute.

  4. removed
    needs-triage
    on Nov 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementgh-release

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions