Skip to content

Commit

Permalink
feat: add checksum
Browse files Browse the repository at this point in the history
  • Loading branch information
Shurtu-gal committed Dec 22, 2023
1 parent 3ae826f commit 5e63bdd
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/deploy/chocolatey/asyncapi-cli.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<metadata>
<id>asyncapi</id>
<version>{{version}}</version>
<packageSourceUrl>https://github.com/asyncapi/cli/releases</packageSourceUrl>
<packageSourceUrl>https://github.com/asyncapi/cli/releases/v{{version}}</packageSourceUrl>
<owners>AsyncAPI_Initiative</owners>

<!-- == SOFTWARE SPECIFIC SECTION == -->
Expand Down
6 changes: 5 additions & 1 deletion .github/workflows/deploy/chocolatey/replace.ps1
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
param (
[Parameter(Mandatory=$true)]
[string]$version
[string]$version,
[string]$checksum,
[string]$checksum64
)

$filePaths = @(
Expand All @@ -11,5 +13,7 @@ $filePaths = @(
foreach ($filePath in $filePaths) {
$fileContents = Get-Content $filePath
$fileContents = $fileContents -replace '{{version}}', $version
$fileContents = $fileContents -replace '{{checksum}}', $checksum
$fileContents = $fileContents -replace '{{checksum64}}', $checksum64
Set-Content $filePath $fileContents
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,10 @@ $packageArgs = @{

softwareName = 'asyncapi-cli*'

# TODO :- Change the checksum and checksumType to match the checksums for the above file.
# checksum = ''
# checksumType = 'sha256' #default is md5, can also be sha1, sha256 or sha512
# checksum64 = ''
# checksumType64= 'sha256' #default is checksumType
checksum = '{{checksum}}'
checksumType = 'sha256' #default is md5, can also be sha1, sha256 or sha512
checksum64 = '{{checksum64}}'
checksumType64= 'sha256' #default is checksumType

validExitCodes= @(0, 3010, 1641)
silentArgs = '/S' # NSIS
Expand Down
23 changes: 22 additions & 1 deletion .github/workflows/release-chocolatey.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Set Version
id: release_version
run: |
Expand All @@ -29,16 +30,36 @@ jobs:
}
echo "Setting version to $version"
echo "version=$version" >> $env:GITHUB_OUTPUT
- name: Download release
run: |
echo "Downloading release assets for version ${{ steps.release_version.outputs.version }}"
mkdir -p ./dist/win32
curl -L "https://github.com/asyncapi/cli/releases/download/v${{ steps.release_version.outputs.version }}/asyncapi.x64.exe" -o "./dist/win32/asyncapi.x64.exe"
curl -L "https://github.com/asyncapi/cli/releases/download/v${{ steps.release_version.outputs.version }}/asyncapi.x86.exe" -o "./dist/win32/asyncapi.x86.exe"
- name: Get Checksum of the release
id: release_checksum
run: |
$checksum = (Get-FileHash -Path "./dist/win32/asyncapi.x86.exe" -Algorithm SHA256).Hash
$checksum64 = (Get-FileHash -Path "./dist/win32/asyncapi.x64.exe" -Algorithm SHA256).Hash
echo "Setting checksum to $checksum"
echo "checksum=$checksum" >> $env:GITHUB_OUTPUT
echo "Setting checksum64 to $checksum64"
echo "checksum64=$checksum64" >> $env:GITHUB_OUTPUT
- name: Make nuspec from the template
run: |
cd ./.github/workflows/deploy/chocolatey
pwsh -File ./replace.ps1 -version ${{ steps.release_version.outputs.version }}
pwsh -File ./replace.ps1 -version ${{ steps.release_version.outputs.version }} -checksum ${{ steps.release_checksum.outputs.checksum }} -checksum64 ${{ steps.release_checksum.outputs.checksum64 }}
- name: Run Chocolatey Pack
run: |
cd ./.github/workflows/deploy/chocolatey
choco pack ./asyncapi-cli.nuspec
choco apikey add --source "'https://push.chocolatey.org/'" --key ${{ secrets.CHOCOLATEY_API_KEY }}
choco push ./asyncapi.${{ steps.release_version.outputs.version }}.nupkg --source "'https://push.chocolatey.org/'"
- if: failure() # Only, on failure, send a message on the 94_bot-failing-ci slack channel
name: Report workflow run status to Slack
uses: 8398a7/action-slack@fbd6aa58ba854a740e11a35d0df80cb5d12101d8 #using https://github.com/8398a7/action-slack/releases/tag/v3.15.1
Expand Down

0 comments on commit 5e63bdd

Please sign in to comment.