mirror of
https://github.com/pezkuwichain/revive.git
synced 2026-06-14 01:51:03 +00:00
Remove path from release json and add sha256 (#280)
PR addresses https://github.com/paritytech/revive/issues/162#issuecomment-2783173447
This commit is contained in:
committed by
GitHub
parent
0dafc779ce
commit
9f5443b6d6
@@ -2,7 +2,6 @@ import os
|
|||||||
import sys
|
import sys
|
||||||
import json
|
import json
|
||||||
import requests
|
import requests
|
||||||
from datetime import datetime
|
|
||||||
|
|
||||||
def validate_github_token():
|
def validate_github_token():
|
||||||
"""Validate that GITHUB_TOKEN environment variable is set."""
|
"""Validate that GITHUB_TOKEN environment variable is set."""
|
||||||
@@ -27,26 +26,70 @@ def fetch_release_data(repo, tag):
|
|||||||
print(f"Error fetching release data: {e}")
|
print(f"Error fetching release data: {e}")
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
|
def fetch_checksum_file(release_data):
|
||||||
|
"""
|
||||||
|
Fetch the checksum.txt file from the release assets
|
||||||
|
and parse it into a dictionary mapping file names to their SHA256 checksums.
|
||||||
|
"""
|
||||||
|
checksums = {}
|
||||||
|
|
||||||
|
# Find the checksum.txt asset URL
|
||||||
|
checksum_asset = None
|
||||||
|
for asset in release_data['assets']:
|
||||||
|
if asset['name'] == 'checksums.txt':
|
||||||
|
checksum_asset = asset
|
||||||
|
break
|
||||||
|
|
||||||
|
if not checksum_asset:
|
||||||
|
print("Warning: checksum.txt file not found in release assets.")
|
||||||
|
return checksums
|
||||||
|
|
||||||
|
# Download the checksum file
|
||||||
|
headers = {
|
||||||
|
'Authorization': f"Bearer {os.environ['GITHUB_TOKEN']}",
|
||||||
|
'Accept': 'application/octet-stream'
|
||||||
|
}
|
||||||
|
|
||||||
|
try:
|
||||||
|
response = requests.get(checksum_asset['browser_download_url'], headers=headers)
|
||||||
|
response.raise_for_status()
|
||||||
|
|
||||||
|
# Parse checksum file
|
||||||
|
for line in response.text.splitlines():
|
||||||
|
if line.strip():
|
||||||
|
checksum, filename = line.strip().split(None, 1)
|
||||||
|
checksums[filename] = checksum
|
||||||
|
|
||||||
|
return checksums
|
||||||
|
except requests.RequestException as e:
|
||||||
|
print(f"Error fetching checksum file: {e}")
|
||||||
|
return checksums
|
||||||
|
except Exception as e:
|
||||||
|
print(f"Error parsing checksum file: {e}")
|
||||||
|
return checksums
|
||||||
|
|
||||||
def extract_build_hash(target_commitish):
|
def extract_build_hash(target_commitish):
|
||||||
"""Extract the first 8 characters of the commit hash."""
|
"""Extract the first 8 characters of the commit hash."""
|
||||||
return f"commit.{target_commitish[:8]}"
|
return f"commit.{target_commitish[:8]}"
|
||||||
|
|
||||||
def generate_asset_json(release_data, asset):
|
def generate_asset_json(release_data, asset, checksums):
|
||||||
"""Generate JSON for a specific asset."""
|
"""Generate JSON for a specific asset."""
|
||||||
version = release_data['tag_name'].lstrip('v')
|
version = release_data['tag_name'].lstrip('v')
|
||||||
build = extract_build_hash(release_data['target_commitish'])
|
build = extract_build_hash(release_data['target_commitish'])
|
||||||
long_version = f"{version}+{build}"
|
long_version = f"{version}+{build}"
|
||||||
path = f"{asset['name']}+{long_version}"
|
|
||||||
|
# Get SHA256 checksum if available
|
||||||
|
sha256 = checksums.get(asset['name'], "")
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"path": path,
|
|
||||||
"name": asset['name'],
|
"name": asset['name'],
|
||||||
"version": version,
|
"version": version,
|
||||||
"build": build,
|
"build": build,
|
||||||
"longVersion": long_version,
|
"longVersion": long_version,
|
||||||
"url": asset['browser_download_url'],
|
"url": asset['browser_download_url'],
|
||||||
"firstSolcVersion": os.environ["FIRST_SOLC_VERSION"],
|
"sha256": sha256,
|
||||||
"lastSolcVersion": os.environ["LAST_SOLC_VERSION"]
|
"firstSolcVersion": os.environ.get("FIRST_SOLC_VERSION", ""),
|
||||||
|
"lastSolcVersion": os.environ.get("LAST_SOLC_VERSION", "")
|
||||||
}
|
}
|
||||||
|
|
||||||
def save_platform_json(platform_folder, asset_json, tag):
|
def save_platform_json(platform_folder, asset_json, tag):
|
||||||
@@ -69,14 +112,14 @@ def save_platform_json(platform_folder, asset_json, tag):
|
|||||||
# Remove any existing entry with the same path
|
# Remove any existing entry with the same path
|
||||||
list_data['builds'] = [
|
list_data['builds'] = [
|
||||||
build for build in list_data['builds']
|
build for build in list_data['builds']
|
||||||
if build['path'] != asset_json['path']
|
if build['version'] != asset_json['version']
|
||||||
]
|
]
|
||||||
# Add the new build
|
# Add the new build
|
||||||
list_data['builds'].append(asset_json)
|
list_data['builds'].append(asset_json)
|
||||||
|
|
||||||
# Update releases
|
# Update releases
|
||||||
version = asset_json['version']
|
version = asset_json['version']
|
||||||
list_data['releases'][version] = asset_json['path']
|
list_data['releases'][version] = f"{asset_json['name']}+{asset_json['longVersion']}"
|
||||||
|
|
||||||
# Update latest release
|
# Update latest release
|
||||||
list_data['latestRelease'] = version
|
list_data['latestRelease'] = version
|
||||||
@@ -98,6 +141,9 @@ def main():
|
|||||||
# Fetch release data
|
# Fetch release data
|
||||||
release_data = fetch_release_data(repo, tag)
|
release_data = fetch_release_data(repo, tag)
|
||||||
|
|
||||||
|
# Fetch checksums
|
||||||
|
checksums = fetch_checksum_file(release_data)
|
||||||
|
|
||||||
# Mapping of asset names to platform folders
|
# Mapping of asset names to platform folders
|
||||||
platform_mapping = {
|
platform_mapping = {
|
||||||
'resolc-x86_64-unknown-linux-musl': 'linux',
|
'resolc-x86_64-unknown-linux-musl': 'linux',
|
||||||
@@ -111,7 +157,7 @@ def main():
|
|||||||
platform_name = platform_mapping.get(asset['name'])
|
platform_name = platform_mapping.get(asset['name'])
|
||||||
if platform_name:
|
if platform_name:
|
||||||
platform_folder = os.path.join(platform_name)
|
platform_folder = os.path.join(platform_name)
|
||||||
asset_json = generate_asset_json(release_data, asset)
|
asset_json = generate_asset_json(release_data, asset, checksums)
|
||||||
save_platform_json(platform_folder, asset_json, tag)
|
save_platform_json(platform_folder, asset_json, tag)
|
||||||
print(f"Processed {asset['name']} for {platform_name}")
|
print(f"Processed {asset['name']} for {platform_name}")
|
||||||
|
|
||||||
|
|||||||
@@ -249,6 +249,15 @@ jobs:
|
|||||||
chmod +x resolc-x86_64-unknown-linux-musl
|
chmod +x resolc-x86_64-unknown-linux-musl
|
||||||
chmod +x resolc-universal-apple-darwin
|
chmod +x resolc-universal-apple-darwin
|
||||||
|
|
||||||
|
- name: Create sha-256 checksum
|
||||||
|
run: |
|
||||||
|
shasum -a 256 resolc-x86_64-unknown-linux-musl > checksums.txt
|
||||||
|
shasum -a 256 resolc-universal-apple-darwin >> checksums.txt
|
||||||
|
shasum -a 256 resolc-x86_64-pc-windows-msvc.exe >> checksums.txt
|
||||||
|
shasum -a 256 resolc.js >> checksums.txt
|
||||||
|
shasum -a 256 resolc.wasm >> checksums.txt
|
||||||
|
shasum -a 256 resolc_web.js >> checksums.txt
|
||||||
|
|
||||||
- uses: actions/create-github-app-token@v1
|
- uses: actions/create-github-app-token@v1
|
||||||
id: app-token
|
id: app-token
|
||||||
with:
|
with:
|
||||||
@@ -276,3 +285,4 @@ jobs:
|
|||||||
resolc.js
|
resolc.js
|
||||||
resolc.wasm
|
resolc.wasm
|
||||||
resolc_web.js
|
resolc_web.js
|
||||||
|
checksums.txt
|
||||||
|
|||||||
Reference in New Issue
Block a user