@@ -2,7 +2,7 @@ name: Chocolatey Deploy
22
33# This GH action will push a okta-aws-cli build to chocolatey.org when a
44# okta-aws-cli GH release is completed.
5- #
5+ #
66# inspired by https://github.com/rcmaehl/MSEdgeRedirect thank you rcmaehl 🙏🙏🙏
77
88on :
@@ -18,52 +18,74 @@ jobs:
1818 chocolatey :
1919 runs-on : windows-latest
2020 steps :
21- -
22- name : Checkout
21+ - name : Checkout
2322 uses : actions/checkout@v4
24- -
25- name : Unshallow
23+
24+ - name : Unshallow
2625 run : git fetch --prune --unshallow
27- -
28- name : Get latest release tag
26+
27+ - name : Get latest release tag
2928 uses : oprypin/find-latest-tag@v1
3029 with :
3130 repository : ${{ github.repository }}
3231 releases-only : true
3332 id : latesttag
34- -
35- name : Set Version
33+
34+ - name : Set Version
3635 id : version
3736 run : |
3837 version=$(echo "${{ steps.latesttag.outputs.tag }}" | grep -oE "[[:digit:]]{1,}\.[[:digit:]]{1,}\.[[:digit:]]{1,}")
3938 echo "nuget=$version" >> $GITHUB_OUTPUT
4039 sed -i "s/{VERSION}/${version}/g" "nuspec/chocolatey/okta-aws-cli.nuspec"
41- -
42- name : Set Checksum
40+
41+ - name : Download and Embed Binary
4342 run : |
4443 filename="okta-aws-cli_${{ steps.version.outputs.nuget }}_windows_386.zip"
4544 url="https://github.com/${{ github.repository }}/releases/download/${{ steps.latesttag.outputs.tag }}/${filename}"
46- sed -i "s#{ZIPURL}#${url}#g" "nuspec/chocolatey/tools/chocolateyinstall.ps1"
47- curl -sSL "${url}" -o "nuspec/chocolatey/${filename}"
48- sha256=$(cat "nuspec/chocolatey/${filename}" | sha256sum -)
49- sed -i "s/{SHA256CHECKSUM}/${sha256:0:64}/g" "nuspec/chocolatey/tools/chocolateyinstall.ps1"
50- -
51- name : Choco Downgrade
45+
46+ # Retry download with exponential backoff to handle release asset propagation delay
47+ download_success=false
48+ for i in 1 2 3 4 5; do
49+ echo "Download attempt $i..."
50+ if curl -sSL --fail "${url}" -o "nuspec/chocolatey/tools/okta-aws-cli.zip"; then
51+ download_success=true
52+ break
53+ fi
54+ echo "Download failed, waiting $((i * 30)) seconds before retry..."
55+ sleep $((i * 30))
56+ done
57+
58+ if [ "$download_success" != "true" ]; then
59+ echo "ERROR: Failed to download release asset after 5 attempts"
60+ exit 1
61+ fi
62+
63+ # Verify the downloaded file is a valid zip archive (zip files start with "PK")
64+ if [ "$(head -c 2 "nuspec/chocolatey/tools/okta-aws-cli.zip")" != "PK" ]; then
65+ echo "ERROR: Downloaded file is not a valid zip archive"
66+ exit 1
67+ fi
68+
69+ echo "Successfully downloaded and verified binary"
70+ ls -la nuspec/chocolatey/tools/
71+
72+ - name : Choco Downgrade
5273 uses : crazy-max/ghaction-chocolatey@v3
5374 with :
5475 args : install chocolatey --version=1.2.1 --allow-downgrade -y -r --no-progress
55- -
56- name : Pack Release
76+
77+ - name : Pack Release
5778 uses : crazy-max/ghaction-chocolatey@v3
5879 with :
5980 args : pack nuspec/chocolatey/okta-aws-cli.nuspec --outputdirectory nuspec/chocolatey
60- -
61- name : Choco Upgrade
81+
82+ - name : Choco Upgrade
6283 uses : crazy-max/ghaction-chocolatey@v3
6384 with :
6485 args : upgrade chocolatey
65- -
66- name : Upload Release
86+
87+ - name : Upload Release
6788 uses : crazy-max/ghaction-chocolatey@v3
6889 with :
69- args : push nuspec/chocolatey/okta-aws-cli.${{ steps.version.outputs.nuget }}.nupkg -s https://push.chocolatey.org/ -k ${{ secrets.CHOCO_API_KEY }}
90+ args : push nuspec/chocolatey/okta-aws-cli.${{ steps.version.outputs.nuget }}.nupkg -s https://push.chocolatey.org/ -k ${{ secrets.CHOCO_API_KEY }}
91+
0 commit comments