Skip to content

Commit

Permalink
When a GH publish completes publish the same version of okta-aws-cli
Browse files Browse the repository at this point in the history
…to Chocolatey.org

Closes #186
  • Loading branch information
monde committed Jul 3, 2024
1 parent 2063ec9 commit 5bfd2bb
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 4 deletions.
65 changes: 65 additions & 0 deletions .github/workflows/chocolatey.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: Chocolatey Deploy

# This GH action will push a okta-aws-cli build to chocolatey.org when a
# okta-aws-cli GH release is completed.
#
# inspired by https://github.com/rcmaehl/MSEdgeRedirect thank you rcmaehl 🙏🙏🙏

on:
release:
types:
- published
jobs:
chocolatey:
runs-on: windows-latest
steps:
-
name: Checkout
uses: actions/checkout@v4
-
name: Unshallow
run: git fetch --prune --unshallow
-
name: Get latest release tag
uses: oprypin/find-latest-tag@v1
with:
repository: ${{ github.repository }}
releases-only: true
id: latesttag
-
name: Set Checksum
run: |
shortVersion=$(echo "${{ steps.latesttag.outputs.tag }}" | grep -oE '\d{1,2}\.\d{1,2}\.\d{1,2}')
filename="okta-aws-cli_${shortVersion}_windows_386.zip"
url="https://github.com/${{ github.repository }}/releases/download/${{ steps.latesttag.outputs.tag }}/${filename}"
sed -i "s#{ZIPURL}#${url}#g" "nuspec/chocolatey/tools/chocolateyinstall.ps1"
curl -sSL "${url}" -o "nuspec/chocolatey/${filename}"
sha256=$(cat "nuspec/chocolatey/${filename}" | sha256sum -)
sed -i "s/{SHA256CHECKSUM}/${sha256:0:64}/g" "nuspec/chocolatey/tools/chocolateyinstall.ps1"
-
name: Set Version
id: version
run: |
version=${{ steps.latesttag.outputs.tag }}
echo "nuget=$version" >> $GITHUB_OUTPUT
sed -i "s/{VERSION}/${version}/g" "nuspec/chocolatey/okta-aws-cli.nuspec"
-
name: Choco Downgrade
uses: crazy-max/ghaction-chocolatey@v3
with:
args: install chocolatey --version=1.2.1 --allow-downgrade -y -r --no-progress
-
name: Pack Release
uses: crazy-max/ghaction-chocolatey@v3
with:
args: pack nuspec/chocolatey/okta-aws-cli.nuspec --outputdirectory nuspec/chocolatey
-
name: Choco Upgrade
uses: crazy-max/ghaction-chocolatey@v3
with:
args: upgrade chocolatey
-
name: Upload Release
uses: crazy-max/ghaction-chocolatey@v3
with:
args: push nuspec/chocolatey/okta-aws-cli.${{ steps.version.outputs.nuget }}.nupkg -s https://push.chocolatey.org/ -k ${{ secrets.CHOCO_KEY }}
2 changes: 1 addition & 1 deletion nuspec/chocolatey/okta-aws-cli.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2015/06/nuspec.xsd">
<metadata>
<id>okta-aws-cli</id>
<version>2.0.1</version>
<version>{VERSION}</version>
<owners>Okta, Inc.</owners>
<title>Okta AWS CLI (Install)</title>
<authors>Okta</authors>
Expand Down
5 changes: 2 additions & 3 deletions nuspec/chocolatey/tools/chocolateyinstall.ps1
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@

$ErrorActionPreference = 'Stop'
$toolsDir = "$(Split-Path -parent $MyInvocation.MyCommand.Definition)"
$url = 'https://github.com/okta/okta-aws-cli/releases/download/v2.0.1/okta-aws-cli_2.0.1_windows_386.zip'

$packageArgs = @{
packageName = $env:ChocolateyPackageName
unzipLocation = $toolsDir
url = $url
checksum = 'F05862D42BF14133EFA88C9F77C0AB942858CA0FFDE980D0615395E8E48FD4D6'
url = '{ZIPURL}'
checksum = '{SHA256CHECKSUM}'
checksumType = 'sha256'
}

Expand Down

0 comments on commit 5bfd2bb

Please sign in to comment.