You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
gh release create wildcard '*' not working on windows #5099
As the title states, I can't seem to find a way to submit multiple files with a wildcard. Straight from the docs, this sample command fails:
gh release create v1.2.3 ./dist/*.tgz
with the following message:
CreateFile ./dist/*.tgz: The filename, directory name, or volume label syntax is incorrect.
If I run the command, with an individual file, it works such as:
gh release create v1.2.3 dist\Tool-Linux.tgz
It works.
If I open up a Linux terminal, such as git bash, and try the command in there, it works.
Steps to reproduce the behavior
Type this
dir /b dist
View the output
Tool-Linux.tgz
Tool-MacOS.tgz
Tool-Windows.tgz
Type this
gh release create v1.2.3 ./dist/*.tgz
View the output
See error
CreateFile ./dist/*.tgz: The filename, directory name, or volume label syntax is incorrect.
I also tried:
gh release create v1.2.3 .\dist*.tgz
gh release create v1.2.3 dist*.tgz
Unlike other platforms, Windows does not auto-expand wildcards in its shells when passing arguments to commands. For example, even though PowerShell has support for wildcard expansion like ls ./dist/*.tgz, it does not automatically perform such expansion. You can work around it by using the following expression in powershell:
To make it easier for gh users (and to make the example code that you pointed out work on Windows), I propose that we additionally expand glob expressions in arguments to commands such as gist create, release create, and release upload. This should perhaps only be done on Windows, since users on other platforms might be surprised that globs are additionally expanded by the gh process in addition to their shell.
Reacted by Gabriel Weyer, James John McGuire, arcsector, Abubakar Riaz, Hailin Wang, MareMare, Yevheniy Tymchishin, Alberto, Hypothalamus, Max Kagamine and 1 more
Another workaround to use when using cmd and not PowerShell is described here (found via this superuser answer) and could be used like this (note that this will invoke the tool once for each filename, so it's strictly speaking not equivalent to gh release create v1.2.3 dist/*.tgz on *NIX shells if there are multiple matching files):
for /R %i in (dist\*.tgz) DO gh release create v1.2.3 %i
Of course, eventually replacing this with wildcard/glob expansion in gh would clean things up a lot.
A quick search reveals AssetsFromArgs might be the place where this can be added (at least for upload and create), but my golang skills are insufficient (read: non-existent) to actually go (ha!) and implement this:
Given a call to gist create, release create, or release upload command when a wildcard is used in the <files>... field then that wildcard is expanded on all platforms by gh
Activity
mislav commentedon Jan 25, 2022
Thank you for reporting!
Unlike other platforms, Windows does not auto-expand wildcards in its shells when passing arguments to commands. For example, even though PowerShell has support for wildcard expansion like
ls ./dist/*.tgz, it does not automatically perform such expansion. You can work around it by using the following expression in powershell:To make it easier for
ghusers (and to make the example code that you pointed out work on Windows), I propose that we additionally expand glob expressions in arguments to commands such asgist create,release create, andrelease upload. This should perhaps only be done on Windows, since users on other platforms might be surprised that globs are additionally expanded by theghprocess in addition to their shell.jessehouwing commentedon Feb 7, 2022
The problem with parsing
(dir *.*)is that it only works in PowerShell and that the expanded command becomes too long, causing execution to fail.Commands like
git add *.zipwork fine, because the tool expands the wildcard internally.mislav commentedon Mar 18, 2022
Let's just follow git's lead and expand wildcards on all platforms then, not just Windows. PRs welcome!
thp-stopsmops commentedon Feb 15, 2023
Another workaround to use when using
cmdand not PowerShell is described here (found via this superuser answer) and could be used like this (note that this will invoke the tool once for each filename, so it's strictly speaking not equivalent togh release create v1.2.3 dist/*.tgzon *NIX shells if there are multiple matching files):Of course, eventually replacing this with wildcard/glob expansion in
ghwould clean things up a lot.A quick search reveals
AssetsFromArgsmight be the place where this can be added (at least foruploadandcreate), but my golang skills are insufficient (read: non-existent) to actually go (ha!) and implement this:cli/pkg/cmd/release/shared/upload.go
Line 37 in 7caf7da
fix for cli/cli#5099
fix for cli/cli#5099
ci: fix release action
jtmcg commentedon Feb 10, 2025
Acceptance Criteria
Given a call to
gist create,release create, orrelease uploadcommandwhen a wildcard is used in the
<files>...fieldthen that wildcard is expanded on all platforms by
gh