Skip to content

Commit 3ec5f2b

Browse files
add logic with generation hash
1 parent ba0b46a commit 3ec5f2b

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

Diff for: .github/workflows/build-python-packages.yml

+15-2
Original file line numberDiff line numberDiff line change
@@ -183,21 +183,34 @@ jobs:
183183
body: |
184184
Python ${{ env.VERSION }}
185185
186+
- name: Generate hash for packages
187+
run: |
188+
$childItems = Get-Childitem -Path '.'
189+
$childItems | Foreach-Object {
190+
$packageObj = Get-Childitem -Path $_.FullName | Select-Object -First 1
191+
Write-Host "Package: $($packageObj.Name)"
192+
$actualHash = (Get-FileHash -Path $packageObj.FullName -Algorithm sha256).Hash
193+
$hashString = "$actualHash $($packageObj.Name)"
194+
Write-Host "$hashString"
195+
Add-Content -Path ./hashes.sha256 -Value "$hashString"
196+
}
197+
186198
- name: Upload release assets
187199
uses: actions/github-script@v6
188200
with:
189201
github-token: ${{ secrets.GITHUB_TOKEN }}
190202
script: |
191203
const fs = require('fs');
192204
for (let artifactDir of fs.readdirSync('.')) {
193-
let artifactName = fs.readdirSync(`${artifactDir}`)[0];
205+
let artifactName = fs.lstatSync(artifactDir).isDirectory() ? fs.readdirSync(`${artifactDir}`)[0] : artifactDir;
206+
194207
console.log(`Upload ${artifactName} asset`);
195208
github.rest.repos.uploadReleaseAsset({
196209
owner: context.repo.owner,
197210
repo: context.repo.repo,
198211
release_id: ${{ steps.create_release.outputs.id }},
199212
name: artifactName,
200-
data: fs.readFileSync(`./${artifactDir}/${artifactName}`)
213+
data: fs.lstatSync(artifactDir).isDirectory() ? fs.readFileSync(`./${artifactDir}/${artifactName}`) : fs.readFileSync(`./${artifactName}`).toString()
201214
});
202215
}
203216

0 commit comments

Comments
 (0)