1111 description : ' The name of the package uploaded as an artifact.'
1212 required : true
1313 type : string
14+ artifact-digest :
15+ description : ' SHA-256 digest of an Artifact. https://github.com/actions/upload-artifact?tab=readme-ov-file#outputs'
16+ required : true
17+ type : string
1418 dry-run :
1519 description : ' true = dry-run: The upload will not actually be performed.'
1620 required : false
@@ -30,13 +34,43 @@ jobs:
3034 name : ${{ inputs.artifact-package-name }}
3135 path : ./artifacts
3236
37+ - name : Define Path for Artifact File
38+ id : artifact-path
39+ run : |
40+ file="${{ inputs.artifact-package-name }}"
41+ echo "path=./artifacts/$file" >> "$GITHUB_OUTPUT"
42+
43+ - name : Verify Artifact Exists
44+ run : |
45+ artifact_file="${{ steps.artifact-path.outputs.path }}"
46+ if [ ! -f "$artifact_file" ]; then
47+ echo "::error file=$artifact_file::Artifact file not found!"
48+ exit 1
49+ fi
50+ echo "Artifact exists: $artifact_file"
51+
52+ - name : Verify Artifact Integrity
53+ run : |
54+ artifact_file="${{ steps.artifact-path.outputs.path }}"
55+ calculated_hash=$(sha256sum "$artifact_file" | awk '{ print $1 }')
56+ uploaded_hash="${{ inputs.artifact_digest }}"
57+
58+ echo "Uploaded hash: $uploaded_hash"
59+ echo "Calculated hash: $calculated_hash"
60+
61+ if [ "$calculated_hash" != "$uploaded_hash" ]; then
62+ echo "::error::Artifact integrity check failed! Hash mismatch."
63+ exit 1
64+ fi
65+ echo "Artifact Verified: Integrity check passed. Hash matches."
66+
3367 - name : Upload Package
3468 if : ${{ !inputs.dry-run }}
3569 env :
3670 GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
3771 run : |
3872 file="${{ inputs.artifact-package-name }}"
39- file_path="./artifacts/$file "
73+ file_path="${{ steps.artifact-path.outputs.path }} "
4074 tag="${{ inputs.release-tag }}"
4175 gh release upload "$tag" "$file_path"
4276 echo "::notice title=Uploaded asset::$file"
4579 if : ${{ inputs.dry-run }}
4680 run : |
4781 file="${{ inputs.artifact-package-name }}"
48- file_path="./artifacts/$file "
82+ file_path="${{ steps.artifact-path.outputs.path }} "
4983 tag="${{ inputs.release-tag }}"
5084 echo "::notice title=Dry Run::Simulating upload of '$file_path' to release tag '$tag'."
0 commit comments