Repository navigation
gh release create wildcard '*' not working on windows #5099
Description
Activity
- addedpriority-3Affects a small number of users or is largely cosmeticAffects a small number of users or is largely cosmetichelp wantedContributions welcomeContributions welcomeand removedneeds-triageneeds to be reviewedneeds to be reviewed
on 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:> gh release create v1.2.3 (get-item .\dist\*.tgz)
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.Reacted by Gabriel Weyer, James John McGuire, arcsector, Abubakar Riaz, Hailin Wang, MareMare, Yevheniy Tymchishin, Alberto, Hypothalamus, Max Kagamine and 1 more- addedpriority-2Affects more than a few users but doesn't prevent core functionsAffects more than a few users but doesn't prevent core functionsand removedpriority-3Affects a small number of users or is largely cosmeticAffects a small number of users or is largely cosmetic
on Jan 25, 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.ResourceUnavailable: D:\a\azure-pipelines-tasks-zips\azure-pipelines-tasks-zips\build.ps1:27 Line | 27 | & gh release create $tag -t "$tag" --target main -n """" ((dir _d … | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | Program 'gh.exe' failed to run: An error occurred trying to start process 'C:\Program Files | (x86)\GitHub CLI\gh.exe' with working directory | 'D:\a\azure-pipelines-tasks-zips\azure-pipelines-tasks-zips'. The filename or extension is too long.At | D:\a\azure-pipelines-tasks-zips\azure-pipelines-tasks-zips\build.ps1:27 char:5 + & gh release | create $tag -t "$tag" --target main -n """" ((dir _d … + | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~.Commands like
git add *.zipwork fine, because the tool expands the wildcard internally.Let's just follow git's lead and expand wildcards on all platforms then, not just Windows. PRs welcome!
Reacted by Jesse HouwingAnother 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):for /R %i in (dist\*.tgz) DO gh release create v1.2.3 %iOf 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
func AssetsFromArgs(args []string) (assets []*AssetForUpload, err error) { - addedgh-releaserelating to the gh release commandrelating to the gh release command
on Oct 2, 2023 Acceptance Criteria
Given a call to
gist create,release create, orrelease uploadcommand
when a wildcard is used in the<files>...field
then that wildcard is expanded on all platforms byghReacted by James John McGuire and Azeem
Describe the bug
gh --version
gh version 2.4.0 (2021-12-21)
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
cd dist
gh release create v1.2.3 *.tgz
with no succcess
Expected vs actual behavior
A successfully submited release tag