Skip to content

Commit

Permalink
Try psutil to create checksum on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
autarch committed Sep 14, 2024
1 parent b067a2a commit e40479c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
12 changes: 10 additions & 2 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -97,15 +97,23 @@ runs:
- name: Generate SHA-256 checksum file (*nix)
shell: bash
run: |
set -e
set -x
shasum -a 256 \
"${{ steps.package-archive.outputs.archive-basename }}" \
> "${{ steps.package-archive.outputs.archive-basename }}.sha256"
if: runner.os != 'Windows'
- name: Install psutils on Windows
shell: powershell
run: choco install --ignore-checksums psutils
if: runner.os == 'Windows'
- name: Generate SHA-256 checksum file (Windows)
shell: powershell
run: |
$hash = $(CertUtil -hashfile ${{ steps.package-archive.outputs.archive-basename }} SHA256)[1]
echo "${{ steps.package-archive.outputs.archive-basename }} $hash" > "${{ steps.package-archive.outputs.archive-basename }}.sha256"
shasum -a 256 `
"${{ steps.package-archive.outputs.archive-basename }}" `
> "${{ steps.package-archive.outputs.archive-basename }}.sha256"
if: runner.os == 'Windows'
- name: Publish release artifact for run
id: publish-release-artifact
Expand Down
4 changes: 1 addition & 3 deletions tests/check-release.pl
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,7 @@ sub main {
my ( $checksum, $filename ) = $sha256_contents =~ /^(\S+) (\S+)$/;
is( $filename, $archive_file, "filename in checksum file matches archive filename" )
or diag($sha256_contents);
my $shasum
= $^O eq 'MSWin32' ? 'c/programdata/chocolatey/lib/psutils/tools/shasum.ps1' : 'shasum';
my $output = capturex( $shasum, '--algorithm', '256', '--check', $checksum_file );
my $output = capturex( 'shasum', '--algorithm', '256', '--check', $checksum_file );
like( $output, qr/\Q$archive_file\E: OK/, 'sha256sum reports checksum is OK' );

if ( $archive_file =~ /\.zip$/ ) {
Expand Down

0 comments on commit e40479c

Please sign in to comment.