Add logic to generate hash file (#65)

pull/66/head
Dmitry Shibanov 1 year ago committed by GitHub
parent b964a9871b
commit 6fbb1f0f20
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -163,15 +163,26 @@ jobs:
body: | body: |
${{ steps.generate-release-body.outputs.RELEASE_BODY }} ${{ steps.generate-release-body.outputs.RELEASE_BODY }}
- name: Generate hash for packages
run: |
$childItems = Get-Childitem -Path '.'
$childItems | Foreach-Object {
$packageObj = Get-Childitem -Path $_.FullName | Select-Object -First 1
Write-Host "Package: $($packageObj.Name)"
$actualHash = (Get-FileHash -Path $packageObj.FullName -Algorithm sha256).Hash
$hashString = "$actualHash $($packageObj.Name)"
Write-Host "$hashString"
Add-Content -Path ./hashes.sha256 -Value "$hashString"
}
- name: Upload release assets - name: Upload release assets
uses: actions/github-script@v6 uses: actions/github-script@v6
with: with:
github-token: ${{ secrets.GITHUB_TOKEN }} github-token: ${{ secrets.GITHUB_TOKEN }}
script: | script: |
const fs = require('fs'); const fs = require('fs');
for (let artifactDir of fs.readdirSync('.')) { for (let artifactDir of fs.readdirSync('.')) {
let artifactName = fs.readdirSync(`${artifactDir}`)[0]; let artifactName = fs.lstatSync(artifactDir).isDirectory() ? fs.readdirSync(`${artifactDir}`)[0] : artifactDir;
console.log(`Upload ${artifactName} asset`); console.log(`Upload ${artifactName} asset`);
github.rest.repos.uploadReleaseAsset({ github.rest.repos.uploadReleaseAsset({
@ -179,7 +190,7 @@ jobs:
repo: context.repo.repo, repo: context.repo.repo,
release_id: ${{ steps.create_release.outputs.id }}, release_id: ${{ steps.create_release.outputs.id }},
name: artifactName, name: artifactName,
data: fs.readFileSync(`./${artifactDir}/${artifactName}`) data: fs.lstatSync(artifactDir).isDirectory() ? fs.readFileSync(`./${artifactDir}/${artifactName}`) : fs.readFileSync(`./${artifactName}`).toString()
}); });
} }

@ -77,6 +77,7 @@ Describe "Build-VersionsManifest" {
$assets = @( $assets = @(
@{ name = "python-3.8.3-linux-16.04-x64.tar.gz"; browser_download_url = "fake_url"; } @{ name = "python-3.8.3-linux-16.04-x64.tar.gz"; browser_download_url = "fake_url"; }
@{ name = "python-3.8.3-linux-18.04-x64.tar.gz"; browser_download_url = "fake_url"; } @{ name = "python-3.8.3-linux-18.04-x64.tar.gz"; browser_download_url = "fake_url"; }
@{ name = "hashes.sha256"; browser_download_url = "fake_url"; }
) )
$configuration = @{ $configuration = @{
regex = "python-\d+\.\d+\.\d+-(\w+)-([\w\.]+)?-?(x\d+)"; regex = "python-\d+\.\d+\.\d+-(\w+)-([\w\.]+)?-?(x\d+)";

@ -67,7 +67,7 @@ function Build-VersionsManifest {
$ltsStatus = Get-VersionLtsStatus -Version $versionKey -LtsRules $ltsRules $ltsStatus = Get-VersionLtsStatus -Version $versionKey -LtsRules $ltsRules
$stable = $version.PreReleaseLabel ? $false : $true $stable = $version.PreReleaseLabel ? $false : $true
[array]$releaseAssets = $release.assets | ForEach-Object { New-AssetItem -ReleaseAsset $_ -Configuration $Configuration } [array]$releaseAssets = $release.assets | Where { $_.Name -ne "hashes.sha256" } | ForEach-Object { New-AssetItem -ReleaseAsset $_ -Configuration $Configuration }
$versionHash = [PSCustomObject]@{} $versionHash = [PSCustomObject]@{}
$versionHash | Add-Member -Name "version" -Value $versionKey -MemberType NoteProperty $versionHash | Add-Member -Name "version" -Value $versionKey -MemberType NoteProperty

Loading…
Cancel
Save