fix(github): improve asset detection for distro-specific and Swift artifacts#7347
Conversation
…tifacts - Add Linux distro names (ubuntu, debian, fedora, centos, rhel, alpine, arch) to OS detection pattern so distro-specific releases are correctly identified - Increase wrong OS penalty from -50 to -100 so it outweighs architecture match bonus (+50), preventing cross-platform mismatches - Add penalty for .artifactbundle.zip files (Swift Package Manager bundles) which are not suitable for direct tool installation Fixes krzysztofzablocki/Sourcery installation on macOS where: - Ubuntu tarballs were incorrectly selected due to matching architecture - Swift artifact bundles were preferred over plain release archives 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
This PR fixes asset selection logic in the GitHub backend to properly identify and score Linux distribution-specific releases and Swift Package Manager artifacts. The changes prevent mise from downloading incorrect release assets for tools like Sourcery on macOS.
Key Changes:
- Extended OS detection regex to recognize common Linux distro names (ubuntu, debian, fedora, etc.)
- Increased wrong OS penalty from -50 to -100 to prevent architecture matches from overriding OS mismatches
- Added penalty for
.artifactbundle.zipfiles which are Swift Package Manager bundles unsuitable for direct installation
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| AssetOs::Linux, | ||
| Regex::new(r"(?i)(?:\b|_)linux(?:\b|_|32|64)").unwrap(), | ||
| // Include common Linux distro names that may appear in release asset names | ||
| Regex::new(r"(?i)(?:\b|_)(?:linux|ubuntu|debian|fedora|centos|rhel|alpine|arch)(?:\b|_|32|64|-)") |
There was a problem hiding this comment.
The regex pattern allows a hyphen - as a terminating character but not as a word boundary at the start. This creates an asymmetry that could cause issues with asset names like my-ubuntu-tool where the leading hyphen before 'ubuntu' won't match the (?:\b|_) prefix. Consider adding - to the prefix alternatives: (?:\b|_|-) to match the suffix pattern.
| macos_score < gnu_score, | ||
| "macOS assets should score lower than Linux assets when using a Linux picker" |
There was a problem hiding this comment.
The test assertion message references 'Linux picker' but doesn't verify the actual score relationship is due to the wrong OS penalty. Consider adding an assertion that verifies macos_score is negative (indicating wrong OS penalty was applied) to more explicitly test the penalty behavior.
Hyperfine Performance
|
| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
|---|---|---|---|---|
mise-2025.12.10 x -- echo |
19.3 ± 0.2 | 18.8 | 21.5 | 1.00 |
mise x -- echo |
19.5 ± 1.0 | 19.0 | 40.2 | 1.01 ± 0.05 |
mise env
| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
|---|---|---|---|---|
mise-2025.12.10 env |
18.7 ± 0.5 | 18.1 | 24.4 | 1.00 |
mise env |
18.9 ± 0.2 | 18.3 | 19.7 | 1.01 ± 0.03 |
mise hook-env
| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
|---|---|---|---|---|
mise-2025.12.10 hook-env |
18.8 ± 0.2 | 18.4 | 20.5 | 1.00 |
mise hook-env |
19.1 ± 0.4 | 18.5 | 24.6 | 1.02 ± 0.02 |
mise ls
| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
|---|---|---|---|---|
mise-2025.12.10 ls |
16.4 ± 0.2 | 16.0 | 17.5 | 1.00 |
mise ls |
16.7 ± 0.6 | 16.1 | 22.8 | 1.02 ± 0.04 |
xtasks/test/perf
| Command | mise-2025.12.10 | mise | Variance |
|---|---|---|---|
| install (cached) | 107ms | 108ms | +0% |
| ls (cached) | 64ms | 65ms | -1% |
| bin-paths (cached) | 70ms | 71ms | -1% |
| task-ls (cached) | 275ms | 274ms | +0% |
### 🚀 Features - **(alias)** rename alias to tool-alias, add shell-alias command by @jdx in [#7357](#7357) - **(upgrade)** display summary of upgraded tools by @jdx in [#7372](#7372) - **(vfox)** embed vfox plugin Lua code in binary by @jdx in [#7369](#7369) ### 🐛 Bug Fixes - **(aqua)** add start_operations for progress reporting by @jdx in [#7354](#7354) - **(github)** improve asset detection for distro-specific and Swift artifacts by @jdx in [#7347](#7347) - **(github)** clean up static_helpers.rs and fix archive bin= option by @jdx in [#7366](#7366) - **(http)** add start_operations for progress reporting by @jdx in [#7355](#7355) - **(lockfile)** place lockfile alongside config file by @jdx in [#7360](#7360) - **(progress)** add start_operations to core plugins by @jdx in [#7351](#7351) - **(ruby-install)** Use ruby_install_bin to update by @calebhearth in [#7350](#7350) - **(rust)** add release_url for rust versions by @jdx in [#7373](#7373) - **(schema)** add `tool_alias`, mark `alias` as deprecated by @SKalt in [#7358](#7358) - **(toolset)** filter tools by OS in list_current_versions by @jdx in [#7356](#7356) - **(ubi)** only show deprecation warning during installation by @jdx in [#7380](#7380) - **(ui)** remove noisy "record size" message during install by @jdx in [#7381](#7381) - update mise-versions URL to use /tools/ prefix by @jdx in [#7378](#7378) ### 🚜 Refactor - **(backend)** unified AssetMatcher with checksum fetching by @jdx in [#7370](#7370) - **(backend)** deprecate ubi backend in favor of github by @jdx in [#7374](#7374) - **(toolset)** decompose mod.rs into smaller modules by @jdx in [#7371](#7371) ### 🧪 Testing - **(e2e)** fix and rename ubi and vfox_embedded_override tests by @jdx in [052ea40](052ea40) ### 📦 Registry - add vfox-gcloud backend for gcloud by @jdx in [#7349](#7349) - convert amplify to use github backend by @jdx in [#7365](#7365) - add github backend for djinni tool by @jdx in [#7363](#7363) - switch glab to native gitlab backend by @jdx in [#7364](#7364) - add s5cmd by @jdx in [#7376](#7376) ### Chore - **(registry)** disable flaky tests for gitu and ktlint by @jdx in [64151cb](64151cb) - resolve clippy warnings and add stricter CI check by @jdx in [#7367](#7367) - suppress dead_code warnings in asset_matcher module by @jdx in [#7377](#7377) ### New Contributors - @calebhearth made their first contribution in [#7350](#7350)
* upstream/main: fix(lockfile): place lockfile alongside config file (jdx#7360) feat(alias): rename alias to tool-alias, add shell-alias command (jdx#7357) fix(aqua): add start_operations for progress reporting (jdx#7354) fix(schema): add `tool_alias`, mark `alias` as deprecated (jdx#7358) fix(progress): add start_operations to core plugins (jdx#7351) fix(toolset): filter tools by OS in list_current_versions (jdx#7356) registry: add vfox-gcloud backend for gcloud (jdx#7349) fix(github): improve asset detection for distro-specific and Swift artifacts (jdx#7347)
Summary
.artifactbundle.zipfiles (Swift Package Manager bundles) which are not suitable for direct tool installationFixes #7345
Problem
The GitHub backend was selecting wrong release assets for Sourcery on macOS:
sourcery-X.Y.Z.artifactbundle.zip(Swift Package Manager bundle) instead ofsourcery-X.Y.Z.zip(actual macOS binary)sourcery-X.Y.Z-ubuntu-jammy-22.04.3-lts-aarch64.tar.xz)Root cause: The asset scoring algorithm had two issues:
Test plan
test_sourcery_macos_assetsthat verifies macOS picks plain.zipover artifactbundle and ubuntutest_artifactbundle_penaltythat verifies.artifactbundle.zipscores lower than plain.ziptest_ubuntu_detected_as_linuxthat verifies ubuntu is detected as Linux🤖 Generated with Claude Code
Note
Recognizes Linux distro names, increases wrong-OS penalty, penalizes
.artifactbundlefiles, and adds tests to validate correct asset selection.src/backend/asset_detector.rs)ubuntu,debian,fedora,centos,rhel,alpine,arch.-50to-100so it outweighs arch match bonus..artifactbundle(-30).test_sourcery_macos_assets,test_artifactbundle_penalty,test_ubuntu_detected_as_linux.Written by Cursor Bugbot for commit acc48cc. This will update automatically on new commits. Configure here.