Skip to content

Commit

Permalink
migrate cross-platform SHA to shell script
Browse files Browse the repository at this point in the history
  • Loading branch information
artoonie committed Jan 26, 2024
1 parent 5d63228 commit 3ac98a1
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 33 deletions.
5 changes: 2 additions & 3 deletions .github/actions/gradle-and-sha/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,5 @@ runs:
mv ${{ inputs.intermediate-filepath }} ${{ inputs.final-filepath }}
- name: "Generate SHA512"
uses: ./.github/actions/sha
with:
filepath: ${{ inputs.final-filepath }}
shell: bash
run: ./.github/workflows/sha.sh ${{ runner.os }} ${{ inputs.final-filepath }} 512
24 changes: 0 additions & 24 deletions .github/actions/sha/action.yml

This file was deleted.

6 changes: 4 additions & 2 deletions .github/workflows/generate-dependency-hashes.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
# Including their actual SHA 256, and where to verify that online
set -e

parentPath=$( cd "$(dirname "${BASH_SOURCE[0]}")" ; pwd -P )

echo "Filename, SHA-1 Checksum, SHA-256 Checksum, Maven Dependency URL, Direct URL to SHA-1, Direct URL to SHA-256"
cd ~/.gradle/caches/modules-2/files-2.1
for filename in $(find * -type f); do
Expand All @@ -21,7 +23,7 @@ for filename in $(find * -type f); do
directUrl="https://repo1.maven.org/maven2/$slashSeparatedOrg/$dependencyName/$version/$dependencyName-$version.$ext"
directUrlToSha1="$directUrl.sha1"
directUrlToSha256="$directUrl.sha256"
sha1=$(shasum -a 1 $filename | cut -f1 -d" ")
sha256=$(shasum -a 256 $filename | cut -f1 -d" ")
sha1=$($parentPath/sha.sh $filename 1)
sha256=$($parentPath/sha.sh $filename 256)
echo "$filename,$sha1,$sha256,$friendlyurl,$directUrlToSha1,$directUrlToSha256"
done
5 changes: 2 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,8 @@ jobs:
zipFilename: ${{steps.cachefn.outputs.FILEPATH}}

- name: "Generate SHA512 for plugins cache"
uses: ./.github/actions/sha
with:
filepath: ${{steps.cachefn.outputs.FILEPATH}}
shell: bash
run: ./.github/workflows/sha.sh ${{steps.cachefn.outputs.FILEPATH}} ${{ runner.os }} 512

- name: "Prepare keychain"
if: matrix.os == 'macOS-latest'
Expand Down
18 changes: 18 additions & 0 deletions .github/workflows/sha.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/bash
# Cross-platform SHA generation
# Usage: <filename> <OS: Windows, MacOS, or Linux> <sha version: 1, 256, or 512>

set -e

filename=$1
os=$2
a=$3


if [ $os == 'Windows' ]; then
echo $(certutil -hashfile $filename SHA$a | sed -n 2p)
elif [ $os == 'Linux' ]; then
echo $(sha${a}sum $filename | cut -f1 -d" ")
else
echo $(shasum -a $a $filename | cut -f1 -d" ")
fi
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ On Linux, you may install the .deb file, then run `/opt/rcv/bin/RCTab` to launch
1. Download gradle from https://gradle.org/releases/ and place it in your path
2. Download and extract the source code from [releases page](https://github.com/BrightSpots/rcv/releases)
3. Download the appropriate cache files for your OS: cache.[OS].zip
4. Stop the gradle daemon with `./gradlew --stop`
4. Stop the gradle daemon with `gradle --stop`
5. Delete the directory ~/.gradle/caches if it exists
6. Extract cache.[OS].zip to ~/.gradle/caches so that the "caches" directory is in ~/.gradle
7. In the extracted directory, you may manually verify each dependency using checksums.csv in accordance with your own policies
Expand Down

0 comments on commit 3ac98a1

Please sign in to comment.