Skip to content

Instantly share code, notes, and snippets.

@JV-conseil
Last active May 16, 2024 21:02
Show Gist options
  • Save JV-conseil/d7e56fad60936775b0dea2c6216679d5 to your computer and use it in GitHub Desktop.
Save JV-conseil/d7e56fad60936775b0dea2c6216679d5 to your computer and use it in GitHub Desktop.

Download the latest release of a GitHub repository

Become a sponsor to JV-conseil Follow JV conseil on StackOverflow Follow JV conseil on LinkedIn Follow JVconseil on Twitter Follow JVconseil on Mastodon Follow JV conseil on GitHub

This solution downloads the latest release tar.gz archive of a GitHub repository with GitHub CLI command line.

To use the gh release download command we need to pick the tag of the latest release, here is how

gh release list --limit 1 --json "tagName" --jq ".[].tagName"

Then provide this tag to the gh release download command

gh release download \
  "$(gh release list --limit 1 --json "tagName" --jq ".[].tagName")" \
  --archive="tar.gz"

The overall code πŸ‘‡

#!/usr/bin/env bash
# -*- coding: UTF-8 -*-
#
# github   : https://github.com/JV-conseil
# www      : https://www.jv-conseil.net
# author   : JV-conseil
#
# gh release download & list
# see: <https://cli.github.com/manual/gh_release_download>
#
#====================================================

# Retrieve the tag of the latest release
_jvcl_::gh_release_latest_tag() {
  gh release list --limit 1 --json "tagName" --jq ".[].tagName"
}

# Download the latest release archive in tar.gz
# to a local directory
_jvcl_::gh_release_download() {
  local _dir_backup="${1:-"./Downloads"}"
  gh release download \
    "$(_jvcl_::gh_release_latest_tag)" \
    --archive="tar.gz" \
    --dir="${_dir_backup}"
}

_jvcl_::gh_release_download "./path_to_a_folder"

This solution does not provide a link stricto sensu as requested by the question, but is convenient to work with public and private repositories.

πŸ‘‰ Read the answer on stackoverflow.com

PostgreSQL JSON Dump

Become a sponsor to JV-conseil Follow JV conseil on StackOverflow Follow JV conseil on LinkedIn Follow JVconseil on Twitter Follow JVconseil on Mastodon Follow JV conseil on GitHub

This combination of PostgreSQL COPY ... TO PROGRAM and sed escaped properly the double quotes in a json compressed gzip data dumpπŸ‘‡

\copy (
 SELECT json_agg(row_to_json(T)) :: text FROM (
  SELECT title, author, year FROM books WHERE category NOT LIKE 'fiction'
 ) AS T
) TO PROGRAM
'sed ''s~\\\\~\\~g'' | gzip > ./books-`date +"%Y%m%d-%H%M%S"`.json.gz' ;

πŸ‘‰ Read the answer on stackoverflow.com

Exporting GitHub issues to CSV

Become a sponsor to JV-conseil Follow JV conseil on StackOverflow Follow JV conseil on LinkedIn Follow JVconseil on Twitter Follow JVconseil on Mastodon Follow JV conseil on GitHub

gh GitHub CLI integrates now jq with --jq <expression> to filter JSON output using a jq expression as documented on GitHub CLI Manual https://cli.github.com/manual/gh_issue_list.

TSV dump.

gh issue list \
  --limit 10 \
  --state all \
  --json title,body \
  --jq '["title","body"], (.[] | [.title,.body]) | @tsv' \
  >"issues-$(date '+%Y-%m-%d').tsv"

CSV dump

Surprisingly 000D unicode character need to be filtered out with tr $'\x{0D}' ' '.

gh issue list \
  --limit 10 \
  --state all \
  --json title,body \
  --jq '["title","body"], (.[] | [.title,.body]) | @csv' |
  tr $'\x{0D}' ' ' \
    >"issues-$(date '+%Y-%m-%d').csv"

πŸ‘‰ Read the answer on stackoverflow.com

author tags
JV conseil (JV-conseil)
git-lfs
obsidian

obsidian-git Large File Storage LFS

Become a sponsor to JV-conseil Follow JV conseil on StackOverflow Follow JV conseil on LinkedIn Follow JVconseil on Twitter Follow JVconseil on Mastodon Follow JV conseil on GitHub

Adding

/opt/homebrew/bin

in

Obsidian Git > Advanced > Additional PATH environment variable paths

worked for me πŸ‘Œ

Adding :opt:homebrew:bin in Obsidian Git   Advanced   Additional PATH environment variable paths

Git LFS commit and push now work on Obsidian with git-lfs installed with Homebrew βœ…

πŸ‘‰ Read the answer on github.com

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment