mirror of
https://github.com/zen-browser/desktop.git
synced 2025-07-08 04:49:59 +02:00
Merge pull request #4162 from cristiancmoises/patch-2
This commit is contained in:
commit
040a8fad5b
6 changed files with 297 additions and 245 deletions
|
@ -1,136 +1,119 @@
|
||||||
param(
|
param(
|
||||||
|
[ValidateNotNullOrEmpty()]
|
||||||
[string][Parameter(Mandatory=$true)]$SignIdentity,
|
[string][Parameter(Mandatory=$true)]$SignIdentity,
|
||||||
|
|
||||||
|
[ValidateNotNullOrEmpty()]
|
||||||
[string][Parameter(Mandatory=$true)]$GithubRunId
|
[string][Parameter(Mandatory=$true)]$GithubRunId
|
||||||
)
|
)
|
||||||
|
|
||||||
$ErrorActionPreference = "Stop"
|
$ErrorActionPreference = "Stop"
|
||||||
|
|
||||||
echo "Preparing environment"
|
function Download-Artifacts {
|
||||||
git pull --recurse-submodules
|
param(
|
||||||
mkdir windsign-temp -ErrorAction SilentlyContinue
|
[string]$Name,
|
||||||
|
[string]$GithubRunId
|
||||||
# Download in parallel
|
)
|
||||||
|
gh run download $GithubRunId --name $Name -D (Join-Path $PWD 'windsign-temp\windows-x64-obj-' + $Name)
|
||||||
#show output too
|
Write-Verbose "Downloaded $Name artifacts"
|
||||||
#Start-Job -Name "DownloadGitObjectsRepo" -ScriptBlock {
|
|
||||||
# param($PWD)
|
|
||||||
# echo "Downloading git objects repo to $PWD\windsign-temp\windows-binaries"
|
|
||||||
# git clone https://github.com/zen-browser/windows-binaries.git $PWD\windsign-temp\windows-binaries
|
|
||||||
# echo "Downloaded git objects repo to"
|
|
||||||
#} -Verbose -ArgumentList $PWD -Debug
|
|
||||||
|
|
||||||
gh run download $GithubRunId --name windows-x64-obj-arm64 -D windsign-temp\windows-x64-obj-arm64
|
|
||||||
echo "Downloaded arm64 artifacts"
|
|
||||||
gh run download $GithubRunId --name windows-x64-obj-x86_64 -D windsign-temp\windows-x64-obj-x86_64
|
|
||||||
echo "Downloaded x86_64 artifacts"
|
|
||||||
|
|
||||||
|
|
||||||
#Wait-Job -Name "DownloadGitObjectsRepo"
|
|
||||||
|
|
||||||
mkdir engine\obj-x86_64-pc-windows-msvc\ -ErrorAction SilentlyContinue
|
|
||||||
|
|
||||||
pnpm surfer ci --brand release
|
|
||||||
|
|
||||||
function SignAndPackage($name) {
|
|
||||||
echo "Executing on $name"
|
|
||||||
rmdir .\dist -Recurse -ErrorAction SilentlyContinue
|
|
||||||
rmdir engine\obj-x86_64-pc-windows-msvc\ -Recurse -ErrorAction SilentlyContinue
|
|
||||||
cp windsign-temp\windows-x64-obj-$name engine\obj-x86_64-pc-windows-msvc\ -Recurse
|
|
||||||
echo "Signing $name"
|
|
||||||
|
|
||||||
# Collect all .exe and .dll files into a list
|
|
||||||
$files = Get-ChildItem engine\obj-x86_64-pc-windows-msvc\ -Recurse -Include *.exe
|
|
||||||
$files += Get-ChildItem engine\obj-x86_64-pc-windows-msvc\ -Recurse -Include *.dll
|
|
||||||
|
|
||||||
signtool.exe sign /n "$SignIdentity" /t http://time.certum.pl/ /fd sha256 /v $files
|
|
||||||
echo "Packaging $name"
|
|
||||||
$env:SURFER_SIGNING_MODE="sign"
|
|
||||||
$env:MAR="$PWD\\build\\winsign\\mar.exe"
|
|
||||||
if ($name -eq "arm64") {
|
|
||||||
$env:SURFER_COMPAT="aarch64"
|
|
||||||
} else {
|
|
||||||
$env:SURFER_COMPAT="x86_64"
|
|
||||||
}
|
|
||||||
|
|
||||||
echo "Compat Mode? $env:SURFER_COMPAT"
|
|
||||||
pnpm surfer package --verbose
|
|
||||||
|
|
||||||
# In the release script, we do the following:
|
|
||||||
# tar -xvf .github/workflows/object/windows-x64-signed-x86_64.tar.gz -C windows-x64-signed-x86_64
|
|
||||||
# We need to create a tar with the same structure and no top-level directory
|
|
||||||
# Inside, we need:
|
|
||||||
# - update_manifest/*
|
|
||||||
# - windows.mar
|
|
||||||
# - zen.installer.exe
|
|
||||||
# - zen.win-x86_64.zip
|
|
||||||
echo "Creating tar for $name"
|
|
||||||
rm .\windsign-temp\windows-x64-signed-$name -Recurse -ErrorAction SilentlyContinue
|
|
||||||
mkdir windsign-temp\windows-x64-signed-$name
|
|
||||||
|
|
||||||
# Move the MAR, add the `-arm64` suffix if needed
|
|
||||||
echo "Moving MAR for $name"
|
|
||||||
if ($name -eq "arm64") {
|
|
||||||
mv .\dist\output.mar windsign-temp\windows-x64-signed-$name\windows-$name.mar
|
|
||||||
} else {
|
|
||||||
mv .\dist\output.mar windsign-temp\windows-x64-signed-$name\windows.mar
|
|
||||||
}
|
|
||||||
|
|
||||||
# Move the installer
|
|
||||||
echo "Moving installer for $name"
|
|
||||||
if ($name -eq "arm64") {
|
|
||||||
mv .\dist\zen.installer.exe windsign-temp\windows-x64-signed-$name\zen.installer-$name.exe
|
|
||||||
} else {
|
|
||||||
mv .\dist\zen.installer.exe windsign-temp\windows-x64-signed-$name\zen.installer.exe
|
|
||||||
}
|
|
||||||
|
|
||||||
# Move the zip
|
|
||||||
echo "Moving zip for $name"
|
|
||||||
if ($name -eq "arm64") {
|
|
||||||
mv (Get-Item .\dist\*.en-US.win64-aarch64.zip) windsign-temp\windows-x64-signed-$name\zen.win-arm64.zip
|
|
||||||
} else {
|
|
||||||
mv (Get-Item .\dist\*.en-US.win64.zip) windsign-temp\windows-x64-signed-$name\zen.win-$name.zip
|
|
||||||
}
|
|
||||||
|
|
||||||
# Extract the zip, sign everything inside, and repackage it
|
|
||||||
Expand-Archive -Path windsign-temp\windows-x64-signed-$name\zen.win-$name.zip -DestinationPath windsign-temp\windows-x64-signed-$name\zen.win-$name
|
|
||||||
rm windsign-temp\windows-x64-signed-$name\zen.win-$name.zip
|
|
||||||
$files = Get-ChildItem windsign-temp\windows-x64-signed-$name\zen.win-$name -Recurse -Include *.exe
|
|
||||||
$files += Get-ChildItem windsign-temp\windows-x64-signed-$name\zen.win-$name -Recurse -Include *.dll
|
|
||||||
signtool.exe sign /n "$SignIdentity" /t http://time.certum.pl/ /fd sha256 /v $files
|
|
||||||
Compress-Archive -Path windsign-temp\windows-x64-signed-$name\zen.win-$name -DestinationPath windsign-temp\windows-x64-signed-$name\zen.win-$name.zip
|
|
||||||
rmdir windsign-temp\windows-x64-signed-$name\zen.win-$name -Recurse -ErrorAction SilentlyContinue
|
|
||||||
|
|
||||||
# Move the manifest
|
|
||||||
mv .\dist\update\. windsign-temp\windows-x64-signed-$name\update_manifest
|
|
||||||
|
|
||||||
echo "Invoking tar for $name"
|
|
||||||
# note: We need to sign it into a parent folder, called windows-x64-signed-$name
|
|
||||||
rmdir .\windsign-temp\windows-binaries\windows-x64-signed-$name -Recurse -ErrorAction SilentlyContinue
|
|
||||||
mv windsign-temp\windows-x64-signed-$name .\windsign-temp\windows-binaries -Force
|
|
||||||
|
|
||||||
echo "Finished $name"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SignAndPackage arm64
|
function Sign-Files {
|
||||||
SignAndPackage x86_64
|
param(
|
||||||
|
[string]$Path
|
||||||
|
)
|
||||||
|
$files = Get-ChildItem -Path $Path -Recurse -Include *.exe, *.dll
|
||||||
|
signtool.exe sign /n "$SignIdentity" /t http://time.certum.pl/ /fd sha256 /v $files
|
||||||
|
}
|
||||||
|
|
||||||
echo "All artifacts signed and packaged, ready for release!"
|
function Move-File {
|
||||||
echo "Commiting the changes to the repository"
|
param(
|
||||||
cd windsign-temp\windows-binaries
|
[string]$Source,
|
||||||
|
[string]$Destination
|
||||||
|
)
|
||||||
|
if (Test-Path $Source) {
|
||||||
|
Move-Item $Source -Destination $Destination -Force
|
||||||
|
Write-Verbose "Moved $Source to $Destination"
|
||||||
|
} else {
|
||||||
|
Write-Warning "Source file $Source does not exist."
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function Create-Tar {
|
||||||
|
param(
|
||||||
|
[string]$Name
|
||||||
|
)
|
||||||
|
$tarPath = Join-Path $PWD "windsign-temp\windows-x64-signed-$Name"
|
||||||
|
Remove-Item -Path $tarPath -Recurse -ErrorAction SilentlyContinue
|
||||||
|
New-Item -ItemType Directory -Path $tarPath | Out-Null
|
||||||
|
|
||||||
|
Move-File -Source ".\dist\output.mar" -Destination (Join-Path $tarPath ("windows-$Name.mar"))
|
||||||
|
Move-File -Source ".\dist\zen.installer.exe" -Destination (Join-Path $tarPath ("zen.installer$($Name -eq 'arm64' ? '-arm64' : '') .exe"))
|
||||||
|
Move-File -Source (Get-ChildItem ".\dist\*.en-US.win64$($Name -eq 'arm64' ? '-aarch64' : '') .zip" | Select-Object -First 1) -Destination (Join-Path $tarPath ("zen.win-$Name.zip"))
|
||||||
|
}
|
||||||
|
|
||||||
|
function SignAndPackage {
|
||||||
|
param(
|
||||||
|
[string]$Name
|
||||||
|
)
|
||||||
|
|
||||||
|
Write-Verbose "Executing on $Name"
|
||||||
|
Remove-Item -Path ".\dist" -Recurse -ErrorAction SilentlyContinue
|
||||||
|
Remove-Item -Path "engine\obj-x86_64-pc-windows-msvc\" -Recurse -ErrorAction SilentlyContinue
|
||||||
|
Copy-Item -Path (Join-Path $PWD "windsign-temp\windows-x64-obj-$Name") -Destination "engine\obj-x86_64-pc-windows-msvc\" -Recurse
|
||||||
|
Write-Verbose "Signing $Name"
|
||||||
|
|
||||||
|
Sign-Files -Path "engine\obj-x86_64-pc-windows-msvc\"
|
||||||
|
|
||||||
|
$env:SURFER_SIGNING_MODE = "sign"
|
||||||
|
$env:MAR = (Join-Path $PWD "build\winsign\mar.exe")
|
||||||
|
$env:SURFER_COMPAT = if ($Name -eq "arm64") { "aarch64" } else { "x86_64" }
|
||||||
|
Write-Verbose "Compat Mode? $env:SURFER_COMPAT"
|
||||||
|
|
||||||
|
pnpm surfer package --verbose
|
||||||
|
|
||||||
|
Create-Tar -Name $Name
|
||||||
|
|
||||||
|
# Extract and sign the contents of the zip
|
||||||
|
Expand-Archive -Path (Join-Path $tarPath ("zen.win-$Name.zip")) -DestinationPath (Join-Path $tarPath ("zen.win-$Name"))
|
||||||
|
Remove-Item -Path (Join-Path $tarPath ("zen.win-$Name.zip")) -ErrorAction SilentlyContinue
|
||||||
|
|
||||||
|
Sign-Files -Path (Join-Path $tarPath ("zen.win-$Name"))
|
||||||
|
Compress-Archive -Path (Join-Path $tarPath ("zen.win-$Name")) -DestinationPath (Join-Path $tarPath ("zen.win-$Name.zip"))
|
||||||
|
Remove-Item -Path (Join-Path $tarPath ("zen.win-$Name")) -Recurse -ErrorAction SilentlyContinue
|
||||||
|
|
||||||
|
Move-File -Source ".\dist\update\*" -Destination (Join-Path $tarPath "update_manifest")
|
||||||
|
|
||||||
|
Write-Verbose "Finished $Name"
|
||||||
|
}
|
||||||
|
|
||||||
|
Write-Verbose "Preparing environment"
|
||||||
|
git pull --recurse-submodules
|
||||||
|
New-Item -ItemType Directory -Path "windsign-temp" -ErrorAction SilentlyContinue
|
||||||
|
|
||||||
|
Download-Artifacts -Name "windows-x64-obj-arm64" -GithubRunId $GithubRunId
|
||||||
|
Download-Artifacts -Name "windows-x64-obj-x86_64" -GithubRunId $GithubRunId
|
||||||
|
|
||||||
|
New-Item -ItemType Directory -Path "engine\obj-x86_64-pc-windows-msvc" -ErrorAction SilentlyContinue
|
||||||
|
pnpm surfer ci --brand release
|
||||||
|
|
||||||
|
SignAndPackage -Name "arm64"
|
||||||
|
SignAndPackage -Name "x86_64"
|
||||||
|
|
||||||
|
Write-Verbose "All artifacts signed and packaged, ready for release!"
|
||||||
|
Write-Verbose "Committing the changes to the repository"
|
||||||
|
cd (Join-Path $PWD "windsign-temp\windows-binaries")
|
||||||
git add .
|
git add .
|
||||||
git commit -m "Sign and package windows artifacts"
|
git commit -m "Sign and package windows artifacts"
|
||||||
git push
|
git push
|
||||||
cd ..\..
|
cd -
|
||||||
|
|
||||||
# Cleaning up
|
# Cleaning up
|
||||||
|
Write-Verbose "Cleaning up"
|
||||||
|
Remove-Item -Path "windsign-temp\windows-x64-obj-x86_64" -Recurse -ErrorAction SilentlyContinue
|
||||||
|
Remove-Item -Path "windsign-temp\windows-x64-obj-arm64" -Recurse -ErrorAction SilentlyContinue
|
||||||
|
|
||||||
echo "All done!"
|
Write-Verbose "Opening Visual Studio Code"
|
||||||
echo "All the artifacts (x86_64 and arm46) are signed and packaged, get a rest now!"
|
|
||||||
Read-Host "Press Enter to continue"
|
|
||||||
|
|
||||||
echo "Cleaning up"
|
|
||||||
rmdir windsign-temp\windows-x64-obj-x86_64 -Recurse -ErrorAction SilentlyContinue
|
|
||||||
rmdir windsign-temp\windows-x64-obj-arm64 -Recurse -ErrorAction SilentlyContinue
|
|
||||||
|
|
||||||
echo "Opening visual studio code"
|
|
||||||
code .
|
code .
|
||||||
|
Write-Host "All done! Press Enter to continue."
|
||||||
|
Read-Host
|
||||||
|
|
||||||
|
|
|
@ -1,63 +1,61 @@
|
||||||
import json
|
import json
|
||||||
import sys
|
|
||||||
import os
|
import os
|
||||||
import requests
|
import requests
|
||||||
|
from typing import Optional
|
||||||
|
|
||||||
RESPONSE = 'rc-response.json'
|
RESPONSE_FILENAME = 'rc-response.json'
|
||||||
METADATA = 'surfer.json'
|
METADATA_FILENAME = 'surfer.json'
|
||||||
|
|
||||||
def get_current_version():
|
def get_current_version() -> Optional[str]:
|
||||||
with open(METADATA) as f:
|
"""Retrieve the current version from the metadata file."""
|
||||||
metadata = json.load(f)
|
try:
|
||||||
return metadata['version']['candidate']
|
with open(METADATA_FILENAME) as f:
|
||||||
|
metadata = json.load(f)
|
||||||
|
return metadata['version']['candidate']
|
||||||
|
except (FileNotFoundError, json.JSONDecodeError) as e:
|
||||||
|
print(f"Error reading current version: {e}")
|
||||||
|
return None
|
||||||
|
|
||||||
def get_rc_response():
|
def get_rc_response() -> Optional[str]:
|
||||||
with open(RESPONSE) as f:
|
"""Get the release candidate response from the response file."""
|
||||||
data = json.load(f)
|
try:
|
||||||
for tag_dict in data['tags']:
|
with open(RESPONSE_FILENAME) as f:
|
||||||
tag = tag_dict['tag']
|
data = json.load(f)
|
||||||
is_valid_tag = (tag.startswith('FIREFOX') and tag.endswith('_BUILD1')
|
for tag_dict in data['tags']:
|
||||||
and not 'ESR' in tag and not 'b' in tag)
|
tag = tag_dict['tag']
|
||||||
if is_valid_tag:
|
if (tag.startswith('FIREFOX') and tag.endswith('_BUILD1')
|
||||||
return tag.replace('FIREFOX_', '').replace('_BUILD1', '').replace('_', '.')
|
and 'ESR' not in tag and 'b' not in tag):
|
||||||
return None
|
return tag.replace('FIREFOX_', '').replace('_BUILD1', '').replace('_', '.')
|
||||||
|
except (FileNotFoundError, json.JSONDecodeError) as e:
|
||||||
|
print(f"Error reading RC response: {e}")
|
||||||
|
return None
|
||||||
|
|
||||||
def get_pings():
|
def get_pings() -> str:
|
||||||
pings = ""
|
"""Build a string of Discord user IDs for mentions."""
|
||||||
for ping in os.getenv('DISCORD_PING_IDS').split(','):
|
ping_ids = os.getenv('DISCORD_PING_IDS', '')
|
||||||
pings += "<@%s> " % ping
|
return ' '.join(f"<@{ping.strip()}>" for ping in ping_ids.split(',') if ping.strip())
|
||||||
return pings
|
|
||||||
|
|
||||||
def send_webhook(rc: str):
|
def send_webhook(rc: str) -> None:
|
||||||
text = "||%s|| New Firefox RC version is available: **%s**" % (get_pings(), rc)
|
"""Send a message to the Discord webhook."""
|
||||||
webhook_url = os.getenv('DISCORD_WEBHOOK_URL') #os.getenv('DISCORD_WEBHOOK_URL')
|
text = f"||{get_pings()}|| New Firefox RC version is available: **{rc}**"
|
||||||
message = {
|
webhook_url = os.getenv('DISCORD_WEBHOOK_URL')
|
||||||
"content": text,
|
|
||||||
"username": "Firefox RC Checker",
|
if webhook_url:
|
||||||
"avatar_url": "https://avatars.githubusercontent.com/u/189789277?v=4",
|
message = {
|
||||||
}
|
"content": text,
|
||||||
response = requests.post(webhook_url, json=message)
|
"username": "Firefox RC Checker",
|
||||||
if response.status_code == 204:
|
}
|
||||||
print("Message sent successfully!")
|
try:
|
||||||
else:
|
response = requests.post(webhook_url, json=message)
|
||||||
print(f"Failed to send message: {response.status_code}")
|
response.raise_for_status() # Raise an error for bad responses
|
||||||
|
except requests.RequestException as e:
|
||||||
|
print(f"Error sending webhook: {e}")
|
||||||
|
else:
|
||||||
|
print("Webhook URL not set.")
|
||||||
|
|
||||||
def main():
|
if __name__ == "__main__":
|
||||||
current = get_current_version()
|
current_version = get_current_version()
|
||||||
if not current:
|
rc_response = get_rc_response()
|
||||||
print('Could not find current version')
|
|
||||||
return 1
|
if rc_response and rc_response != current_version:
|
||||||
rc = get_rc_response()
|
send_webhook(rc_response)
|
||||||
if not rc:
|
|
||||||
print('Could not find RC version')
|
|
||||||
return 1
|
|
||||||
if current != rc:
|
|
||||||
print('Current version is %s, but RC version is %s' % (current, rc))
|
|
||||||
# Here, we should update the current version in surfer.json
|
|
||||||
send_webhook(rc)
|
|
||||||
return 0
|
|
||||||
print('Current version is %s, and RC version is %s' % (current, rc))
|
|
||||||
return 1
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
sys.exit(main())
|
|
||||||
|
|
|
@ -1,52 +1,61 @@
|
||||||
import hashlib
|
import hashlib
|
||||||
import argparse
|
import argparse
|
||||||
import sys
|
import sys
|
||||||
|
import os
|
||||||
|
|
||||||
FLATID = "io.github.zen_browser.zen"
|
FLATID = "io.github.zen_browser.zen"
|
||||||
|
|
||||||
def get_sha256sum(filename):
|
def get_sha256sum(filename):
|
||||||
"""Calculate the SHA256 checksum of a file."""
|
"""Calculate the SHA256 checksum of a file."""
|
||||||
sha256 = hashlib.sha256()
|
sha256 = hashlib.sha256()
|
||||||
|
try:
|
||||||
with open(filename, "rb") as f:
|
with open(filename, "rb") as f:
|
||||||
for byte_block in iter(lambda: f.read(4096), b""):
|
for byte_block in iter(lambda: f.read(4096), b""):
|
||||||
sha256.update(byte_block)
|
sha256.update(byte_block)
|
||||||
return sha256.hexdigest()
|
except FileNotFoundError:
|
||||||
|
print(f"File {filename} not found.")
|
||||||
|
sys.exit(1)
|
||||||
|
return sha256.hexdigest()
|
||||||
|
|
||||||
def build_template(template, linux_sha256, flatpak_sha256, version):
|
def build_template(template, linux_sha256, flatpak_sha256, version):
|
||||||
print(f"Building template with version {version}")
|
"""Build the template with the provided hashes and version."""
|
||||||
print(f"\tLinux archive sha256: {linux_sha256}")
|
print(f"Building template with version {version}")
|
||||||
print(f"\tFlatpak archive sha256: {flatpak_sha256}")
|
print(f"\tLinux archive sha256: {linux_sha256}")
|
||||||
return template.format(linux_sha256=linux_sha256,
|
print(f"\tFlatpak archive sha256: {flatpak_sha256}")
|
||||||
flatpak_sha256=flatpak_sha256,
|
return template.format(
|
||||||
version=version)
|
linux_sha256=linux_sha256,
|
||||||
|
flatpak_sha256=flatpak_sha256,
|
||||||
|
version=version
|
||||||
|
)
|
||||||
|
|
||||||
def get_template(template_root):
|
def get_template(template_root):
|
||||||
file = f"{template_root}/{FLATID}.yml.template"
|
"""Get the template content from the specified root directory."""
|
||||||
print(f"Reading template {file}")
|
file = os.path.join(template_root, f"{FLATID}.yml.template")
|
||||||
try:
|
print(f"Reading template {file}")
|
||||||
with open(file, "r") as f:
|
try:
|
||||||
return f.read()
|
with open(file, "r") as f:
|
||||||
except FileNotFoundError:
|
return f.read()
|
||||||
print(f"Template {file} not found")
|
except FileNotFoundError:
|
||||||
sys.exit(1)
|
print(f"Template {file} not found.")
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
parser = argparse.ArgumentParser(description='Prepare flatpak release')
|
"""Main function to parse arguments and process files."""
|
||||||
parser.add_argument('--version', help='Version of the release', required=True)
|
parser = argparse.ArgumentParser(description='Prepare flatpak release')
|
||||||
parser.add_argument('--linux-archive', help='Linux archive', required=True)
|
parser.add_argument('--version', help='Version of the release', required=True)
|
||||||
parser.add_argument('--flatpak-archive', help='Flatpak archive', required=True)
|
parser.add_argument('--linux-archive', help='Linux archive', required=True)
|
||||||
parser.add_argument('--output', help='Output file', default=f"{FLATID}.yml")
|
parser.add_argument('--flatpak-archive', help='Flatpak archive', required=True)
|
||||||
parser.add_argument('--template-root', help='Template root', default="flatpak")
|
parser.add_argument('--output', help='Output file', default=f"{FLATID}.yml")
|
||||||
args = parser.parse_args()
|
parser.add_argument('--template-root', help='Template root', default="flatpak")
|
||||||
|
args = parser.parse_args()
|
||||||
|
|
||||||
linux_sha256 = get_sha256sum(args.linux_archive)
|
linux_sha256 = get_sha256sum(args.linux_archive)
|
||||||
flatpak_sha256 = get_sha256sum(args.flatpak_archive)
|
flatpak_sha256 = get_sha256sum(args.flatpak_archive)
|
||||||
template = build_template(get_template(args.template_root), linux_sha256, flatpak_sha256, args.version)
|
template = build_template(get_template(args.template_root), linux_sha256, flatpak_sha256, args.version)
|
||||||
|
|
||||||
print(f"Writing output to {args.output}")
|
print(f"Writing output to {args.output}")
|
||||||
with open(args.output, "w") as f:
|
with open(args.output, "w") as f:
|
||||||
f.write(template)
|
f.write(template)
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main()
|
main()
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
gh_bulk_delete_workflow_runs() {
|
gh_bulk_delete_workflow_runs() {
|
||||||
repo=$1
|
local repo=$1
|
||||||
|
|
||||||
# Ensure the repo argument is provided
|
# Ensure the repo argument is provided
|
||||||
if [[ -z "$repo" ]]; then
|
if [[ -z "$repo" ]]; then
|
||||||
|
@ -7,14 +9,37 @@ gh_bulk_delete_workflow_runs() {
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
runs=$(gh api repos/$repo/actions/runs --paginate | jq -r '.workflow_runs[] | select(.conclusion == "cancelled" or .conclusion == "failure" or .conclusion == "timed_out") | .id')
|
# Fetch workflow runs that are cancelled, failed, or timed out
|
||||||
|
local runs
|
||||||
|
runs=$(gh api repos/$repo/actions/runs --paginate |
|
||||||
|
jq -r '.workflow_runs[] |
|
||||||
|
select(.conclusion == "cancelled" or
|
||||||
|
.conclusion == "failure" or
|
||||||
|
.conclusion == "timed_out") |
|
||||||
|
.id')
|
||||||
|
|
||||||
|
if [[ -z "$runs" ]]; then
|
||||||
|
echo "No workflow runs found for $repo with the specified conclusions."
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Loop through each run and delete it
|
||||||
while IFS= read -r run; do
|
while IFS= read -r run; do
|
||||||
echo "Deleting run https://github.com/$repo/actions/runs/$run"
|
echo "Attempting to delete run: https://github.com/$repo/actions/runs/$run"
|
||||||
gh api -X DELETE repos/$repo/actions/runs/$run --silent
|
|
||||||
|
# Perform the deletion
|
||||||
|
if gh api -X DELETE repos/$repo/actions/runs/$run --silent; then
|
||||||
|
echo "Successfully deleted run: $run"
|
||||||
|
else
|
||||||
|
echo "Error deleting run: $run" >&2
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Optional delay to avoid hitting API rate limits
|
||||||
|
sleep 1
|
||||||
done <<< "$runs"
|
done <<< "$runs"
|
||||||
|
|
||||||
echo "All workflow runs for $repo have been deleted."
|
echo "Completed deletion process for workflow runs in $repo."
|
||||||
}
|
}
|
||||||
|
|
||||||
gh_bulk_delete_workflow_runs $1
|
# Execute the function with the provided argument
|
||||||
|
gh_bulk_delete_workflow_runs "$1"
|
||||||
|
|
|
@ -1,37 +1,43 @@
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import json
|
import json
|
||||||
|
|
||||||
last_version = "0.0.0"
|
|
||||||
new_version = "0.0.0"
|
|
||||||
|
|
||||||
def update_ff():
|
def update_ff():
|
||||||
os.system("npm run update-ff:raw")
|
"""Runs the npm command to update the 'ff' component."""
|
||||||
|
result = os.system("npm run update-ff:raw")
|
||||||
|
if result != 0:
|
||||||
|
raise RuntimeError("Failed to update 'ff' component.")
|
||||||
|
|
||||||
def get_version_before():
|
def get_version_from_file(filename):
|
||||||
global last_version
|
"""Retrieves the version from the specified JSON file."""
|
||||||
with open("surfer.json", "r") as f:
|
try:
|
||||||
data = json.load(f)
|
with open(filename, "r") as f:
|
||||||
last_version = data["version"]["version"]
|
data = json.load(f)
|
||||||
|
return data["version"]["version"]
|
||||||
|
except (FileNotFoundError, json.JSONDecodeError) as e:
|
||||||
|
raise RuntimeError(f"Error reading version from {filename}: {e}")
|
||||||
|
|
||||||
def get_version_after():
|
def update_readme(last_version, new_version):
|
||||||
global new_version
|
"""Updates the README.md file to reflect the new version."""
|
||||||
with open("surfer.json", "r") as f:
|
try:
|
||||||
data = json.load(f)
|
with open("README.md", "r") as f:
|
||||||
new_version = data["version"]["version"]
|
data = f.read()
|
||||||
|
updated_data = data.replace(last_version, new_version)
|
||||||
|
|
||||||
def update_readme():
|
with open("README.md", "w") as f:
|
||||||
global last_version
|
f.write(updated_data)
|
||||||
global new_version
|
except FileNotFoundError as e:
|
||||||
with open("README.md", "r") as f:
|
raise RuntimeError(f"README.md file not found: {e}")
|
||||||
data = f.read()
|
|
||||||
data = data.replace(last_version, new_version)
|
def main():
|
||||||
with open("README.md", "w") as f:
|
"""Main function to update versions and README."""
|
||||||
f.write(data)
|
try:
|
||||||
|
last_version = get_version_from_file("surfer.json")
|
||||||
|
update_ff()
|
||||||
|
new_version = get_version_from_file("surfer.json")
|
||||||
|
update_readme(last_version, new_version)
|
||||||
|
print(f"Updated version from {last_version} to {new_version} in README.md.")
|
||||||
|
except Exception as e:
|
||||||
|
print(f"An error occurred: {e}")
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
get_version_before()
|
main()
|
||||||
update_ff()
|
|
||||||
get_version_after()
|
|
||||||
update_readme()
|
|
||||||
print("Updated from version {} to version {}".format(last_version, new_version))
|
|
||||||
|
|
|
@ -1,9 +1,40 @@
|
||||||
import os
|
import os
|
||||||
|
import subprocess
|
||||||
|
import logging
|
||||||
|
|
||||||
|
# Set up logging
|
||||||
|
logging.basicConfig(level=logging.INFO)
|
||||||
|
|
||||||
|
# Constants for paths
|
||||||
|
NEW_TAB_DIR = './engine/browser/components/newtab'
|
||||||
|
ENGINE_DIR = './engine'
|
||||||
|
NPM_INSTALL_COMMANDS = [
|
||||||
|
"npm install",
|
||||||
|
"npm install meow@9.0.0"
|
||||||
|
]
|
||||||
|
BUNDLE_COMMAND = "npm run bundle --prefix=browser/components/newtab"
|
||||||
|
|
||||||
|
def install_dependencies():
|
||||||
|
"""Install necessary npm packages for the newtab component."""
|
||||||
|
for command in NPM_INSTALL_COMMANDS:
|
||||||
|
logging.info(f"Running command: {command} in {NEW_TAB_DIR}")
|
||||||
|
subprocess.run(command.split(), cwd=NEW_TAB_DIR, check=True)
|
||||||
|
|
||||||
|
def bundle_newtab_components():
|
||||||
|
"""Bundle the newtab components."""
|
||||||
|
logging.info(f"Bundling newtab components in {ENGINE_DIR}")
|
||||||
|
subprocess.run(BUNDLE_COMMAND.split(), cwd=ENGINE_DIR, check=True)
|
||||||
|
|
||||||
def update_newtab(init: bool = True):
|
def update_newtab(init: bool = True):
|
||||||
if init:
|
"""Update the newtab components, optionally initializing dependencies."""
|
||||||
os.system("(cd ./engine/browser/components/newtab && ../../../mach npm install && ../../../mach npm install meow@9.0.0)")
|
try:
|
||||||
os.system("cd ./engine && ./mach npm run bundle --prefix=browser/components/newtab")
|
if init:
|
||||||
|
install_dependencies()
|
||||||
|
|
||||||
|
bundle_newtab_components()
|
||||||
|
except subprocess.CalledProcessError as e:
|
||||||
|
logging.error(f"An error occurred: {e}")
|
||||||
|
raise
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
update_newtab(False)
|
update_newtab(init=False)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue