Skip to content

feat(release): fork file process to get mime type before release asset upload - #15089

Closed
eighty4 wants to merge 2 commits into
cli:trunkfrom
eighty4:asset-mime-types
Closed

eighty4 wants to merge 2 commits into
cli:trunkfrom
eighty4:asset-mime-types

Conversation

@eighty4

@eighty4 eighty4 commented Nov 17, 2026 •

Copy link
Copy Markdown

Fixes #15088

Description

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 change adds 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, release uploads will attempt to fork a file -b --mime-type process to get an accurate mime type.

How did you test this change?

The change is tested with run.Stub to include testing a call of file -b --mime-type.

Key points

The gains from simplifying CICD pipelines from scripting boilerplate to a single succinct command is greatly worth the process forking. No consideration was put into parallelizing the asset prep before uploading.

Notes for reviewers

This is an impactful change for users -- who knows what is currently being uploaded as application/octet-stream? I'm assuming that most asset uploads have an extension and if they do not they are probably binaries.

Authorship and follow-up

Authored by the user account, @eighty4, that is submitting the PR. Review comments will be received and actioned on by the same human.

@eighty4
eighty4 requested review from a team as code owners November 17, 2026 23:37
@eighty4
eighty4 requested review from sergiou87 and a balanced review from Copilot November 17, 2026 23:37
@github-actions github-actions Bot added external pull request originating outside of the CLI core team needs-triage needs to be reviewed unmet-requirements and removed needs-triage needs to be reviewed labels Nov 17, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Thanks for your pull request! Unfortunately, it doesn't meet the requirements for review:

  • None of the referenced issues have the help wanted label

Please update your PR to address the above. This PR will be automatically closed in 4 days if these requirements are not met.

Full contribution requirements
  1. Include a detailed description of what this PR does
  2. Link to an issue with the help wanted label (use Fixes #123 or Closes #123)

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

MIME detection reports the symlink’s type instead of its target’s content, and the binary MIME test relies on host utilities and shell format rather than an isolated, deterministic setup.

2 open issues
What changed in this PR

This PR addresses #15088 by extending release asset MIME detection beyond filename extensions, aiming to identify unrecognized artifacts more accurately.

Changes:

  • Preserve extension-based detection, then invoke file on non-Windows systems when no MIME type is found.
  • Pass asset paths into detection while retaining the application/octet-stream fallback.
  • Update MIME tests with temporary data and platform-binary cases.
File Description
pkg/​cmd/​release/​shared/​upload.go Adds path-aware MIME detection using the external file command.
pkg/​cmd/​release/​shared/​upload_test.go Updates MIME detection tests and refactors retry-test branching.

Review effort: Balanced

Comment thread pkg/cmd/release/shared/upload.go Resolved
Comment thread pkg/cmd/release/shared/upload_test.go Resolved
@eighty4
eighty4 force-pushed the asset-mime-types branch 3 times, most recently from 4b6fabe to 924e598 Compare November 18, 2026 00:30
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 unmet-requirements

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Release asset uploads with specific and accurate mime types

3 participants