Merge pull request #18 from 0xc000022070/feat/support-for-aarch64
Support for aarch64 + automated updates for twilight and beta versions
This commit is contained in:
18
.github/new-version.sh
vendored
18
.github/new-version.sh
vendored
@@ -1,18 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
echo "Fetching upstream version from GitHub API..." >&2
|
||||
upstream_data=$(curl -s https://api.github.com/repos/zen-browser/desktop/releases/latest)
|
||||
echo "Upstream data: $upstream_data" >&2
|
||||
|
||||
upstream=$(echo "$upstream_data" | tr -d '\000-\037\177' | jq -r '.tag_name')
|
||||
echo "Upstream version is: $upstream" >&2
|
||||
|
||||
local=$(grep -oP 'beta_version = "\K[^"]+' flake.nix)
|
||||
echo "Current version (local) is: $local" >&2 # first!
|
||||
|
||||
if [ "$upstream" != "$local" ]; then
|
||||
echo "new_version=true" >>"$GITHUB_OUTPUT"
|
||||
echo "upstream=$upstream" >>"$GITHUB_OUTPUT"
|
||||
fi
|
||||
|
||||
echo "$upstream"
|
||||
43
.github/update-zen-browser.bash
vendored
43
.github/update-zen-browser.bash
vendored
@@ -1,43 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
script_dir="$(dirname -- "$0")"
|
||||
|
||||
upstream="null"
|
||||
|
||||
max_attempts=10
|
||||
attempts=1
|
||||
|
||||
while [ "$upstream" == "null" ]; do
|
||||
upstream=$("$script_dir/new-version.sh")
|
||||
|
||||
if [ "$upstream" != "null" ]; then
|
||||
break
|
||||
elif [ $attempts -ge $max_attempts ]; then
|
||||
echo "Unable to determine new upstream version"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "[attempt #${attempts}] Unable to determine new upstream version, retrying in 5 seconds..."
|
||||
attempts=$((attempts + 1))
|
||||
sleep 5
|
||||
done
|
||||
|
||||
upstream=$("$script_dir/new-version.sh" | cat -)
|
||||
if [ "$upstream" == "null" ]; then
|
||||
echo "Unable to determine new upstream version"
|
||||
return 1
|
||||
fi
|
||||
|
||||
echo "Updating to $upstream"
|
||||
|
||||
base_url="https://github.com/zen-browser/desktop/releases/download/$upstream"
|
||||
|
||||
# Modify with sed the nix file
|
||||
sed -i "s/beta_version = \".*\"/beta_version = \"$upstream\"/" ./flake.nix
|
||||
|
||||
# Update the hash sha256
|
||||
hash=$(nix-prefetch-url --type sha256 --unpack "$base_url/zen.linux-x86_64.tar.bz2")
|
||||
sed -i "s/beta_hash = \".*\"/beta_hash = \"$hash\"/" ./flake.nix
|
||||
|
||||
nix flake update
|
||||
nix build .#beta
|
||||
111
.github/update.sh
vendored
Executable file
111
.github/update.sh
vendored
Executable file
@@ -0,0 +1,111 @@
|
||||
#!/bin/sh
|
||||
|
||||
ci=false
|
||||
if echo "$@" | grep -qoE '(--ci)'; then
|
||||
ci=true
|
||||
fi
|
||||
|
||||
only_check=false
|
||||
if echo "$@" | grep -qoE '(--only-check)'; then
|
||||
only_check=true
|
||||
fi
|
||||
|
||||
repo_tags=$(curl 'https://api.github.com/repos/zen-browser/desktop/tags' -s)
|
||||
|
||||
twilight_tag=$(echo "$repo_tags" | jq -r '.[]|select(.name|test("twilight"))')
|
||||
beta_tag=$(echo "$repo_tags" | jq -r '(map(select(.name | test("-b.")))) | first')
|
||||
|
||||
commit_beta_targets=""
|
||||
commit_beta_version=""
|
||||
commit_twilight_targets=""
|
||||
commit_twilight_version=""
|
||||
|
||||
try_to_update() {
|
||||
name=$1
|
||||
arch=$2
|
||||
target_tag_meta=$3
|
||||
|
||||
meta=$(jq ".[\"$name\"][\"$arch-linux\"]" <sources.json)
|
||||
|
||||
local_sha1=$(echo "$meta" | jq -r '.sha1')
|
||||
remote_sha1=$(echo "$target_tag_meta" | jq -r '.commit.sha')
|
||||
|
||||
echo "Checking $name version @ $arch... local=$local_sha1 remote=$remote_sha1"
|
||||
|
||||
if [ "$local_sha1" = "$remote_sha1" ]; then
|
||||
echo "Local $name version is up to date"
|
||||
else
|
||||
echo "Local $name version is outdated"
|
||||
|
||||
if $only_check; then
|
||||
echo "should_update=true" >>"$GITHUB_OUTPUT"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
version=$(echo "$target_tag_meta" | jq -r '.name')
|
||||
download_url="https://github.com/zen-browser/desktop/releases/download/$version/zen.linux-$arch.tar.bz2"
|
||||
|
||||
prefetch_output=$(nix store prefetch-file --hash-type sha256 --json "$download_url")
|
||||
sha256=$(echo "$prefetch_output" | jq -r '.hash')
|
||||
|
||||
jq ".[\"$name\"][\"$arch-linux\"] = {\"name\":\"$name\",\"version\":\"$version\",\"sha1\":\"$remote_sha1\",\"url\":\"$download_url\",\"sha256\":\"$sha256\"}" <sources.json >sources.json.tmp
|
||||
mv sources.json.tmp sources.json
|
||||
|
||||
echo "$name was updated to $version" # missing nix build!
|
||||
|
||||
if ! $ci; then
|
||||
return
|
||||
fi
|
||||
|
||||
if [ "$name" = "beta" ]; then
|
||||
if [ "$commit_beta_targets" = "" ]; then
|
||||
commit_beta_targets="$arch"
|
||||
commit_beta_version="$version"
|
||||
else
|
||||
commit_beta_targets="$commit_beta_targets && $arch"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "$name" = "twilight" ]; then
|
||||
if [ "$commit_twilight_targets" = "" ]; then
|
||||
commit_twilight_targets="$arch"
|
||||
commit_twilight_version="latest"
|
||||
else
|
||||
commit_twilight_targets="$commit_twilight_targets && $arch"
|
||||
fi
|
||||
|
||||
fi
|
||||
|
||||
fi
|
||||
}
|
||||
|
||||
set -e
|
||||
|
||||
try_to_update "beta" "x86_64" "$beta_tag"
|
||||
try_to_update "beta" "aarch64" "$beta_tag"
|
||||
try_to_update "twilight" "x86_64" "$twilight_tag"
|
||||
try_to_update "twilight" "aarch64" "$twilight_tag"
|
||||
|
||||
if $only_check && $ci; then
|
||||
echo "should_update=false" >>"$GITHUB_OUTPUT"
|
||||
fi
|
||||
|
||||
# Check if there are changes
|
||||
if ! git diff --exit-code >/dev/null; then
|
||||
init_message="Update Zen Browser"
|
||||
message="$init_message"
|
||||
|
||||
if [ "$commit_beta_targets" != "" ]; then
|
||||
message="$message beta @ $commit_beta_targets to $commit_beta_version"
|
||||
fi
|
||||
|
||||
if [ "$commit_twilight_targets" != "" ]; then
|
||||
if [ "$message" != "$init_message" ]; then
|
||||
message="$message and"
|
||||
fi
|
||||
|
||||
message="$message twilight @ $commit_twilight_targets to $commit_twilight_version"
|
||||
fi
|
||||
|
||||
echo "commit_message=$message" >>"$GITHUB_OUTPUT"
|
||||
fi
|
||||
21
.github/workflows/zen-update.yml
vendored
21
.github/workflows/zen-update.yml
vendored
@@ -13,29 +13,30 @@ jobs:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Check new version
|
||||
id: new-version
|
||||
- name: Check if update is needed
|
||||
id: check
|
||||
run: |
|
||||
.github/new-version.sh
|
||||
.github/update.sh --ci --only-check
|
||||
|
||||
- name: Install Nix
|
||||
if: steps.new-version.outputs.new_version == 'true'
|
||||
if: steps.check.outputs.should_update == 'true'
|
||||
uses: cachix/install-nix-action@v27
|
||||
with:
|
||||
nix_path: nixpkgs=channel:nixpkgs-unstable
|
||||
|
||||
- name: Setup Nix Magic Cache
|
||||
if: steps.new-version.outputs.new_version == 'true'
|
||||
if: steps.check.outputs.should_update == 'true'
|
||||
uses: DeterminateSystems/magic-nix-cache-action@main
|
||||
|
||||
- name: Update hashes and test build
|
||||
if: steps.new-version.outputs.new_version == 'true'
|
||||
- name: Update versions
|
||||
id: update
|
||||
if: steps.check.outputs.should_update == 'true'
|
||||
run: |
|
||||
.github/update-zen-browser.bash
|
||||
.github/update.sh --ci
|
||||
|
||||
- name: Commit changes
|
||||
if: steps.new-version.outputs.new_version == 'true'
|
||||
if: steps.check.outputs.should_update == 'true'
|
||||
uses: stefanzweifel/git-auto-commit-action@v5
|
||||
with:
|
||||
commit_message: "Update Zen Browser to v${{ steps.new-version.outputs.upstream }}"
|
||||
commit_message: "${{ steps.update.outputs.commit_message }}"
|
||||
file_pattern: "*"
|
||||
|
||||
62
flake.nix
62
flake.nix
@@ -1,41 +1,16 @@
|
||||
{
|
||||
description = "Zen Browser";
|
||||
|
||||
inputs = {nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable";};
|
||||
inputs.nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable";
|
||||
|
||||
outputs = {
|
||||
self,
|
||||
nixpkgs,
|
||||
}: let
|
||||
system = "x86_64-linux";
|
||||
mkZen = name: system: let
|
||||
pkgs = import nixpkgs {inherit system;};
|
||||
variant = (builtins.fromJSON (builtins.readFile ./sources.json)).${name}.${system};
|
||||
|
||||
prepareUrl = version: arch: "https://github.com/zen-browser/desktop/releases/download/${version}/zen.linux-${arch}.tar.bz2";
|
||||
|
||||
beta_version = "1.0.2-b.5";
|
||||
beta_hash = "1xp0z86l7z661cwckgr623gwwjsy3h66900xqjq6dvgx5a3njbxi";
|
||||
|
||||
beta = {
|
||||
name = "beta";
|
||||
url = prepareUrl beta_version "x86_64";
|
||||
sha256 = beta_hash;
|
||||
version = beta_version;
|
||||
};
|
||||
|
||||
twilight = {
|
||||
name = "twilight";
|
||||
url = prepareUrl "twilight" "x86_64";
|
||||
sha256 = "0yhlkyj87fylmjr8zfqv73ljx99wry8j07r19bl88078pll4ifn2";
|
||||
version = "twilight";
|
||||
};
|
||||
|
||||
pkgs = import nixpkgs {inherit system;};
|
||||
|
||||
mkZen = {
|
||||
name,
|
||||
url,
|
||||
sha256,
|
||||
version,
|
||||
}: let
|
||||
runtimeLibs = with pkgs;
|
||||
[
|
||||
libGL
|
||||
@@ -95,10 +70,10 @@
|
||||
});
|
||||
in
|
||||
pkgs.stdenv.mkDerivation {
|
||||
inherit version;
|
||||
inherit (variant) version;
|
||||
pname = "zen-browser";
|
||||
|
||||
src = builtins.fetchTarball {inherit url sha256;};
|
||||
src = builtins.fetchTarball {inherit (variant) url sha256;};
|
||||
desktopSrc = ./.;
|
||||
|
||||
phases = ["installPhase" "fixupPhase"];
|
||||
@@ -106,12 +81,12 @@
|
||||
nativeBuildInputs = [pkgs.makeWrapper pkgs.copyDesktopItems pkgs.wrapGAppsHook];
|
||||
|
||||
installPhase = ''
|
||||
mkdir -p $out/{bin,opt/zen,lib/zen-${version}/distribution} && cp -r $src/* $out/opt/zen
|
||||
mkdir -p $out/{bin,opt/zen,lib/zen-${variant.version}/distribution} && cp -r $src/* $out/opt/zen
|
||||
ln -s $out/opt/zen/zen $out/bin/zen
|
||||
ln -s ${policiesJson} "$out/lib/zen-${version}/distribution/policies.json"
|
||||
ln -s $out/bin/zen $out/bin/zen-${name}
|
||||
ln -s ${policiesJson} "$out/lib/zen-${variant.version}/distribution/policies.json"
|
||||
ln -s $out/bin/zen $out/bin/zen-${variant.name}
|
||||
|
||||
install -D $desktopSrc/zen-${name}.desktop $out/share/applications/zen.desktop
|
||||
install -D $desktopSrc/zen-${variant.name}.desktop $out/share/applications/zen.desktop
|
||||
|
||||
install -D $src/browser/chrome/icons/default/default16.png $out/share/icons/hicolor/16x16/apps/zen.png
|
||||
install -D $src/browser/chrome/icons/default/default32.png $out/share/icons/hicolor/32x32/apps/zen.png
|
||||
@@ -153,11 +128,18 @@
|
||||
|
||||
meta.mainProgram = "zen";
|
||||
};
|
||||
|
||||
supportedSystems = [
|
||||
"x86_64-linux"
|
||||
"aarch64-linux"
|
||||
];
|
||||
|
||||
forAllSystems = nixpkgs.lib.genAttrs supportedSystems;
|
||||
in {
|
||||
packages."${system}" = {
|
||||
default = mkZen beta;
|
||||
beta = mkZen beta;
|
||||
twilight = mkZen twilight;
|
||||
};
|
||||
packages = forAllSystems (system: {
|
||||
default = mkZen "beta" system;
|
||||
beta = mkZen "beta" system;
|
||||
twilight = mkZen "twilight" system;
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
34
sources.json
Normal file
34
sources.json
Normal file
@@ -0,0 +1,34 @@
|
||||
{
|
||||
"beta": {
|
||||
"x86_64-linux": {
|
||||
"name": "beta",
|
||||
"version": "1.0.2-b.5",
|
||||
"sha1": "20c16af6d399fc325572e9beb404c160a1130aa8",
|
||||
"url": "https://github.com/zen-browser/desktop/releases/download/1.0.2-b.5/zen.linux-x86_64.tar.bz2",
|
||||
"sha256": "1xp0z86l7z661cwckgr623gwwjsy3h66900xqjq6dvgx5a3njbxi"
|
||||
},
|
||||
"aarch64-linux": {
|
||||
"name": "beta",
|
||||
"version": "1.0.2-b.5",
|
||||
"sha1": "20c16af6d399fc325572e9beb404c160a1130aa8",
|
||||
"url": "https://github.com/zen-browser/desktop/releases/download/1.0.2-b.5/zen.linux-aarch64.tar.bz2",
|
||||
"sha256": "sha256-NwIYylGal2QoWhWKtMhMkAAJQ6iNHfQOBZaxTXgvxAk="
|
||||
}
|
||||
},
|
||||
"twilight": {
|
||||
"x86_64-linux": {
|
||||
"name": "twilight",
|
||||
"version": "twilight",
|
||||
"sha1": "c88dbd3f02016b568e4de61b7c20ade45b2a16d1",
|
||||
"url": "https://github.com/zen-browser/desktop/releases/download/twilight/zen.linux-x86_64.tar.bz2",
|
||||
"sha256": "0yhlkyj87fylmjr8zfqv73ljx99wry8j07r19bl88078pll4ifn2"
|
||||
},
|
||||
"aarch64-linux": {
|
||||
"name": "twilight",
|
||||
"version": "twilight",
|
||||
"sha1": "c88dbd3f02016b568e4de61b7c20ade45b2a16d1",
|
||||
"url": "https://github.com/zen-browser/desktop/releases/download/twilight/zen.linux-aarch64.tar.bz2",
|
||||
"sha256": "sha256-3u6nxVsHXNvDywHAwJWlOEAWxHV/FzWp6kPTmS5HlsQ="
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user