How to download the latest GitHub repo release via command line

I just fiddled around a bit to find out how to download the latest GitHub release via the command line. Turns out that GitHub doesn’t provide a universal download URL to release binaries like it does for the release browser page itself. The latest release page can always be reached via https://github.com/ORGANIZATION/REPO/releases/latest, e.g. https://github.com/gvenzl/csv2db/releases/latest. Unfortunately that is not true for the binaries, which are available under https://github.com/ORGANIZATION/REPO/archive/RELEASE_TAG.zip and https://github.com/ORGANIZATION/REPO/archive/RELEASE_TAG.tar.gz but not under something generic like https://github.com/ORGANIZATION/REPO/archive/latest.zip and https://github.com/ORGANIZATION/REPO/archive/latest.tar.gz

The issue here is that GitHub only provides the release binaries under their actual release tag, e.g. v1.0.0, but that tag is entirely up to the user to define and changes as more releases are added, of course. It’s therefore hard to guess what the release tag would be and what to download. Nevertheless, thanks to the GitHub developer APIs it’s not that tricky to figure out the release tag for the latest release and instruct a utility like curl to download the binary. I’ve written a little one-liner for the UNIX command line to do exactly that. It took me a bit to get it right and so I thought it might come handy to you, rather than trying to reinvent the wheel. it It’s also available as a public Gist but I thought for visibility purposes it makes sense to blog it here, too.

LOCATION=$(curl -s https://api.github.com/repos/YOUR_ORGANIZTION/YOUR_REPO/releases/latest \
| grep "tag_name" \
| awk '{print "https://github.com/YOUR_ORGANIZATION/YOUR_REPO/archive/" substr($2, 2, length($2)-3) ".zip"}') \
; curl -L -o OUTPUT_FILE_NAME $LOCATION

For example:

LOCATION=$(curl -s https://api.github.com/repos/gvenzl/csv2db/releases/latest \
| grep "tag_name" \
| awk '{print "https://github.com/gvenzl/csv2db/archive/" substr($2, 2, length($2)-3) ".zip"}') \
; curl -L -o csv2db.zip $LOCATION

Here is how it goes:

LOCATION=$(...)

stores the output of all the commands in the brackets in the variable $LOCATION,

curl -s https://api.github.com/repos/gvenzl/csv2db/releases/latest

gets the latest release from your repository, in my case https://github.com/gvenzl/csv2db,

grep "tag_name"

grabs the tag name of the latest release (e.g. v1.0.0),

awk '{print "https://github.com/gvenzl/csv2db/archive/" substr($2, 2, length($2)-3) ".zip"}'

prints https://github.com/gvenzl/csv2db/archive/ + v1.0.0.zip
–>
https://github.com/gvenzl/csv2db/archive/v1.0.0.zip.

Now the $LOCATION environment variable is set to that string. From that point on you can do with that variable whatever you like, in case you have another use than downloading the binary. Or, just like below, you can complete the download process:

curl -L -o csv2db.zip $LOCATION

invokes cURL and downloads $LOCATION into csv2db.zip. The -L parameter is important so that cURL follows the URL, i.e. redirect.

Hope this helps.

How to install Python 3 on Oracle Linux

You can install Python 3 on your Oracle Linux 7 environment with three simple steps:

  1. sudo yum install -y yum-utils
  2. sudo yum-config-manager --enable *EPEL
  3. sudo yum install -y python36

As a first step, in case you don’t have it yet on your system, is to install the yum-utils package. This package includes the yum-config-manager which allows you to easily enable and disable yum repositories, amongst other tasks.

[gerald@localhost ~]$ sudo yum install -y yum-utils
Loaded plugins: langpacks, ulninfo
Resolving Dependencies
--> Running transaction check
---> Package yum-utils.noarch 0:1.1.31-46.0.1.el7_5 will be updated
---> Package yum-utils.noarch 0:1.1.31-50.0.1.el7 will be an update
--> Finished Dependency Resolution

Dependencies Resolved

=====================================================================================================================================
Package Arch Version Repository Size
=====================================================================================================================================
Updating:
yum-utils noarch 1.1.31-50.0.1.el7 ol7_latest 121 k

Transaction Summary
=====================================================================================================================================
Upgrade 1 Package

Total download size: 121 k
Downloading packages:
No Presto metadata available for ol7_latest
yum-utils-1.1.31-50.0.1.el7.noarch.rpm | 121 kB 00:00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Updating : yum-utils-1.1.31-50.0.1.el7.noarch 1/2
Cleanup : yum-utils-1.1.31-46.0.1.el7_5.noarch 2/2
Verifying : yum-utils-1.1.31-50.0.1.el7.noarch 1/2
Verifying : yum-utils-1.1.31-46.0.1.el7_5.noarch 2/2

Updated:
yum-utils.noarch 0:1.1.31-50.0.1.el7

Complete!
[gerald@localhost ~]$

Python 3 ships as part of the EPEL (Extra Packages for Enterprise Linux) repository but that repository is not enabled by default. With yum-config-manager enabling that repository is easy:



[gerald@localhost ~]$ sudo yum-config-manager --enable *EPEL
Loaded plugins: langpacks
===================================================== repo: ol7_developer_EPEL ======================================================
[ol7_developer_EPEL]
async = True
bandwidth = 0
base_persistdir = /var/lib/yum/repos/x86_64/7Server
baseurl = https://yum.oracle.com/repo/OracleLinux/OL7/developer_EPEL/x86_64/
cache = 0
cachedir = /var/cache/yum/x86_64/7Server/ol7_developer_EPEL
check_config_file_age = True
compare_providers_priority = 80
cost = 1000
deltarpm_metadata_percentage = 100
deltarpm_percentage =
enabled = 1
enablegroups = True
exclude =
failovermethod = priority
ftp_disable_epsv = False
gpgcadir = /var/lib/yum/repos/x86_64/7Server/ol7_developer_EPEL/gpgcadir
gpgcakey =
gpgcheck = True
gpgdir = /var/lib/yum/repos/x86_64/7Server/ol7_developer_EPEL/gpgdir
gpgkey = file:///etc/pki/rpm-gpg/RPM-GPG-KEY-oracle
hdrdir = /var/cache/yum/x86_64/7Server/ol7_developer_EPEL/headers
http_caching = all
includepkgs =
ip_resolve =
keepalive = True
keepcache = False
mddownloadpolicy = sqlite
mdpolicy = group:small
mediaid =
metadata_expire = 21600
metadata_expire_filter = read-only:present
metalink =
minrate = 0
mirrorlist =
mirrorlist_expire = 86400
name = Oracle Linux 7Server Development Packages (x86_64)
old_base_cache_dir =
password =
persistdir = /var/lib/yum/repos/x86_64/7Server/ol7_developer_EPEL
pkgdir = /var/cache/yum/x86_64/7Server/ol7_developer_EPEL/packages
proxy = False
proxy_dict =
proxy_password =
proxy_username =
repo_gpgcheck = False
retries = 10
skip_if_unavailable = False
ssl_check_cert_permissions = True
sslcacert =
sslclientcert =
sslclientkey =
sslverify = True
throttle = 0
timeout = 30.0
ui_id = ol7_developer_EPEL/x86_64
ui_repoid_vars = releasever,
basearch
username =

[gerald@localhost ~]$

Now you are ready to install Python 3, version 3.6 in this case:


[gerald@localhost ~]$ sudo yum install -y python36
Loaded plugins: langpacks, ulninfo
ol7_UEKR4 | 1.2 kB 00:00:00
ol7_developer_EPEL | 1.2 kB 00:00:00
ol7_latest | 1.4 kB 00:00:00
(1/2): ol7_developer_EPEL/x86_64/updateinfo | 2.4 kB 00:00:00
(2/2): ol7_developer_EPEL/x86_64/primary | 8.0 MB 00:00:05
ol7_developer_EPEL 24145/24145
Resolving Dependencies
--> Running transaction check
---> Package python36.x86_64 0:3.6.6-1.el7 will be installed
--> Processing Dependency: python36-libs(x86-64) = 3.6.6-1.el7 for package: python36-3.6.6-1.el7.x86_64
--> Processing Dependency: libpython3.6m.so.1.0()(64bit) for package: python36-3.6.6-1.el7.x86_64
--> Running transaction check
---> Package python36-libs.x86_64 0:3.6.6-1.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

=====================================================================================================================================
Package Arch Version Repository Size
=====================================================================================================================================
Installing:
python36 x86_64 3.6.6-1.el7 ol7_developer_EPEL 65 k
Installing for dependencies:
python36-libs x86_64 3.6.6-1.el7 ol7_developer_EPEL 8.6 M

Transaction Summary
=====================================================================================================================================
Install 1 Package (+1 Dependent package)

Total download size: 8.6 M
Installed size: 36 M
Downloading packages:
(1/2): python36-3.6.6-1.el7.x86_64.rpm | 65 kB 00:00:00
(2/2): python36-libs-3.6.6-1.el7.x86_64.rpm | 8.6 MB 00:00:08
-------------------------------------------------------------------------------------------------------------------------------------
Total 1.0 MB/s | 8.6 MB 00:00:08
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : python36-3.6.6-1.el7.x86_64 1/2
Installing : python36-libs-3.6.6-1.el7.x86_64 2/2
Verifying : python36-libs-3.6.6-1.el7.x86_64 1/2
Verifying : python36-3.6.6-1.el7.x86_64 2/2

Installed:
python36.x86_64 0:3.6.6-1.el7

Dependency Installed:
python36-libs.x86_64 0:3.6.6-1.el7

Complete!
[gerald@localhost ~]$

You can verify the installation via python36 --version:

[gerald@localhost ~]$ python36 --version
Python 3.6.6
[gerald@localhost ~]$

How to enable auto start/shutdown for Oracle Database 18c Express Edition on Linux

Oracle Database 18c Express Edition can be enabled for automatic startup and shutdown with the Linux operating system. This will not only allow you not to worry about starting and stopping the database but it will also ensure that the database is properly shutdown before the machine is powered off. Enabling auto startup/shutdown is done via two simple commands:

  1. systemctl daemon-reload
  2. systemctl enable oracle-xe-18c

These commands will have to be executed either via the root user or with root privileges:

[root@localhost ~]# systemctl daemon-reload
[root@localhost ~]# systemctl enable oracle-xe-18c
oracle-xe-18c.service is not a native service, redirecting to /sbin/chkconfig.
Executing /sbin/chkconfig oracle-xe-18c on

For more information about starting and stopping Oracle Database XE, have a look at the documentation.

How to install Oracle Database 18c XE on Linux

The new version of the free Oracle Database edition, Oracle Database 18c Express Edition, just got released for Linux 64-bit. Getting started is really simple on Oracle Linux, basically a three step process of downloading the RPM file, installing it and then configuring the database. On other Red Hat  compatible Linux distributions you will also have to download the Oracle Database Preinstall RPM alongside the XE RPM file. Here is a quick guide on how to setup Oracle Database 18c XE.

tl;dr

Oracle Linux

  1. Download the RPM file from Oracle Technology Network
  2. Run “yum -y localinstall oracle-database*18c*
  3. Run “/etc/init.d/oracle-xe-18c configure

Other Red Hat compatible Linux distribution

  1. Download the RPM file from Oracle Technology Network
  2. Download the Oracle Database Preinstall RPM via “curl -o oracle-database-preinstall-18c-1.0-1.el7.x86_64.rpm https://yum.oracle.com/repo/OracleLinux/OL7/latest/x86_64/getPackage/oracle-database-preinstall-18c-1.0-1.el7.x86_64.rpm
  3. Run “yum -y localinstall oracle-database*18c*
  4. Run “/etc/init.d/oracle-xe-18c configure

Continue reading “How to install Oracle Database 18c XE on Linux”

Oracle Database 18c Express Edition is Generally Available!

Oracle just released the new version of Oracle Database Express Edition (XE), a free edition of Oracle Database. This release means something special to me, as I have been closely involved in it and with the great team that brought us Oracle Database 18c XE.

Continue reading “Oracle Database 18c Express Edition is Generally Available!”