Repository navigation
Replies: 4 comments 3 replies
|
@exekutive Hello! I think that it is depend on tag name. Name of archive is |
|
I tested this against a couple of public repos with
So the practical convention is close to: But if your script needs something reliable, I still would not build too much logic around the extracted directory name. The safer pattern is:
gh release view --repo OWNER/REPO --json tagName
gh release download --repo OWNER/REPO <tag> --archive=zip --output source.zipThat way your script does not have to guess the archive filename or the unpacked folder name. |
|
There isn't a Practical approach in a script: Using If this answers it, please mark this comment as the answer — thanks! |
|
There is a convention, and it is stable enough to rely on — but you do not need to guess it, because The convention for source archives (the auto-generated ones):
Specifically: GitHub strips a leading Two caveats that break the assumption:
The reliable approach — ask instead of guessing: tag=$(gh release view "$TAG" --repo "$REPO" --json tagName --jq .tagName)then, instead of predicting the folder, extract into your own directory: gh release download "$TAG" --repo "$REPO" --archive=tar.gz
mkdir -p src && tar -xzf ./*.tar.gz -C src --strip-components=1
cd src
gh release download "$TAG" --repo "$REPO" --archive=zip
mkdir -p src && unzip -q ./*.zip -d src
cd src/*/ && mv * .. 2>/dev/null; cd ..If you specifically want the folder name as data: |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
I'm writing a shell script to download github repo releases using the gh CLI, unarchive them, and then change to the enclosed source directory.
The zip that gets downloaded always has a directory containing the files, but the name of that directory doesn't appear to be consistent to me. Is there a naming convention for this directory, or some way to predict it, or determine its name using gh commands?
For example the directory for jubalh/nudoku becomes
nudoku-5.0.0and the directory for doctorfree/ninvaders is
ninvaders-1.0.0r1All reactions