1
0
Fork 1
mirror of https://github.com/zen-browser/desktop.git synced 2025-07-08 07:10:01 +02:00

Fixed flatpak

This commit is contained in:
Mauro Balades 2024-08-04 22:30:16 +02:00
parent 36d6abda0d
commit b37b2e656a
2 changed files with 59 additions and 43 deletions

View file

@ -364,19 +364,21 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Update repo
- name: Clone flatpak repo
uses: actions/checkout@v4
with:
repository: flathub/io.github.zen_browser.zen
token: ${{ secrets.DEPLOY_KEY }}
- name: Download linux generic build
uses: actions/download-artifact@v4
with:
name: zen.linux-generic.tar.bz2
- name: Clone flatpak repo
- name: Update repo
uses: actions/checkout@v4
with:
repository: flathub/io.github.zen_browser.zen
path: flatpak-repo
path: zen-browser
token: ${{ secrets.DEPLOY_KEY }}
- name: Download flatpak archive
@ -385,22 +387,34 @@ jobs:
- name: Setup git
run: |
cd flatpak-repo
git config --global user.email "mauro-balades@users.noreply.github.com"
git config --global user.name "mauro-balades"
git checkout -b update-to-${{ needs.build-data.outputs.version }}
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
- name: Prepare flatpak manifest
run: |
python3 ./scripts/prepare-flatpak-release.py ${{ needs.build-data.outputs.version }}
rm flatpak-repo/io.github.zen_browser.zen.yml
mv flatpak/io.github.zen_browser.zen.yml flatpak-repo/io.github.zen_browser.zen.yml
python3 ./zen-browser/scripts/prepare-flatpak-release.py \
--flatpak-archive archive.tar \
--version ${{ needs.build-data.outputs.version }} \
--linux-archive zen.linux-generic.tar.bz2 \
--output io.github.zen_browser.zen.yml \
--template-root ./zen-browser/flatpak
- name: Create pull request
uses: peter-evans/create-pull-request@v6
env:
GIT_TRACE: 1
GIT_CURL_VERBOSE: 1
with:
token: ${{ secrets.DEPLOY_KEY }}
commit-message: 🚀 Update to version ${{ needs.build-data.outputs.version }}
title: 🚀 Update to version ${{ needs.build-data.outputs.version }}
body: |
This PR updates the Zen Browser Flatpak package to version ${{ needs.build-data.outputs.version }}.
@mauro-balades
branch: update-to-${{ needs.build-data.outputs.version }}
base: master
git-token: ${{ secrets.DEPLOY_KEY }}
delete-branch: true
- name: Publish flatpak
run: |
cd flatpak-repo
git add .
git commit -m "Update Zen Browser to ${{ needs.build-data.outputs.version }}"
git push origin update-to-${{ needs.build-data.outputs.version }}

View file

@ -3,14 +3,9 @@ import os
import sys
import hashlib
import argparse
FLATID = "io.github.zen_browser.zen"
TEMPLATE = open(f"flatpak/{FLATID}.yml.template").read()
LINUX_ARCHIVE = "zen.linux-generic.tar.bz2"
FLATPAK_ARCHIVE = "archive.tar"
VERSION = sys.argv[1]
def get_sha256sum(filename):
sha256 = hashlib.sha256()
@ -19,31 +14,38 @@ def get_sha256sum(filename):
sha256.update(byte_block)
return sha256.hexdigest()
def build_template(linux_sha256, flatpak_sha256):
return TEMPLATE.format(linux_sha256=linux_sha256,
def build_template(template, linux_sha256, flatpak_sha256, version):
return template.format(linux_sha256=linux_sha256,
flatpak_sha256=flatpak_sha256,
version=VERSION)
version=version)
def check_required_files():
if not os.path.exists(LINUX_ARCHIVE):
print(f"File {LINUX_ARCHIVE} not found")
sys.exit(1)
if not os.path.exists(FLATPAK_ARCHIVE):
print(f"File {FLATPAK_ARCHIVE} not found")
sys.exit(1)
if not os.path.exists(f"flatpak"):
print(f"Directory flatpak not found")
def get_template(template_root):
with open(f"{template_root}/{FLATID}.yml.template", "r") as f:
return f.read()
print(f"Template {template_root}/flatpak.yml not found")
sys.exit(1)
def main():
check_required_files()
linux_sha256 = get_sha256sum(LINUX_ARCHIVE)
flatpak_sha256 = get_sha256sum(FLATPAK_ARCHIVE)
parser = argparse.ArgumentParser(description='Prepare flatpak release')
parser.add_argument('--version', help='Version of the release', required=True)
parser.add_argument('--linux-archive', help='Linux archive', required=True)
parser.add_argument('--flatpak-archive', help='Flatpak archive', required=True)
parser.add_argument('--output', help='Output file', default=f"{FLATID}.yml")
parser.add_argument('--template-root', help='Template root', default="flatpak")
args = parser.parse_args()
template = build_template(linux_sha256, flatpak_sha256)
version = args.version
linux_archive = args.linux_archive
flatpak_archive = args.flatpak_archive
output = args.output
template_root = args.template_root
with open(f"flatpak/{FLATID}.yml", "w") as f:
linux_sha256 = get_sha256sum(linux_archive)
flatpak_sha256 = get_sha256sum(flatpak_archive)
template = build_template(get_template(template_root), linux_sha256, flatpak_sha256, version)
with open(output, "w") as f:
f.write(template)
if __name__ == "__main__":