Learning and Sharing
  • Home
  • Blog
  • Linux
  • macOS
  • Virtualization
    • VMware
    • VirtualBox
  • Windows
    • Windows 11
    • Windows 10
    • Windows Server
  • Series
    • Symantec
    • Intune
    • Microsoft Azure
    • Powershell
    • VirtualBox
    • VMware
    • PowerShell Learning
    • Microsoft Graph
  • More
    • Auto Installation
    • AEC Installation
  • Contact
No Result
View All Result
  • Home
  • Blog
  • Linux
  • macOS
  • Virtualization
    • VMware
    • VirtualBox
  • Windows
    • Windows 11
    • Windows 10
    • Windows Server
  • Series
    • Symantec
    • Intune
    • Microsoft Azure
    • Powershell
    • VirtualBox
    • VMware
    • PowerShell Learning
    • Microsoft Graph
  • More
    • Auto Installation
    • AEC Installation
  • Contact
No Result
View All Result
No Result
View All Result

Download Artifacts from a Latest GitHub Release with PowerShell

October 31, 2022
in Blog, Linux
0
ADVERTISEMENT

Table of Contents

Using PowerShell to Retrieve Latest Package Url from GitHub

Lately I’ve been working on an application for which the releases are published on GitHub, and I wanted to use PowerShell to always downloads the latest release.

It turned out that downloading the artifacts for a specific version is easy, we can simply build an URL with the version number to access the artifact. However, there is no direct URL to download artifacts from the latest release, so we need a bit of logic in PowerShell to do that.

Link structure

We can access a particular release with a URL like https://github.com/<user>/<repo>/releases/tag/v1.x.x. (The part after tag/ is what we specified when we created the release.)

Bg2239
Note And there is this URL, which always takes us to the latest release of a project: https://github.com/user/repo/releases/latest.

Artifacts from this particular release can be downloaded with the URL https://github.com/<user>/<repo>/releases/download/v1.x.x/myArtifact.zip

Bg2240

Getting the latest version from GitHub

Take a look the link of zlib project https://github.com///releases/latest.

  • <user> = madler
  • <repo> = zlib

The following example demonstrates this by fetching the latest Windows x64 release .zip file of the PowerShell: https://github.com/PowerShell/PowerShell/releases/latest

Bg2238
$url = 'https://github.com/PowerShell/PowerShell/releases/latest'
$request = [System.Net.WebRequest]::Create($url)
$response = $request.GetResponse()
$tagUrl = $response.ResponseUri.OriginalString
$version = $tagUrl.split('/')[-1].Trim('v')
$fileName = "PowerShell-$version-win-x64.zip"

###Create the download link
$downloadUrl = $tagUrl.Replace('tag', 'download') + '/' + $fileName

###Create a folder then download to the temp folder
New-Item -Path $env:TEMP/pwsh -ItemType Directory -Force
Invoke-WebRequest -Uri $downloadUrl -OutFile $env:TEMP/pwsh/$fileName  

###Open the destination folder
Invoke-Item $env:TEMP/pwsh

Downloading the latest version of PowerShell from GitHub using PowerShell.

Bg2241

Once done, you can see the package is saved in the destination folder.

Bg2242
ADVERTISEMENT
5/5 - (1 vote)
Previous Post

How to Download Artifacts from a Latest GitHub Release with Bash

Next Post

How to Download the Latest Package from GitHub using PowerShell

Related Posts

Running Hyper-V and VMware Workstation on The Same Machine

August 15, 2024

How to Uninstall All Autodesk Products At Once Silently

July 29, 2024
Ftr5

How to Uninstall the Autodesk Genuine Service on Windows

July 29, 2024
Ftr19

How to Fix Windows Cannot Read the ProductKey From the Unattend Answer File in VirtualBox

July 26, 2024
Ftr25

How to Update Windows Terminal in Windows 10/11

July 26, 2024

How to Disable The Beep Sound in WSL Terminal on Windows

July 26, 2024

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Recent Posts

  • How To Turn On uBlock Origin Extension in Chrome (2025)
  • Images Hidden Due To Mature Content Settings In CivitAI
  • Azure OpenAI vs Azure AI Hub, How to Choose the Right One for Your Needs

Categories

Stay in Touch

Discord Server

Join the Discord server with the site members for all questions and discussions.

Telegram Community

Jump in Telegram server. Ask questions and discuss everything with the site members.

Youtube Channel

Watch more videos, learning and sharing with Leo ❤❤❤. Sharing to be better.

Newsletter

Join the movement and receive our weekly Tech related newsletter. It’s Free.

General

Microsoft Windows

Microsoft Office

VMware

VirtualBox

Technology

PowerShell

Microsoft 365

Microsoft Teams

Email Servers

Copyright 2025 © All rights Reserved. Design by Leo with ❤

No Result
View All Result
  • Home
  • Linux
  • Intune
  • macOS
  • VMware
  • VirtualBox
  • Powershell
  • Windows 10
  • Windows 11
  • Microsoft 365
  • Microsoft Azure
  • Microsoft Office
  • Active Directory

No Result
View All Result
  • Home
  • Linux
  • Intune
  • macOS
  • VMware
  • VirtualBox
  • Powershell
  • Windows 10
  • Windows 11
  • Microsoft 365
  • Microsoft Azure
  • Microsoft Office
  • Active Directory