Unpacking Software Livestream

Join our monthly Unpacking Software livestream to hear about the latest news, chat and opinion on packaging, software deployment and lifecycle management!

Learn More

Chocolatey Product Spotlight

Join the Chocolatey Team on our regular monthly stream where we put a spotlight on the most recent Chocolatey product releases. You'll have a chance to have your questions answered in a live Ask Me Anything format.

Learn More

Chocolatey Coding Livestream

Join us for the Chocolatey Coding Livestream, where members of our team dive into the heart of open source development by coding live on various Chocolatey projects. Tune in to witness real-time coding, ask questions, and gain insights into the world of package management. Don't miss this opportunity to engage with our team and contribute to the future of Chocolatey!

Learn More

Calling All Chocolatiers! Whipping Up Windows Automation with Chocolatey Central Management

Webinar from
Wednesday, 17 January 2024

We are delighted to announce the release of Chocolatey Central Management v0.12.0, featuring seamless Deployment Plan creation, time-saving duplications, insightful Group Details, an upgraded Dashboard, bug fixes, user interface polishing, and refined documentation. As an added bonus we'll have members of our Solutions Engineering team on-hand to dive into some interesting ways you can leverage the new features available!

Watch On-Demand
Chocolatey Community Coffee Break

Join the Chocolatey Team as we discuss all things Community, what we do, how you can get involved and answer your Chocolatey questions.

Watch The Replays
Chocolatey and Intune Overview

Webinar Replay from
Wednesday, 30 March 2022

At Chocolatey Software we strive for simple, and teaching others. Let us teach you just how simple it could be to keep your 3rd party applications updated across your devices, all with Intune!

Watch On-Demand
Chocolatey For Business. In Azure. In One Click.

Livestream from
Thursday, 9 June 2022

Join James and Josh to show you how you can get the Chocolatey For Business recommended infrastructure and workflow, created, in Azure, in around 20 minutes.

Watch On-Demand
The Future of Chocolatey CLI

Livestream from
Thursday, 04 August 2022

Join Paul and Gary to hear more about the plans for the Chocolatey CLI in the not so distant future. We'll talk about some cool new features, long term asks from Customers and Community and how you can get involved!

Watch On-Demand
Hacktoberfest Tuesdays 2022

Livestreams from
October 2022

For Hacktoberfest, Chocolatey ran a livestream every Tuesday! Re-watch Cory, James, Gary, and Rain as they share knowledge on how to contribute to open-source projects such as Chocolatey CLI.

Watch On-Demand

Downloads:

142

Downloads of v 0.1:

142

Last Update:

17 Oct 2022

Package Maintainer(s):

Software Author(s):

  • Teknowledgist

Tags:

largh latest release github update version au powershell module foss

Latest Release on GitHub Helper

  • 1
  • 2
  • 3

0.1 | Updated: 17 Oct 2022

Downloads:

142

Downloads of v 0.1:

142

Maintainer(s):

Software Author(s):

  • Teknowledgist

Latest Release on GitHub Helper 0.1

  • 1
  • 2
  • 3

All Checks are Passing

3 Passing Tests


Validation Testing Passed


Verification Testing Passed

Details

Scan Testing Successful:

No detections found in any package files

Details
Learn More

Deployment Method: Individual Install, Upgrade, & Uninstall

To install Latest Release on GitHub Helper, run the following command from the command line or from PowerShell:

>

To upgrade Latest Release on GitHub Helper, run the following command from the command line or from PowerShell:

>

To uninstall Latest Release on GitHub Helper, run the following command from the command line or from PowerShell:

>

Deployment Method:

NOTE

This applies to both open source and commercial editions of Chocolatey.

1. Enter Your Internal Repository Url

(this should look similar to https://community.chocolatey.org/api/v2/)


2. Setup Your Environment

1. Ensure you are set for organizational deployment

Please see the organizational deployment guide

2. Get the package into your environment

  • Open Source or Commercial:
    • Proxy Repository - Create a proxy nuget repository on Nexus, Artifactory Pro, or a proxy Chocolatey repository on ProGet. Point your upstream to https://community.chocolatey.org/api/v2/. Packages cache on first access automatically. Make sure your choco clients are using your proxy repository as a source and NOT the default community repository. See source command for more information.
    • You can also just download the package and push it to a repository Download

3. Copy Your Script

choco upgrade largh -y --source="'INTERNAL REPO URL'" [other options]

See options you can pass to upgrade.

See best practices for scripting.

Add this to a PowerShell script or use a Batch script with tools and in places where you are calling directly to Chocolatey. If you are integrating, keep in mind enhanced exit codes.

If you do use a PowerShell script, use the following to ensure bad exit codes are shown as failures:


choco upgrade largh -y --source="'INTERNAL REPO URL'" 
$exitCode = $LASTEXITCODE

Write-Verbose "Exit code was $exitCode"
$validExitCodes = @(0, 1605, 1614, 1641, 3010)
if ($validExitCodes -contains $exitCode) {
  Exit 0
}

Exit $exitCode

- name: Install largh
  win_chocolatey:
    name: largh
    version: '0.1'
    source: INTERNAL REPO URL
    state: present

See docs at https://docs.ansible.com/ansible/latest/modules/win_chocolatey_module.html.


chocolatey_package 'largh' do
  action    :install
  source   'INTERNAL REPO URL'
  version  '0.1'
end

See docs at https://docs.chef.io/resource_chocolatey_package.html.


cChocoPackageInstaller largh
{
    Name     = "largh"
    Version  = "0.1"
    Source   = "INTERNAL REPO URL"
}

Requires cChoco DSC Resource. See docs at https://github.com/chocolatey/cChoco.


package { 'largh':
  ensure   => '0.1',
  provider => 'chocolatey',
  source   => 'INTERNAL REPO URL',
}

Requires Puppet Chocolatey Provider module. See docs at https://forge.puppet.com/puppetlabs/chocolatey.


4. If applicable - Chocolatey configuration/installation

See infrastructure management matrix for Chocolatey configuration elements and examples.

Package Approved

This package was approved by moderator TheCakeIsNaOH on 08 Nov 2022.

Description

Are you a Chocolatey package maintainer for software released on GitHub? Have you noticed that GitHub has made it increasingly difficult to scrape pages for information on the latest release?

The Latest Release on GitHub Helper can help you!

Maybe you use AU or maybe you have another process for updating your packages. Regardless, you no longer need to parse raw HTML to nab the version or to snag the URL for the download. This package gives you a PowerShell function that leverages the GitHub API so that you to easily check for the latest version of any (public) project. It can be as simple as:

$Release = Get-LatestReleaseOnGitHub -URL https://www.github.com/ownername/repositoryname
$version = $Release.Tag.trim('v.')
$URL = $Release.Assets | Where-Object {$_.FileName -match '\.exe'} | Select-Object -ExpandProperty DownloadURL

The $Release object will contain the name of the latest release, the principle tag (which usually contains the version), the description, the URLs for the "zipball" and "tarball" of the release code, and finally, information on each of the "assets" (i.e. files) for the release like the filename, date, size and full download URL.

Sure, you can do this yourself by installing the PowerShellForGitHub module and reading the documentation, but that's overkill for what you need to do. Install this package and keep it simple. It even has a shortened alias:

Example

Note for maintainers with LOTS of packages

The GitHub API has a speed limit of 60 queries per hour. If you have so many packages or check for updates so often that you might exceed that limit, you can create an Access Token. The Token needs no special scope or permissions and will allow you to make up to 5000 queries per hour. (Surely that is enough!) This package allows you to provide the token as a one-time thing (less safe), or have it cached so you only need to provide it once on each computer you use.

Examples:
  • Get-LARGH -URL https://github.com/ownername/repositoryname -AccessToken a1b2c3d4e5f6g7h8i9j0
    This will use the token just one time. Other than a quick test, this is not particularly helpful unless you are going to put your access token in plaintext in your code (not a good idea!), but you do things your way.

  • Get-LARGH -URL https://github.com/ownername/repositoryname -Credential
    This will request the token in a credential window and then store it encrypted within the user profile. All future uses of the function will use the cached credential without needing the switch until the -credential switch is used again and an empty/blank password is provided.

Requirements

  • PowerShell v3

tools\chocolateyInstall.ps1
$ErrorActionPreference = 'Stop'

$toolsPath = Split-Path $MyInvocation.MyCommand.Definition

$ModuleDir  = $env:psmodulepath.split(';') | Where-Object {$_ -like "$env:programfiles*"} | Select-Object -first 1

# remove the old version for an upgrade
Remove-Item -Force -Recurse "$ModuleDir\LaRGH" -ErrorAction ignore

$null = New-Item -ItemType Directory "$ModuleDir\LaRGH" -ErrorAction Ignore

Copy-Item -Recurse -Force "$toolsPath\LaRGH"  $ModuleDir

$res = Get-Module LaRGH -ListAvailable | Where-Object { (Split-Path $_.ModuleBase) -eq $ModuleDir }
if (!$res) { throw 'Module installation failed' }

Write-Host "`n$($res.Name) version $($res.Version) installed successfully at '$ModuleDir\LaRGH'"

tools\chocolateyuninstall.ps1
$ErrorActionPreference = 'Stop'

$toolsPath = Split-Path $MyInvocation.MyCommand.Definition

$ModuleDir  = $env:psmodulepath.split(';') | Where-Object {$_ -like "$env:programfiles*"} | Select-Object -first 1

# remove the old version for an upgrade
Remove-Item -Force -Recurse "$ModuleDir\LaRGH" -ErrorAction ignore

Write-Host "LaRGH module successfully removed from this system."

tools\LaRGH\LaRGH.psd1
#
# Module manifest for module 'LaRGH'
#
@{

# Script module or binary module file associated with this manifest.
RootModule = 'LaRGH.psm1'

# Version number of this module.
ModuleVersion = '0.1'

# Supported PSEditions
# CompatiblePSEditions = @()

# ID used to uniquely identify this module
GUID = 'bf45ddd2-ae6e-4034-895c-2b9ecd56b612'

# Author of this module
Author = 'Teknowledgist'

# Company or vendor of this module
CompanyName = 'Unknown'

# Copyright statement for this module
Copyright = '(c) 2022 Teknowledgist. All rights reserved.'

# Description of the functionality provided by this module
Description = 'Retrieving the latest release of a project on GitHub'

# Minimum version of the Windows PowerShell engine required by this module
PowerShellVersion = '3.0'

# Name of the Windows PowerShell host required by this module
# PowerShellHostName = ''

# Minimum version of the Windows PowerShell host required by this module
# PowerShellHostVersion = ''

# Minimum version of Microsoft .NET Framework required by this module. This prerequisite is valid for the PowerShell Desktop edition only.
# DotNetFrameworkVersion = ''

# Minimum version of the common language runtime (CLR) required by this module. This prerequisite is valid for the PowerShell Desktop edition only.
# CLRVersion = ''

# Processor architecture (None, X86, Amd64) required by this module
# ProcessorArchitecture = ''

# Modules that must be imported into the global environment prior to importing this module
# RequiredModules = @()

# Assemblies that must be loaded prior to importing this module
# RequiredAssemblies = @()

# Script files (.ps1) that are run in the caller's environment prior to importing this module.
# ScriptsToProcess = @()

# Type files (.ps1xml) to be loaded when importing this module
# TypesToProcess = @()

# Format files (.ps1xml) to be loaded when importing this module
# FormatsToProcess = @()

# Modules to import as nested modules of the module specified in RootModule/ModuleToProcess
# NestedModules = @()

# Functions to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no functions to export.
FunctionsToExport = 'Get-LatestReleaseOnGitHub'

# Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export.
CmdletsToExport = '*'

# Variables to export from this module
VariablesToExport = '*'

# Aliases to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no aliases to export.
AliasesToExport = 'Get-LaRGH'

# DSC resources to export from this module
# DscResourcesToExport = @()

# List of all modules packaged with this module
# ModuleList = @()

# List of all files packaged with this module
# FileList = @()

# Private data to pass to the module specified in RootModule/ModuleToProcess. This may also contain a PSData hashtable with additional module metadata used by PowerShell.
PrivateData = @{

    PSData = @{

        # Tags applied to this module. These help with module discovery in online galleries.
        Tags = 'chocolatey', 'update'

        # A URL to the license for this module.
        LicenseUri = 'https://www.gnu.org/licenses/gpl-3.0.html'

        # A URL to the main website for this project.
        ProjectUri = 'https://github.com/teknowledgist/Chocolatey-packages/tree/master/manual/largh'

        # A URL to an icon representing this module.
        # IconUri = ''

        # ReleaseNotes of this module
        ReleaseNotes = ''

    } # End of PSData hashtable

} # End of PrivateData hashtable

# HelpInfo URI of this module
HelpInfoURI = ''

# Default prefix for commands exported from this module. Override the default prefix using Import-Module -Prefix.
# DefaultCommandPrefix = ''

}

tools\LaRGH\LaRGH.psm1
<#
.SYNOPSIS
   Gathers info on the latest release of a project on GitHub
.Description
   GitHub has made it very difficult to scrape their web pages for information
   about a project.  They do have a comprehensive API however.  This script 
   API calls to collect information about the latest release of a project.  In
   particular, it gathers the tag (typically containing the version), the 
   description and the name, date, size, and download URL of all the assets
   for the release.
   The API does have a "speed limit" of 60 queries per hour.  In most, expected 
   use-cases for this script (primarily for Chocolatey Automatic Update packages), 
   users won't come close to that limit.  If the limit is a concern, this 
   script can accept, collect and cache (encrypted), or read a cached API Key 
   ("Personal Access Token":
   https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token)
   to increase the limit to 5000 queries per hour.

.Parameter URL
   (Required) The URL to the GitHub repository in the form: "https://[www.]github.com/<owner>/<repo>
.Parameter AccessToken
   The actual API Key as a plaintext string.  This is not a recommended option,
   but if the API Key is needed and available as plain text this is how to provide
   it.  
   Default Value: <none>
.Parameter Credential
   Script will open a credential request window to collect the API Key in the 
   password field (while ignoring any value provided in the username field).
   The value will be cached as an secure string for future use.
   Default value: $false
.Output
   A custom object containing the release name, release tag (typically, the 
   version), the description and all the asset values of name, date, size, and 
   download URL for the release.  
.Example
   Get-LatestReleaseInfo -URL 'https://github.com/torakiki/pdfsam'
   Information for the latest release of PDFSam will be collected and returned.
   If an encrypted personal access token is found in the user profile, it will 
   be used to authenticate to GitHub.  If one is not found, the information will 
   still be collected unless there have been more than 60 previous queries 
   within the hour.
.Example
   Get-LatestReleaseInfo -URL 'https://github.com/torakiki/pdfsam' -AccessToken <plaintext token>
   The same query and results as above, but the provided access token will be 
   used and will not be stored anywhere.
.Example
   Get-LatestReleaseInfo -URL 'https://github.com/torakiki/pdfsam' -Credential
   This will first request credentials in which the user can provide any username
   and a GitHub Personal Access Token for the password.  The access token will be
   stored encrypted within the user profile, and information for the latest release
   of PDFSam will be collected and returned as above.
.Notes
   Copyright 2022 Teknowledgist

   This script/information is free: you can redistribute it and/or
   modify it under the terms of the GNU General Public License as
   published by the Free Software Foundation, either version 2 of the 
   License, or (at your option) any later version.

   This script is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   The GNU General Public License can be found at <http://www.gnu.org/licenses/>.
#>
Function Get-LatestReleaseOnGitHub {
   [CmdletBinding(DefaultParametersetName='Token')]
   Param(
      [Parameter(Position=0)]   
      [ValidateNotNullOrEmpty()]
      [string]$URL = $null,

      [Parameter(ParameterSetName='Token',Position=1)]    
      [ValidateNotNullOrEmpty()]
      [string]$AccessToken = $null,

      [Parameter(ParameterSetName='Creds',Position=1)]    
      [Switch]$Credential
   )

   if ($URL -match '^https?://(?:www.)?github\.com/([^/]+)/?([^/]+)?(?:/.*)?$') {
      $ownerName = $Matches[1]
      if ($Matches.Count -gt 2) {
         $repositoryName = $Matches[2]
      }
   } else {
      Write-Warning "URL must be in the form 'http[s]://[www.]github.com/<owner>/<repo>'."
      Throw 'URL not in recognized form.'
   }
   $LatestURL = "https://api.github.com/repos/$OwnerName/$RepositoryName/releases/latest"

   $headers = @{
      'Accept' = 'application/vnd.github.v3+json'
      'User-Agent' = 'GetLatest@GitHub'
   }


   $accessTokenFilePath = Join-Path $env:LOCALAPPDATA 'LatestReleaseOnGH\accessToken.txt'
   if ($PSBoundParameters.ContainsKey('Credential')) {
      # Collect the access token in a PSCredential object
      $CredMessage = 'Provide your GitHub API Token in the Password field.  The username field is required but will be ignored.' + 
                  '  ***The API Token will be cached across PowerShell sessions.  If the password is blank, any cached password will be erased. ***'
      $Credential = Get-Credential -Message $CredMessage

      if ([String]::IsNullOrWhiteSpace($Credential.GetNetworkCredential().Password)) {
         # Erase any existing cached token when an empty credential is provided
         Remove-Item $accessTokenFilePath -Force -ErrorAction SilentlyContinue
         Write-Verbose 'Cached Access Token has been erased.'
         $NoTokenMsg = 'Access Token was empty/blank. '
      } else {
         $AccessToken = $Credential.GetNetworkCredential().Password
         Write-Verbose "If the provided Access Token is valid and active, it will be cached."
         $SaveNew = $true
      }
   } else {
      if (-not $AccessToken) {
         If (Test-Path $accessTokenFilePath) {
            $content = Get-Content -Path $accessTokenFilePath -ErrorAction Ignore
            if (-not [String]::IsNullOrEmpty($content)) {
               $secureString = $content | ConvertTo-SecureString
               Write-Verbose "Retrieving Access Token from cache file.  This value can be cleared in the future using the 'Credential' switch and providing an empty password."
               $accessTokenCredential = New-Object System.Management.Automation.PSCredential 'ignored', $secureString
               $AccessToken = $accessTokenCredential.GetNetworkCredential().Password
            } else {
               $NoTokenMsg = "Access Token was empty/blank. "
            }
         } else {
            $NoTokenMsg = "No cached Access Token found. "
         }
      }
   }
   if (-not $AccessToken) {
      Write-Warning "$NoTokenMsg GitHub will limit queries to 60 per hour."
   } else {
      $headers.Authorization = "token $AccessToken"
   }

   $originalSecurityProtocol = [Net.ServicePointManager]::SecurityProtocol
   [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12

   $IWRparams = @{
      Uri = $LatestURL
      Method = 'Get'
      Headers =  $headers
      UseDefaultCredentials = $true
      UseBasicParsing = $true
      TimeoutSec = 0
   }
   Try {
      $result = Invoke-WebRequest @IWRparams
   } catch {
      if ($_.Exception.Response.StatusCode.value__ -eq 404) {
         Write-Warning "The URL, '$URL' does not appear to exist."
      } elseif ($_.Exception.Response.StatusCode.value__ -eq 401) {
         Write-Warning 'The provided access token is not authorized to access this repository.'
      }
      Throw $_.Exception.Message
   } finally {
      [Net.ServicePointManager]::SecurityProtocol = $originalSecurityProtocol
   }

   if ($SaveNew) {
      # This comes after the query because only working tokens should be cached
      $Credential.Password | ConvertFrom-SecureString | Set-Content -Path $accessTokenFilePath -Force
   }

   if ($result.StatusCode -eq 202) {
      Throw 'The server is busy right now.  Please try again later.'
   }

   $finalResult = $result.Content | ConvertFrom-Json

   $defaultDisplaySet = 'Name','Tag','AssetCount','Description'
   #Create the default property display set
   $defaultDisplayPropertySet = New-Object System.Management.Automation.PSPropertySet('DefaultDisplayPropertySet',[string[]]$defaultDisplaySet)
   $PSStandardMembers = [Management.Automation.PSMemberInfo[]]@($defaultDisplayPropertySet)

   $InfoObject = [pscustomobject]@{
      Name          = $finalResult.Name
      Tag           = $finalResult.tag_name | Select-Object -first 1
      Description   = $finalResult.body
      TarballURL    = "https://github.com/$ownerName/$repositoryName/archive/refs/tags/$($finalResult.tag_name | Select-Object -first 1).tar.gz"
      ZipballURL    = "https://github.com/$ownerName/$repositoryName/archive/refs/tags/$($finalResult.tag_name | Select-Object -first 1).zip"
      AssetCount    = $finalResult.assets.count
      Assets        = foreach ($item in $finalResult.assets) {
                     [PSCustomObject]@{
                        FileName         = $item.name
                        CreationDate = get-date $item.created_at
                        Size         = $item.size
                        DownloadURL  = $item.Browser_download_url
                     }
               }
   }
   $InfoObject.PSObject.TypeNames.Insert(0,'Release.Information')
   $InfoObject | Add-Member MemberSet PSStandardMembers $PSStandardMembers

   $InfoObject
}

Set-Alias Get-LaRGH Get-LatestReleaseOnGitHub

Export-ModuleMember -Function Get-LatestReleaseOnGitHub -Alias Get-LaRGH

Log in or click on link to see number of positives.

In cases where actual malware is found, the packages are subject to removal. Software sometimes has false positives. Moderators do not necessarily validate the safety of the underlying software, only that a package retrieves software from the official distribution point and/or validate embedded software against official distribution point (where distribution rights allow redistribution).

Chocolatey Pro provides runtime protection from possible malware.

Add to Builder Version Downloads Last Updated Status

CHANGE LOG:

  • 0.1 - initial release

This package has no dependencies.

Discussion for the Latest Release on GitHub Helper Package

Ground Rules:

  • This discussion is only about Latest Release on GitHub Helper and the Latest Release on GitHub Helper package. If you have feedback for Chocolatey, please contact the Google Group.
  • This discussion will carry over multiple versions. If you have a comment about a particular version, please note that in your comments.
  • The maintainers of this Chocolatey Package will be notified about new comments that are posted to this Disqus thread, however, it is NOT a guarantee that you will get a response. If you do not hear back from the maintainers after posting a message below, please follow up by using the link on the left side of this page or follow this link to contact maintainers. If you still hear nothing back, please follow the package triage process.
  • Tell us what you love about the package or Latest Release on GitHub Helper, or tell us what needs improvement.
  • Share your experiences with the package, or extra configuration or gotchas that you've found.
  • If you use a url, the comment will be flagged for moderation until you've been whitelisted. Disqus moderated comments are approved on a weekly schedule if not sooner. It could take between 1-5 days for your comment to show up.
comments powered by Disqus