From 58e1adf0ed0019a568a35e5f318d7300d4e175d9 Mon Sep 17 00:00:00 2001 From: wargio Date: Tue, 19 Mar 2024 11:26:00 +0800 Subject: [PATCH] For master always build against release, dev instead against dev. --- .ci-scripts/ci-build-linux.sh | 24 +++++++++++++++++++----- .ci-scripts/ci-rizin-dl.py | 22 ++++++++++++++-------- .github/workflows/build-plugin.yml | 6 +++--- 3 files changed, 36 insertions(+), 16 deletions(-) diff --git a/.ci-scripts/ci-build-linux.sh b/.ci-scripts/ci-build-linux.sh index 59001ba..64f0ab6 100644 --- a/.ci-scripts/ci-build-linux.sh +++ b/.ci-scripts/ci-build-linux.sh @@ -1,9 +1,15 @@ #!/bin/bash set -e +CI_BRANCH="$1" CI_BRANCH="$1" CI_JSDEC="$PWD" -CI_RZ_VERSION=$(curl -s GET https://api.github.com/repos/rizinorg/rizin/tags\?per_page\=1 | jq -r '.[].name') +CI_RZ_VERSION=$2 + +if [ "$2" != "dev" ]; then + # master branch always build against latest release of rizin + CI_RZ_VERSION=$(curl -s GET https://api.github.com/repos/rizinorg/rizin/tags\?per_page\=1 | jq -r '.[].name') +fi echo "CI_BRANCH: $CI_BRANCH" echo "CI_RZ_VERSION: $CI_RZ_VERSION" @@ -12,11 +18,19 @@ echo "CI_JSDEC: $CI_JSDEC" # avoid placing rizin in the same folder. cd .. -# download the latest tagged rizin version and install it -wget -O "rizin.tar.xz" "https://github.com/rizinorg/rizin/releases/download/$CI_RZ_VERSION/rizin-src-$CI_RZ_VERSION.tar.xz" -tar xf "rizin.tar.xz" -cd "rizin-$CI_RZ_VERSION" +# download rizin +if [ "$CI_RZ_VERSION" == "dev" ]; then + # dev branch always build against latest commit of rizin + wget -O "rizin.tar.gz" "https://github.com/rizinorg/rizin/archive/refs/heads/dev.tar.gz" + tar xf "rizin.tar.gz" +else + # master branch always build against latest release of rizin + wget -O "rizin.tar.xz" "https://github.com/rizinorg/rizin/releases/download/$CI_RZ_VERSION/rizin-src-$CI_RZ_VERSION.tar.xz" + tar xf "rizin.tar.xz" +fi +# build rizin and install it. +cd "rizin-$CI_RZ_VERSION" meson setup --buildtype=release -Denable_tests=false build sudo ninja -C build install diff --git a/.ci-scripts/ci-rizin-dl.py b/.ci-scripts/ci-rizin-dl.py index 591f9db..3cbc0c6 100644 --- a/.ci-scripts/ci-rizin-dl.py +++ b/.ci-scripts/ci-rizin-dl.py @@ -4,19 +4,25 @@ import os file_name = sys.argv[1] +latest = "master" if len(sys.argv) < 2 else sys.argv[2] + _, file_extension = os.path.splitext(file_name) out_file = f"rizin{file_extension}" print(file_name, out_file) -tags = None -with urllib.request.urlopen('https://api.github.com/repos/rizinorg/rizin/tags?per_page=1') as f: - tags = json.load(f) -latest = tags[0]['name'] - -url = f"https://github.com/rizinorg/rizin/releases/download/{latest}/{file_name}" -url = url.format(version=latest) +if latest != "dev": + # master branch always build against latest release of rizin + tags = None + with urllib.request.urlopen('https://api.github.com/repos/rizinorg/rizin/tags?per_page=1') as f: + tags = json.load(f) + latest = tags[0]['name'] + url = f"https://github.com/rizinorg/rizin/releases/download/{latest}/{file_name}" + url = url.format(version=latest) +else: + # dev branch always build against latest commit of rizin + url = "https://github.com/rizinorg/rizin/archive/refs/heads/dev.zip" -print(f"Latest rizin tag: {latest}") +print(f"Using rizin branch: {latest}") print(f"{url} as {out_file}") urllib.request.urlretrieve(url, out_file) diff --git a/.github/workflows/build-plugin.yml b/.github/workflows/build-plugin.yml index 0e52ff5..d50dd26 100644 --- a/.github/workflows/build-plugin.yml +++ b/.github/workflows/build-plugin.yml @@ -21,7 +21,7 @@ jobs: - name: Install dependencies run: sudo apt -y install meson ninja-build - name: Build & run the plugin - run: bash .ci-scripts/ci-build-linux.sh "${{ github.ref_name }}" + run: bash .ci-scripts/ci-build-linux.sh "${{ github.event.pull_request.base.ref || github.ref_name }}" windows-64: runs-on: windows-latest @@ -52,8 +52,8 @@ jobs: run: | WORKDIR="$PWD" cd .. - python "$WORKDIR/.ci-scripts/ci-rizin-dl.py" 'rizin-${{ matrix.release }}-{version}.zip' - unzip rizin.zip + python "$WORKDIR/.ci-scripts/ci-rizin-dl.py" 'rizin-${{ matrix.release }}-{version}.zip' '${{ github.event.pull_request.base.ref || github.ref_name }}' + unzip -q rizin.zip rm *.zip mv rizin* rizin cd "$WORKDIR"